Sha256: 6930fb0f4f94ce939e44ddbe1e86e0c81222d306eea334d598502f50943ba5d2

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 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
      if @config.unbind_handler
        @config.unbind_handler.call(get_proxied_bytes)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
r_socks-0.2.6 lib/r_socks/target_connection_handler.rb