summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordelano <delano@solutious.com>2009-08-10 18:41:09 -0400
committerdelano <delano@solutious.com>2009-08-10 18:50:24 -0400
commit2251c54b844bb446ba597e31f185eef8df00903d (patch)
tree6ec2f62c9312f1e87034c311b4ac7965fe71a31e
parent5a3f06e7fe158f20b8edee22e7cd40f51e206266 (diff)
downloadnet-ssh-2251c54b844bb446ba597e31f185eef8df00903d.tar.gz
Closes GH-6 Added support for specifying a list of hosts in .ssh/config, with tests
-rw-r--r--CHANGELOG.rdoc9
-rw-r--r--Manifest3
-rw-r--r--lib/net/ssh/config.rb17
-rw-r--r--net-ssh.gemspec1
-rw-r--r--test/configs/multihost4
-rw-r--r--test/test_config.rb17
6 files changed, 42 insertions, 9 deletions
diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc
index 2f0c422..6d80c37 100644
--- a/CHANGELOG.rdoc
+++ b/CHANGELOG.rdoc
@@ -1,11 +1,18 @@
-=== 2.0.12 / ?? Aug 2009
+=== 2.0.13 / ?? Aug 2009
+
+* Added support for specifying a list of hosts in .ssh/config, with tests (GH-6) [Delano Mandelbaum]
+
+* Added tests for arcfour128/256/512 lengths, encryption, and decryption [Delano Mandelbaum]
* Skip packet stream tests for arcfour128/256/512 [Delano Mandelbaum]
* Fix for OpenSSL cipher key length because it always returns 16, even when 32 byte keys are required, e.g. for arcfour256 and arcfour512 ciphers [Karl Varga]
+
+=== 2.0.12 / 08 Jun 2009
+
* Applied patch for arcfour128 and arcfour256 support [Denis Bernard]
* Use unbuffered reads when negotiating the protocol version [Steven Hazel]
diff --git a/Manifest b/Manifest
index 211d09f..8c29b09 100644
--- a/Manifest
+++ b/Manifest
@@ -80,6 +80,7 @@ test/authentication/test_session.rb
test/common.rb
test/configs/eqsign
test/configs/exact_match
+test/configs/multihost
test/configs/wild_cards
test/connection/test_channel.rb
test/connection/test_session.rb
@@ -102,4 +103,4 @@ test/transport/test_identity_cipher.rb
test/transport/test_packet_stream.rb
test/transport/test_server_version.rb
test/transport/test_session.rb
-test/transport/test_state.rb \ No newline at end of file
+test/transport/test_state.rb
diff --git a/lib/net/ssh/config.rb b/lib/net/ssh/config.rb
index 855e101..1638d12 100644
--- a/lib/net/ssh/config.rb
+++ b/lib/net/ssh/config.rb
@@ -57,11 +57,12 @@ module Net; module SSH
def load(file, host, settings={})
file = File.expand_path(file)
return settings unless File.readable?(file)
-
- in_match = false
+
+ matched_host = nil
+ multi_host = []
IO.foreach(file) do |line|
next if line =~ /^\s*(?:#.*)?$/
-
+
if line =~ /^\s*(\S+)\s*=(.*)$/
key, value = $1, $2
else
@@ -82,8 +83,12 @@ module Net; module SSH
end
if key == 'host'
- in_match = (host =~ pattern2regex(value))
- elsif in_match
+ # Support "Host host1,host2,hostN".
+ # See http://github.com/net-ssh/net-ssh/issues#issue/6
+ multi_host = value.split(/,\s+/)
+ matched_host = multi_host.select { |h| host =~ pattern2regex(h) }.first
+ p matched_host
+ elsif !matched_host.nil?
if key == 'identityfile'
settings[key] ||= []
settings[key] << value
@@ -92,7 +97,7 @@ module Net; module SSH
end
end
end
-
+
return settings
end
diff --git a/net-ssh.gemspec b/net-ssh.gemspec
index ec8b028..864418c 100644
--- a/net-ssh.gemspec
+++ b/net-ssh.gemspec
@@ -100,6 +100,7 @@
test/common.rb
test/configs/eqsign
test/configs/exact_match
+ test/configs/multihost
test/configs/wild_cards
test/connection/test_channel.rb
test/connection/test_session.rb
diff --git a/test/configs/multihost b/test/configs/multihost
new file mode 100644
index 0000000..732975c
--- /dev/null
+++ b/test/configs/multihost
@@ -0,0 +1,4 @@
+Host other.host, test.host
+ Compression yes
+ Port 1980
+ RekeyLimit 2G
diff --git a/test/test_config.rb b/test/test_config.rb
index fb1a848..82ad815 100644
--- a/test/test_config.rb
+++ b/test/test_config.rb
@@ -37,7 +37,22 @@ class TestConfig < Test::Unit::TestCase
assert_equal %w(~/.ssh/id_dsa), config[:keys]
assert !config.key?(:rekey_limit)
end
-
+
+ def test_load_with_multiple_hosts
+ config = Net::SSH::Config.load(config(:multihost), "test.host")
+ assert config['compression']
+ assert_equal '2G', config['rekeylimit']
+ assert_equal 1980, config['port']
+ end
+
+ def test_load_with_multiple_hosts_and_config_should_match_for_both
+ aconfig = Net::SSH::Config.load(config(:multihost), "test.host")
+ bconfig = Net::SSH::Config.load(config(:multihost), "other.host")
+ assert_equal aconfig['port'], bconfig['port']
+ assert_equal aconfig['compression'], bconfig['compression']
+ assert_equal aconfig['rekeylimit'], bconfig['rekeylimit']
+ end
+
def test_load_should_parse_equal_sign_delimiters
config = Net::SSH::Config.load(config(:eqsign), "test.test")
assert config['compression']