Class: RSocks::TargetConnectionHandler
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- RSocks::TargetConnectionHandler
- Defined in:
- lib/r_socks/target_connection_handler.rb
Instance Method Summary collapse
- #assign_user_and_password(username, password) ⇒ Object
- #connection_completed ⇒ Object
-
#initialize(client, config, connect_data = nil) ⇒ TargetConnectionHandler
constructor
A new instance of TargetConnectionHandler.
- #proxy_target_unbound ⇒ Object
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(client, config, connect_data = nil) ⇒ TargetConnectionHandler
Returns a new instance of TargetConnectionHandler.
7 8 9 10 11 12 13 |
# File 'lib/r_socks/target_connection_handler.rb', line 7 def initialize(client, config, connect_data = nil) @client = client @config = config @connect_data = connect_data @forward_connection = !@connect_data.nil? @forward_success = false end |
Instance Method Details
#assign_user_and_password(username, password) ⇒ Object
15 16 17 18 |
# File 'lib/r_socks/target_connection_handler.rb', line 15 def assign_user_and_password(username, password) @username = username @password = password end |
#connection_completed ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/r_socks/target_connection_handler.rb', line 20 def connection_completed if @connect_data send_data(@connect_data) else response_proxy_connect_ready end end |
#proxy_target_unbound ⇒ Object
37 38 39 |
# File 'lib/r_socks/target_connection_handler.rb', line 37 def proxy_target_unbound close_connection end |
#receive_data(data) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/r_socks/target_connection_handler.rb', line 28 def receive_data(data) if @forward_connection && !@forward_success if data == RSocks::HttpProxyResponseCodes::SUCCESS @forward_success = true response_proxy_connect_ready end end end |
#unbind ⇒ Object
41 42 43 44 45 46 |
# File 'lib/r_socks/target_connection_handler.rb', line 41 def unbind @client.close_connection_after_writing if @config.unbind_handler @config.unbind_handler.call(get_proxied_bytes, @username, @password) end end |