module PacketThief::Handlers::TransparentProxy::ProxyConnection

Represents a connection out to the original destination.

Attributes

closing[RW]

Boolean that represents whether this handler has started to close/unbind. Used to ensure there is no unbind-loop between the two connections that make up the proxy.

connected[RW]

Boolean that represents whether the connection has connected yet.

Public Class Methods

new(client_conn) click to toggle source

Sets up references to the client proxy connection handler that created this handler.

# File lib/packetthief/handlers/transparent_proxy.rb, line 20
def initialize(client_conn)
  @client = client_conn

  @connected = false
  @closing = false
end

Public Instance Methods

post_init() click to toggle source
# File lib/packetthief/handlers/transparent_proxy.rb, line 27
def post_init
  @client._send_buffer
end
receive_data(data) click to toggle source

Transmit data sent by the destinaton to the client.

# File lib/packetthief/handlers/transparent_proxy.rb, line 32
def receive_data(data)
  @client.dest_recv(data)
end
unbind() click to toggle source

Start the closing process and close the other connection if it is not already closing.

# File lib/packetthief/handlers/transparent_proxy.rb, line 38
def unbind
  @client.dest_closed
  self.closing = true
  @client.close_connection_after_writing if @client and not @client.closing
end