diff options
author | Miklós Fazekas <mfazekas@szemafor.com> | 2021-08-05 17:20:55 +0200 |
---|---|---|
committer | Miklós Fazekas <mfazekas@szemafor.com> | 2021-08-05 17:25:37 +0200 |
commit | 51dc78feac5dc9df615ca0ef82e707951887411c (patch) | |
tree | 1fcbc3d677f3f03155254d8499ffd638a8065d9d /lib | |
parent | 932f0268a2903e35f7bf9f8d1bb96dd38dd77e1f (diff) | |
download | net-ssh-51dc78feac5dc9df615ca0ef82e707951887411c.tar.gz |
Use ports specific format
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net/ssh/known_hosts.rb | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/net/ssh/known_hosts.rb b/lib/net/ssh/known_hosts.rb index 1313552..fddbffd 100644 --- a/lib/net/ssh/known_hosts.rb +++ b/lib/net/ssh/known_hosts.rb @@ -189,26 +189,28 @@ module Net hosts, type, key_content, comment = line.split(' ') end - if marker == "@cert-authority" - blob = key_content.unpack("m*").first - keys << HostKeyEntries::CertAuthority.new(Net::SSH::Buffer.new(blob).read_key, comment: comment) - else - # Skip empty line or one that is commented - next if hosts.nil? || hosts.start_with?('#') + # Skip empty line or one that is commented + next if hosts.nil? || hosts.start_with?('#') - hostlist = hosts.split(',') + hostlist = hosts.split(',') - next unless SUPPORTED_TYPE.include?(type) + next unless SUPPORTED_TYPE.include?(type) - found = hostlist.any? { |pattern| match(host_name, pattern) } || known_host_hash?(hostlist, entries) - next unless found + found = hostlist.any? { |pattern| match(host_name, pattern) } || known_host_hash?(hostlist, entries) + next unless found - found = hostlist.include?(host_ip) if options[:check_host_ip] && entries.size > 1 && hostlist.size > 1 - next unless found + found = hostlist.include?(host_ip) if options[:check_host_ip] && entries.size > 1 && hostlist.size > 1 + next unless found - blob = key_content.unpack("m*").first - keys << HostKeyEntries::PubKey.new(Net::SSH::Buffer.new(blob).read_key, comment: comment) - end + blob = key_content.unpack("m*").first + raw_key = Net::SSH::Buffer.new(blob).read_key + + keys << + if marker == "@cert-authority" + HostKeyEntries::CertAuthority.new(raw_key, comment: comment) + else + HostKeyEntries::PubKey.new(raw_key, comment: comment) + end end end |