summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklós Fazekas <mfazekas@szemafor.com>2016-09-11 07:00:00 +0200
committerGitHub <noreply@github.com>2016-09-11 07:00:00 +0200
commitf4c787ef3770f5218fefcb3c21091de13205ede8 (patch)
treec7858fe99f28b974182edc1d3ed6f3558767bb8c
parent66ab0bbc30c784734cfbbad737e68fc675728777 (diff)
parent21d971a74d674aaa6cfd64454061d957dfccecc7 (diff)
downloadnet-ssh-multi-master.tar.gz
Merge pull request #9 from mdelaney/fix_ipv6HEADmaster
Fixed host parsing to work with ipv6 addresses
-rw-r--r--lib/net/ssh/multi/server.rb2
-rw-r--r--test/server_test.rb4
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/net/ssh/multi/server.rb b/lib/net/ssh/multi/server.rb
index 0094982..bcf3678 100644
--- a/lib/net/ssh/multi/server.rb
+++ b/lib/net/ssh/multi/server.rb
@@ -45,7 +45,7 @@ module Net; module SSH; module Multi
@master = master
@options = options.dup
- @user, @host, port = host.match(/^(?:([^;,:=]+)@|)(.*?)(?::(\d+)|)$/)[1,3]
+ @user, @host, port = host.match(/^(?:([^;,:=]+)@|)\[?(.*?)\]?(?::(\d+)|)$/)[1,3]
user_opt, port_opt = @options.delete(:user), @options.delete(:port)
diff --git a/test/server_test.rb b/test/server_test.rb
index 544ea16..ecfa12e 100644
--- a/test/server_test.rb
+++ b/test/server_test.rb
@@ -14,6 +14,10 @@ class ServerTest < Minitest::Test
assert_equal "hello", server('host', :properties => { :foo => "hello" })[:foo]
end
+ def test_ipv6_works_with_given_port_using_bracket_notation
+ assert_equal 9022, server('[2001:DB8::1234]:9022').port
+ end
+
def test_port_should_return_22_by_default
assert_equal 22, server('host').port
end