Class: FFWD::Tunnel::TCP

Inherits:
Object
  • Object
show all
Includes:
Lifecycle, Reporter
Defined in:
lib/ffwd/tunnel/tcp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Reporter

build_meta, included, #increment, map_meta, #report!, #reporter_data

Methods included from Lifecycle

#depend_on, #start, #started?, #starting, #starting_hooks, #stop, #stopped?, #stopping, #stopping_hooks

Constructor Details

#initialize(port, core, plugin, log, connection, args) ⇒ TCP

Returns a new instance of TCP.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ffwd/tunnel/tcp.rb', line 34

def initialize port, core, plugin, log, connection, args
  @port = port
  @core = core
  @plugin = plugin
  @log = log
  @connection = connection
  @args = args

  starting do
    @plugin.tcp @port do |handle|
      log.debug "Open tcp/#{@port}"

      instance = @connection.new(nil, self, @core, *@args)
      instance.datasink = handle

      handle.data do |data|
        instance.receive_data data
      end

      handle.close do
        log.debug "Close tcp/#{@port}"
        instance.unbind
      end
    end

    @log.info "Tunneling tcp/#{@port}"
  end

  stopping do
    @log.info "Stopped tunneling tcp/#{@port}"
  end
end

Instance Attribute Details

#logObject (readonly)

Returns the value of attribute log.



32
33
34
# File 'lib/ffwd/tunnel/tcp.rb', line 32

def log
  @log
end