Class: Net::SSH::Service::Forward
- Inherits:
-
Object
- Object
- Net::SSH::Service::Forward
- Defined in:
- lib/devproxy/net-ssh-patch.rb
Overview
Read remote port from channel.
Instance Method Summary collapse
Instance Method Details
#remote(port, host, remote_port, remote_host = "127.0.0.1", &blk) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/devproxy/net-ssh-patch.rb', line 10 def remote(port, host, remote_port, remote_host="127.0.0.1",&blk) session.send_global_request("tcpip-forward", :string, remote_host, :long, remote_port) do |success, response| if success remote_port = response.read_long if remote_port.zero? debug { "remote forward from remote #{remote_host}:#{remote_port} to #{host}:#{port} established" } blk.call(remote_port) if blk @remote_forwarded_ports[[remote_port, remote_host]] = Remote.new(host, port) else error { "remote forwarding request failed" } raise Net::SSH::Exception, "remote forwarding request failed" end end end |