lib/fulmar/infrastructure/service/tunnel_service.rb in fulmar-0.6.5 vs lib/fulmar/infrastructure/service/tunnel_service.rb in fulmar-1.0.0
- old
+ new
@@ -4,19 +4,20 @@
module Infrastructure
module Service
class TunnelService
attr_reader :host, :remote_port, :local_port
- def initialize(host, port)
+ def initialize(host, port, remote_host = 'localhost')
@host = host
@remote_port = port
+ @remote_host = remote_host
@local_port = 0
@tunnel_pid = 0
end
def open
@local_port = free_port
- @tunnel_pid = Process.spawn "ssh #{@host} -L #{@local_port}:localhost:#{@remote_port} -N"
+ @tunnel_pid = Process.spawn "ssh #{@host} -L #{@local_port}:#{@remote_host}:#{@remote_port} -N"
sleep 1
end
def close
Process.kill 'TERM', @tunnel_pid if @tunnel_pid > 0
\ No newline at end of file