Class: TransocksEM::TransocksTCPServer
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- TransocksEM::TransocksTCPServer
- Defined in:
- lib/transocks_em.rb
Instance Attribute Summary collapse
-
#closed ⇒ Object
Returns the value of attribute closed.
Instance Method Summary collapse
- #connection_completed ⇒ Object
-
#initialize(ipfw_natd_style = false) ⇒ TransocksTCPServer
constructor
A new instance of TransocksTCPServer.
- #post_init ⇒ Object
- #proxy_target_unbound ⇒ Object
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(ipfw_natd_style = false) ⇒ TransocksTCPServer
Returns a new instance of TransocksTCPServer.
61 62 63 64 |
# File 'lib/transocks_em.rb', line 61 def initialize(ipfw_natd_style = false) logger.debug { "started server, ipfw_natd_style: #{ipfw_natd_style}" } @ipfw_natd_style = ipfw_natd_style end |
Instance Attribute Details
#closed ⇒ Object
Returns the value of attribute closed.
59 60 61 |
# File 'lib/transocks_em.rb', line 59 def closed @closed end |
Instance Method Details
#connection_completed ⇒ Object
66 67 68 |
# File 'lib/transocks_em.rb', line 66 def connection_completed logger.debug { "connection_completed" } end |
#post_init ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/transocks_em.rb', line 70 def post_init return if @ipfw_natd_style orig_host, orig_port = orig_sockaddr orig_host = [orig_host].pack("N").unpack("CCCC")*'.' proxy_to orig_host, orig_port end |
#proxy_target_unbound ⇒ Object
89 90 91 |
# File 'lib/transocks_em.rb', line 89 def proxy_target_unbound close_connection end |
#receive_data(data) ⇒ Object
79 80 81 82 83 84 85 86 87 |
# File 'lib/transocks_em.rb', line 79 def receive_data(data) @buf ||= '' @buf << data if @buf.gsub!(/\[DEST (\d+\.\d+\.\d+\.\d+) (\d+)\] *\n/m, '') orig_host, orig_port = $1, $2.to_i proxy_to orig_host, orig_port @proxied.send_data @buf end end |
#unbind ⇒ Object
93 94 95 96 |
# File 'lib/transocks_em.rb', line 93 def unbind self.closed = true @proxied.close_connection_after_writing if @proxied end |