Class: Dizby::BidirectionalTunnelStrategy

Inherits:
Object
  • Object
show all
Includes:
TunnelableLocal, TunnelableRemote
Defined in:
lib/dizby/tunnel/bidirectional_strategy.rb

Instance Method Summary collapse

Methods included from TunnelableRemote

#create_remote_tunnel

Methods included from TunnelableLocal

#create_local_tunnel

Constructor Details

#initialize(server_port, client_port) ⇒ BidirectionalTunnelStrategy

Returns a new instance of BidirectionalTunnelStrategy.


10
11
12
13
# File 'lib/dizby/tunnel/bidirectional_strategy.rb', line 10

def initialize(server_port, client_port)
  @server_port = server_port
  @client_port = client_port
end

Instance Method Details

#read(stream)


22
23
24
25
26
27
# File 'lib/dizby/tunnel/bidirectional_strategy.rb', line 22

def read(stream)
  local_tunnel = stream.gets.chomp.to_i
  remote_tunnel = stream.gets.chomp.to_i

  [local_tunnel, remote_tunnel]
end

#write(ssh, stream)


15
16
17
18
19
20
# File 'lib/dizby/tunnel/bidirectional_strategy.rb', line 15

def write(ssh, stream)
  local_tunnel = create_local_tunnel(ssh, @server_port)
  remote_tunnel = create_remote_tunnel(ssh, @client_port)

  stream.puts local_tunnel, remote_tunnel
end