Module: Pipe2me::Tunnel::Commands
- Extended by:
- Commands
- Included in:
- Pipe2me::Tunnel, Commands
- Defined in:
- lib/pipe2me/tunnel/commands.rb
Defined Under Namespace
Classes: Spec
Constant Summary collapse
Instance Method Summary collapse
-
#command ⇒ Object
return an arry [ [name, command ], [name, command ], .. ].
- #tunnel_uri ⇒ Object
- #tunnels ⇒ Object
Instance Method Details
#command ⇒ Object
return an arry [ [name, command ], [name, command ], .. ]
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pipe2me/tunnel/commands.rb', line 25 def command port_mappings = tunnels.map do |tunnel| "-R 0.0.0.0:#{tunnel.remote_port}:localhost:#{tunnel.local_port}" end cmd = <<-SHELL env AUTOSSH_GATETIME=0 #{Which::AUTOSSH} -M 0 -F #{T::SSH_CONFIG} #{tunnel_uri.user}@#{tunnel_uri.host} -p #{tunnel_uri.port} #{port_mappings.join(" ")} -i #{T::SSH_PRIVKEY} -o StrictHostKeyChecking=no -o UserKnownHostsFile=pipe2me.known_hosts -o PasswordAuthentication=no -o ExitOnForwardFailure=yes -N SHELL cmd.gsub(/\s+/, " ") end |
#tunnel_uri ⇒ Object
6 7 8 |
# File 'lib/pipe2me/tunnel/commands.rb', line 6 def tunnel_uri URI.parse config.tunnel end |
#tunnels ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pipe2me/tunnel/commands.rb', line 16 def tunnels urls, ports = config.urls, config.ports.split(",") urls.zip(ports).map do |url, local_port| uri = URI.parse(url) Spec.new uri.scheme, uri.host, uri.port, local_port || uri.port end end |