class to represent how SSH port forwarding should be performed
# File lib/rhc/commands/port-forward.rb, line 13 def initialize(service, remote_host, port_to, port_from = nil) @service = service @remote_host = remote_host @port_to = port_to @host_from = mac? ? "localhost" : remote_host # forward locally on a Mac @port_from = port_from || port_to # match ports if possible @bound = false end
:nocov: These are for sorting. No need to test for coverage.
# File lib/rhc/commands/port-forward.rb, line 39 def <=>(other) if bound? && !other.bound? -1 elsif !bound? && other.bound? 1 else order_by_attrs(other, :service, :remote_host, :port_from) end end
# File lib/rhc/commands/port-forward.rb, line 34 def bound? @bound end
# File lib/rhc/commands/port-forward.rb, line 22 def to_cmd_arg # string to be used in a direct SSH command mac? ? "-L #{port_from}:#{remote_host}:#{port_to}" : "-L #{remote_host}:#{port_from}:#{remote_host}:#{port_to}" end
# File lib/rhc/commands/port-forward.rb, line 27 def to_fwd_args # array of arguments to be passed to Net::SSH::Service::Forward#local args = [port_from.to_i, remote_host, port_to.to_i] args.unshift(remote_host) unless mac? args end