Class: FtpProxy::Relay
- Inherits:
-
Object
- Object
- FtpProxy::Relay
- Defined in:
- lib/ftpproxy.rb
Overview
relay is used to proxy for the data channel
Direct Known Subclasses
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(left, right) ⇒ Relay
constructor
A new instance of Relay.
- #relay ⇒ Object
Constructor Details
#initialize(left, right) ⇒ Relay
Returns a new instance of Relay.
10 11 12 |
# File 'lib/ftpproxy.rb', line 10 def initialize left, right @left, @right = left, right end |
Instance Method Details
#close ⇒ Object
25 26 27 28 |
# File 'lib/ftpproxy.rb', line 25 def close @left.close if @left and !@left.closed? @right.close if @right and !@right.closed? end |
#relay ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ftpproxy.rb', line 14 def relay # find out which way to relay (src, ), dst, ignore = IO.select [@left, @right], nil, nil, 60000 raise 'timeout waiting for data' if !src dst, = [@left, @right] - [src] while data = src.read(8192) dst.write data end close end |