Sha256: 2f8de16afa71b9288ee38e969007842389f2f17109a62c3d61f777d47172b911

Contents?: true

Size: 703 Bytes

Versions: 2

Compression:

Stored size: 703 Bytes

Contents

require 'eventmachine'
require 'r_socks/http_proxy_response_codes'

module RSocks
  class TargetConnectionHandler < EM::Connection

    def initialize(client, config)
      @client = client
      @config = config
    end

    def connection_completed
      if @config.proxy_type == :http
        @client.send_data(RSocks::HttpProxyResponseCodes::SUCCESS)
      end
      @client.proxy_incoming_to(self, @config.proxy_buffer_size)
      proxy_incoming_to(@client, @config.proxy_buffer_size)
    end

    def receive_data(data)
      @client.send_data(data)
    end

    def proxy_target_unbound
      close_connection
    end

    def unbind
      @client.close_connection_after_writing
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
r_socks-0.2.5 lib/r_socks/target_connection_handler.rb
r_socks-0.2.4 lib/r_socks/target_connection_handler.rb