Class: FFWD::Plugin::Tunnel::ConnectionTCP

Inherits:
Connection
  • Object
show all
Includes:
EM::Protocols::LineText2, Logging
Defined in:
lib/ffwd/plugin/tunnel/connection_tcp.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bind, core, config) ⇒ ConnectionTCP

Returns a new instance of ConnectionTCP.



29
30
31
32
33
34
# File 'lib/ffwd/plugin/tunnel/connection_tcp.rb', line 29

def initialize bind, core, config
  @bind = bind
  @core = core
  @tunnel_protocol = BinaryProtocol
  @protocol_instance = nil
end

Class Method Details

.plugin_typeObject



25
26
27
# File 'lib/ffwd/plugin/tunnel/connection_tcp.rb', line 25

def self.plugin_type
  "tunnel_in_tcp"
end

Instance Method Details

#get_peerObject



44
45
46
47
48
49
50
# File 'lib/ffwd/plugin/tunnel/connection_tcp.rb', line 44

def get_peer
  peer = get_peername
  port, ip = Socket.unpack_sockaddr_in(peer)
  "#{ip}:#{port}"
rescue
  nil
end

#metadata?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/ffwd/plugin/tunnel/connection_tcp.rb', line 62

def metadata?
  not @metadata.nil?
end

#post_initObject



52
53
54
# File 'lib/ffwd/plugin/tunnel/connection_tcp.rb', line 52

def post_init
  @protocol_instance = @tunnel_protocol.new @core, self
end

#receive_binary_data(data) ⇒ Object



40
41
42
# File 'lib/ffwd/plugin/tunnel/connection_tcp.rb', line 40

def receive_binary_data data
  @protocol_instance.receive_binary_data data
end

#receive_line(line) ⇒ Object



36
37
38
# File 'lib/ffwd/plugin/tunnel/connection_tcp.rb', line 36

def receive_line line
  @protocol_instance.receive_line line
end

#unbindObject



56
57
58
59
60
# File 'lib/ffwd/plugin/tunnel/connection_tcp.rb', line 56

def unbind
  log.info "Shutting down tunnel connection"
  @protocol_instance.stop
  @protocol_instance = nil
end