Module: Dizby::TunnelableRemote

Included in:
BidirectionalTunnelStrategy
Defined in:
lib/dizby/tunnel/tunnelable_remote.rb

Instance Method Summary collapse

Instance Method Details

#create_remote_tunnel(ssh, client_port)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/dizby/tunnel/tunnelable_remote.rb', line 4

def create_remote_tunnel(ssh, client_port)
  remote_tunnel_port = nil
  ssh.forward.remote client_port, 'localhost',
                     0, 'localhost' do |remote_port|
    remote_tunnel_port = remote_port
    :no_exception
  end

  ssh.loop { remote_tunnel_port.nil? }

  if remote_tunnel_port == :error
    fail Net::SSH::Exception, 'remote forwarding request failed'
  end

  remote_tunnel_port
end