Sha256: e373b4223ccbfb763945a4655cb372319de6f4fe22ac692caafbd96ad9a8149c
Contents?: true
Size: 1.07 KB
Versions: 10
Compression:
Stored size: 1.07 KB
Contents
require 'picsolve_docker_builder/base' require 'net/ssh' module PicsolveDockerBuilder module Helpers # Ruby class that can forward a remote port over SSH class SshForward def self.forward(*args) f = new(*args) f.bind_port f end include PicsolveDockerBuilder::Base attr_reader :connection, :local_port def initialize(connection, remote_host, remote_port, local_port = nil) @connection = connection @remote_host = remote_host @remote_port = remote_port @local_port = local_port || remote_port end def bind_port tries = 0 begin connection.forward.local(@local_port, @remote_host, @remote_port) log.info "forward remote port #{@remote_host}:#{@remote_port}" \ " to local port #{@local_port}" return @local_port rescue Errno::EADDRINUSE => e # raise after five failed tries raise e if tries > 5 tries += 1 @local_port += 1 retry end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems