summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Moriz <roland@moriz.de>2015-05-25 02:26:03 +0200
committerRoland Moriz <roland@moriz.de>2015-05-25 02:26:03 +0200
commit6923a7e60815ac70834099c8a15c42bfdf033643 (patch)
tree7e029aafe39be62712616bfc3025b21898452c03
parentfd2a7bc02962b8151ece8fc7257d36a292feb973 (diff)
downloadohai-6923a7e60815ac70834099c8a15c42bfdf033643.tar.gz
fixes #545
-rw-r--r--lib/ohai/util/ip_helper.rb5
-rw-r--r--spec/unit/util/ip_helper_spec.rb8
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'