diff options
| author | Mark Imbriaco <mark@imbriaco.com> | 2011-08-14 13:28:16 -0400 |
|---|---|---|
| committer | Mark Imbriaco <mark@imbriaco.com> | 2011-08-14 13:28:16 -0400 |
| commit | cbecc7c041f0c3778cb032fd71132ab94a76e0a9 (patch) | |
| tree | c293d9dd754d3f6c1dc49549d5d2a51f0ae95b02 | |
| parent | aa453511f546cd524d2495f55429b2d168efd7d1 (diff) | |
| download | net-ssh-cbecc7c041f0c3778cb032fd71132ab94a76e0a9.tar.gz | |
Only change the port type to :string when we are forwarding a UNIX socket.
| -rw-r--r-- | lib/net/ssh/service/forward.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/net/ssh/service/forward.rb b/lib/net/ssh/service/forward.rb index 7568273..7d88487 100644 --- a/lib/net/ssh/service/forward.rb +++ b/lib/net/ssh/service/forward.rb @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- require 'net/ssh/loggable' module Net; module SSH; module Service @@ -53,13 +54,17 @@ module Net; module SSH; module Service raise ArgumentError, "expected 3 or 4 parameters, got #{args.length}" end + local_port_type = :long + socket = begin if args.first.class == UNIXServer + local_port_type = :string args.shift else bind_address = "127.0.0.1" bind_address = args.shift if args.first.is_a?(String) && args.first =~ /\D/ local_port = args.shift.to_i + local_port_type = :long TCPServer.new(bind_address, local_port) end end @@ -73,7 +78,7 @@ module Net; module SSH; module Service client = server.accept debug { "received connection on #{socket}" } - channel = session.open_channel("direct-tcpip", :string, remote_host, :long, remote_port, :string, bind_address, :string, local_port) do |achannel| + channel = session.open_channel("direct-tcpip", :string, remote_host, :long, remote_port, :string, bind_address, local_port_type, local_port) do |achannel| achannel.info { "direct channel established" } end |
