This is a utility class used internally by Forward::Driver. It manages the network server instance for each locally forwarded port, and is passed as the handler to Driver#direct_channel by Forward::Driver#forward_local. Other clients may desire to extend this class and pass the modified class to Forward::Driver#direct_channel for their own purposes, but in general this class will rarely be used outside of Forward::Driver.

Methods
Public Class methods
new( log, block_size, client )

Create a new LocalNetworkHandler for the given client connection.

    # File lib/net/ssh/service/forward/local-network-handler.rb, line 32
32:           def initialize( log, block_size, client )
33:             @log = log
34:             @block_size = block_size
35:             @client = client
36:           end
Public Instance methods
on_eof( channel )

Invoked when the remote end of the channel will no longer be sending data. It may still receive data, however.

    # File lib/net/ssh/service/forward/local-network-handler.rb, line 46
46:           def on_eof( channel )
47:             channel[:eof] = true
48:           end
on_receive( channel, data )

Invoked when data is recieved from the channel. This method just sends the data to the client connection.

    # File lib/net/ssh/service/forward/local-network-handler.rb, line 40
40:           def on_receive( channel, data )
41:             @client.send data, 0
42:           end
process( channel )

Called to process the channel in a loop. It will repeatedly read from the client and send the results across the channel.

    # File lib/net/ssh/service/forward/local-network-handler.rb, line 52
52:           def process( channel )
53:             loop do
54:               break if channel[:eof]
55:               data = @client.recv(@block_size) or break
56:               channel.send_data data unless data.empty?
57:             end
58: 
59:             channel.close
60:           rescue StandardError, Exception => e
61:             @log.error "error processing connection: " +
62:               "#{e.class} (#{e.message})\n  " +
63:               e.backtrace.join("\n  ")
64:           end