Token handler: now handles local updates (from a dev environment).
This commit is contained in:
		
							parent
							
								
									f63eff59a8
								
							
						
					
					
						commit
						6a9516e2c8
					
				
					 1 changed files with 11 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -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\/(?<token>[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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue