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
- T =
Pipe2me::Tunnel
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 = " env AUTOSSH_GATETIME=0\n \#{Which::AUTOSSH}\n -M 0\n -F \#{T::SSH_CONFIG}\n \#{tunnel_uri.user}@\#{tunnel_uri.host}\n -p \#{tunnel_uri.port}\n \#{port_mappings.join(\" \")}\n -i \#{T::SSH_PRIVKEY}\n -o StrictHostKeyChecking=no\n -o UserKnownHostsFile=pipe2me.known_hosts\n -o PasswordAuthentication=no\n -o ExitOnForwardFailure=yes \n -N\n SHELL\n \n cmd.gsub(/\\s+/, \" \")\nend\n" |
#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 |