Class: HTTPSTunnelServer
- Inherits:
-
Object
- Object
- HTTPSTunnelServer
- Includes:
- WEBrick
- Defined in:
- lib/appswarm/tools/http_tunnel_server.rb
Instance Method Summary collapse
-
#initialize(destHost, destPort) ⇒ HTTPSTunnelServer
constructor
A new instance of HTTPSTunnelServer.
- #run ⇒ Object
Constructor Details
#initialize(destHost, destPort) ⇒ HTTPSTunnelServer
Returns a new instance of HTTPSTunnelServer.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/appswarm/tools/http_tunnel_server.rb', line 9 def initialize(destHost,destPort) port=2443 @s = HTTPServer.new( :Port => port, :BindAddress=>"127.0.0.1", :SSLVerifyClient => ::OpenSSL::SSL::VERIFY_NONE, :SSLCertName => [], :SSLEnable => true ) @socket=TCPSocket.new(destHost,destPort) @socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) @mutex=Mutex.new @out=[] Thread.new {readLoop} @s.mount_proc("/"){|req, res| if req.body @socket.write(decode(req.body)) end #pp req.form_data res["Content-Type"]="data/binary" res.body="" @mutex.synchronize { if @out.length>0 res.body=encode(@out) end @out=[] } } end |
Instance Method Details
#run ⇒ Object
49 50 51 52 |
# File 'lib/appswarm/tools/http_tunnel_server.rb', line 49 def run trap("INT"){ @s.shutdown } @s.start end |