diff options
author | Thom May <thom@may.lt> | 2015-07-09 10:29:30 +0100 |
---|---|---|
committer | Thom May <thom@may.lt> | 2015-07-09 10:29:30 +0100 |
commit | e6938024f017a83a76fb8421ab4edccc1cede028 (patch) | |
tree | de94497f4ce7e2f10bda2dd67808a57591b1b41e | |
parent | 002daec07ceb3bd44fb64daddd9b5d2aa3c0fc0a (diff) | |
parent | 6923a7e60815ac70834099c8a15c42bfdf033643 (diff) | |
download | ohai-e6938024f017a83a76fb8421ab4edccc1cede028.tar.gz |
Merge pull request #546 from rmoriz/RFC4192_link_local
fixes #545 (IPv6 bug in detecting link-local addresses)
-rw-r--r-- | lib/ohai/util/ip_helper.rb | 5 | ||||
-rw-r--r-- | spec/unit/util/ip_helper_spec.rb | 8 |
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/ohai/util/ip_helper.rb b/lib/ohai/util/ip_helper.rb index 3195dd7b..5b848e94 100644 --- a/lib/ohai/util/ip_helper.rb +++ b/lib/ohai/util/ip_helper.rb @@ -19,7 +19,8 @@ require 'ipaddress' module Ohai module Util module IpHelper - # Corresponding to RFC 4193 + # Corresponding to RFC 4192 + RFC 4193 + IPV6_LINK_LOCAL_UNICAST_BLOCK = IPAddress('fe80::/10') IPV6_PRIVATE_ADDRESS_BLOCK = IPAddress('fc00::/7') def private_address?(addr) @@ -28,7 +29,7 @@ module Ohai if ip.respond_to? :private? ip.private? else - IPV6_PRIVATE_ADDRESS_BLOCK.include?(ip) + IPV6_LINK_LOCAL_UNICAST_BLOCK.include?(ip) || IPV6_PRIVATE_ADDRESS_BLOCK.include?(ip) end end alias :unique_local_address? :private_address? diff --git a/spec/unit/util/ip_helper_spec.rb b/spec/unit/util/ip_helper_spec.rb index 946ca47c..2eaa85f1 100644 --- a/spec/unit/util/ip_helper_spec.rb +++ b/spec/unit/util/ip_helper_spec.rb @@ -53,11 +53,11 @@ describe "Ohai::Util::IpHelper" do end end - context 'that is a non RFC 4193 unique local address' do + context 'that is a RFC 4291 Link-Local unicast address' do let(:address) { 'FE80::0202:B3FF:FE1E:8329' } - it 'does not identify the address as a unique local address' do - expect(ip_helper.private_address?(address)).to be_falsey + it 'does identify the address as a link-local address' do + expect(ip_helper.private_address?(address)).to be_truthy end end end @@ -65,7 +65,7 @@ describe "Ohai::Util::IpHelper" do describe 'private_address?' do include_examples 'ip address types' - end + end describe 'unique_local_address?' do include_examples 'ip address types' |