Class: Pgai::Port::Forwarder
- Inherits:
-
Object
- Object
- Pgai::Port::Forwarder
- Defined in:
- lib/pgai/port/forwarder.rb
Constant Summary collapse
- LOCALHOST =
"127.0.0.1"
Instance Attribute Summary collapse
-
#local_port ⇒ Object
readonly
Returns the value of attribute local_port.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#remote_host ⇒ Object
readonly
Returns the value of attribute remote_host.
-
#remote_port ⇒ Object
readonly
Returns the value of attribute remote_port.
Instance Method Summary collapse
-
#initialize(local_port, remote_host, remote_port, logger: Pgai::Commander.instance.logger) ⇒ Forwarder
constructor
A new instance of Forwarder.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(local_port, remote_host, remote_port, logger: Pgai::Commander.instance.logger) ⇒ Forwarder
Returns a new instance of Forwarder.
13 14 15 16 17 18 19 |
# File 'lib/pgai/port/forwarder.rb', line 13 def initialize(local_port, remote_host, remote_port, logger: Pgai::Commander.instance.logger) @local_port = local_port @remote_host = remote_host @remote_port = remote_port @logger = logger @child, @parent = Socket.pair(:UNIX, :DGRAM) end |
Instance Attribute Details
#local_port ⇒ Object (readonly)
Returns the value of attribute local_port.
11 12 13 |
# File 'lib/pgai/port/forwarder.rb', line 11 def local_port @local_port end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
11 12 13 |
# File 'lib/pgai/port/forwarder.rb', line 11 def logger @logger end |
#remote_host ⇒ Object (readonly)
Returns the value of attribute remote_host.
11 12 13 |
# File 'lib/pgai/port/forwarder.rb', line 11 def remote_host @remote_host end |
#remote_port ⇒ Object (readonly)
Returns the value of attribute remote_port.
11 12 13 |
# File 'lib/pgai/port/forwarder.rb', line 11 def remote_port @remote_port end |
Instance Method Details
#start ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/pgai/port/forwarder.rb', line 21 def start return if ready? debug "starting" start_ssh_connection wait_until_ready debug "ready to accept connections" end |
#stop ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/pgai/port/forwarder.rb', line 30 def stop return unless @pid @parent.write("exit") debug "shutting down" Process.wait(@pid) debug "exit" @pid = nil end |