diff options
author | Delano Mandelbaum <delano@delanotes.com> | 2014-02-01 08:17:05 -0800 |
---|---|---|
committer | Delano Mandelbaum <delano@delanotes.com> | 2014-02-01 08:17:05 -0800 |
commit | 20eb632d500323d182041a0d5a518e1349f0866d (patch) | |
tree | 59b3335334ed4b8aec0676546edf87843bea1bff /lib/net/ssh/proxy | |
parent | cbeb31cd0f14b1d4816b797d90bd2b701e6c7ac2 (diff) | |
parent | b84becc741e233fb4182e02b2ef3f194bc29174c (diff) | |
download | net-ssh-20eb632d500323d182041a0d5a518e1349f0866d.tar.gz |
Merge pull request #139 from yugui/feature/follow-proxy-command-spec-r
Support %r in ProxyCommand configuration in ssh_config files as defined in OpenSSH.
Diffstat (limited to 'lib/net/ssh/proxy')
-rw-r--r-- | lib/net/ssh/proxy/command.rb | 9 | ||||
-rw-r--r-- | lib/net/ssh/proxy/http.rb | 2 | ||||
-rw-r--r-- | lib/net/ssh/proxy/socks4.rb | 2 | ||||
-rw-r--r-- | lib/net/ssh/proxy/socks5.rb | 2 |
4 files changed, 11 insertions, 4 deletions
diff --git a/lib/net/ssh/proxy/command.rb b/lib/net/ssh/proxy/command.rb index 2e6098e..e7b2739 100644 --- a/lib/net/ssh/proxy/command.rb +++ b/lib/net/ssh/proxy/command.rb @@ -33,13 +33,20 @@ module Net; module SSH; module Proxy # Return a new socket connected to the given host and port via the # proxy that was requested when the socket factory was instantiated. - def open(host, port) + def open(host, port, connection_options = nil) command_line = @command_line_template.gsub(/%(.)/) { case $1 when 'h' host when 'p' port.to_s + when 'r' + remote_user = connection_options && connection_options[:remote_user] + if remote_user + remote_user + else + raise ArgumentError, "remote user name not available" + end when '%' '%' else diff --git a/lib/net/ssh/proxy/http.rb b/lib/net/ssh/proxy/http.rb index 0d183be..e08d5d2 100644 --- a/lib/net/ssh/proxy/http.rb +++ b/lib/net/ssh/proxy/http.rb @@ -48,7 +48,7 @@ module Net; module SSH; module Proxy # Return a new socket connected to the given host and port via the # proxy that was requested when the socket factory was instantiated. - def open(host, port) + def open(host, port, connection_options = nil) socket = TCPSocket.new(proxy_host, proxy_port) socket.write "CONNECT #{host}:#{port} HTTP/1.0\r\n" diff --git a/lib/net/ssh/proxy/socks4.rb b/lib/net/ssh/proxy/socks4.rb index fdb1e32..8330d96 100644 --- a/lib/net/ssh/proxy/socks4.rb +++ b/lib/net/ssh/proxy/socks4.rb @@ -47,7 +47,7 @@ module Net # Return a new socket connected to the given host and port via the # proxy that was requested when the socket factory was instantiated. - def open(host, port) + def open(host, port, connection_options) socket = TCPSocket.new(proxy_host, proxy_port) ip_addr = IPAddr.new(Resolv.getaddress(host)) diff --git a/lib/net/ssh/proxy/socks5.rb b/lib/net/ssh/proxy/socks5.rb index 06b2d49..96f8637 100644 --- a/lib/net/ssh/proxy/socks5.rb +++ b/lib/net/ssh/proxy/socks5.rb @@ -62,7 +62,7 @@ module Net # Return a new socket connected to the given host and port via the # proxy that was requested when the socket factory was instantiated. - def open(host, port) + def open(host, port, connection_options = nil) socket = TCPSocket.new(proxy_host, proxy_port) methods = [METHOD_NO_AUTH] |