Skip to content

Instantly share code, notes, and snippets.

@ntalbott
Created December 20, 2010 23:02
Show Gist options
  • Save ntalbott/749180 to your computer and use it in GitHub Desktop.
Save ntalbott/749180 to your computer and use it in GitHub Desktop.
Automatically and temporarily exposes a little Rack server on your firewall for testing purposes. Requires UPnP to be enabled on your firewall to work.
EXTERNAL_PORT = 42063
require 'UPnP'
upnp = UPnP::UPnP.new(true, 10)
upnp.addPortMapping(EXTERNAL_PORT, 9292, UPnP::Protocol::TCP, "Test Port")
at_exit{upnp.deletePortMapping(EXTERNAL_PORT, UPnP::Protocol::TCP)}
puts "Call externally: http://#{upnp.externalIP}:#{EXTERNAL_PORT}"
run proc{|env| p :env => env; [200, {"Content-Type" => "text/html"}, ["success\n"]]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment