Class: Tortard::Bridge::Connection

Inherits:
EM::Connection
  • Object
show all
Includes:
EM::Socksify
Defined in:
lib/tortard/bridge/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bridgeObject

Returns the value of attribute bridge.



18
19
20
# File 'lib/tortard/bridge/connection.rb', line 18

def bridge
  @bridge
end

#clientObject

Returns the value of attribute client.



18
19
20
# File 'lib/tortard/bridge/connection.rb', line 18

def client
  @client
end

Instance Method Details

#connection_completedObject



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tortard/bridge/connection.rb', line 20

def connection_completed
	socksify(bridge.from.host, bridge.from.port).callback {
		if bridge.ssl == :both || bridge.ssl == :internal
			start_tls
		end

		@client.connected
	}.errback {|e|
		Tortard.log "failed to connect to #{bridge.from}"
	}
end

#receive_data(data) ⇒ Object



32
33
34
# File 'lib/tortard/bridge/connection.rb', line 32

def receive_data (data)
	@client.received data
end

#send_data(data) ⇒ Object



36
37
38
# File 'lib/tortard/bridge/connection.rb', line 36

def send_data (data)
	super
end

#unbindObject



40
41
42
# File 'lib/tortard/bridge/connection.rb', line 40

def unbind
	@client.close_connection_after_writing if @client
end