Created
February 4, 2018 21:26
-
-
Save austinschwartz/45ada69a6f49d16796f85997bbd6100d to your computer and use it in GitHub Desktop.
link-local.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
set :bind, '0.0.0.0' | |
get '/link-local/:mac' do | |
mac = params['mac'] | |
x = mac.split(':') | |
x.insert(3, 'ff') | |
x.insert(4, 'fe') | |
x[0] = (x[0].to_i(16) ^ 0b00000010).to_s(16) | |
x.insert(0, 'fe') | |
x.insert(1, '80') | |
x = x.each_slice(2).map{|x|x.join('')}.join(':') | |
x.insert(4, ":") | |
x | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment