diff --git a/tools/token-handler.cr b/tools/token-handler.cr index ad1ccd5..883f8f0 100644 --- a/tools/token-handler.cr +++ b/tools/token-handler.cr @@ -15,13 +15,20 @@ dnsmanagerd = DNSManager::Client.new server = HTTP::Server.new do |context| ip = case addr when "127.0.0.1" - pp! context.request.remote_address - context.request.remote_address.not_nil!.to_s + a = context.request.remote_address.not_nil! + case a + when Socket::IPAddress + a.address.to_s + when Socket::UNIXAddress + next + end else - pp! context.request.headers["Host"] context.request.headers["Host"] rescue next end + next if ip.nil? + pp! ip + case context.request.path when /^\/token-update\/(?[a-z0-9-]+)/ token = $~["token"] @@ -30,7 +37,7 @@ server = HTTP::Server.new do |context| context.response.print "invalid token" else context.response.content_type = "text/html" - context.response.print "coucou, token: #{token} from #{ip}" + context.response.print "token: #{token} from #{ip}" begin response = dnsmanagerd.use_token token, ip case response