Sha256: 0bbb983e185d88e40c2b6b5db551d3cd8d1248378fee59b59a5e4a5594685178
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
require 'webrick' require 'webrick/https' require 'http_tunnel_common.rb' require 'pp' class HTTPSTunnelServer include WEBrick 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 def run trap("INT"){ @s.shutdown } @s.start end private def readLoop begin loop do curdata=@socket.recv(101200) if curdata.length>0 #pp "GOT DATA (at #{@socket.addr}) #{curdata.length}" else #puts "NO MORE DATA" break end @mutex.synchronize { @out << curdata } end rescue Object=>e pp e,e.backtrace end end end s=HTTPSTunnelServer.new("127.0.0.1",22) s.run
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appswarm-0.0.1 | lib/appswarm/tools/http_tunnel_server.rb |