diff options
author | Markus Roberts <Markus@reality.com> | 2009-12-14 00:24:42 -0800 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-12-18 14:10:38 +1100 |
commit | 18c5165bea26151d446ff9ae63aeee108cb210ef (patch) | |
tree | 1ceb42ce35cdcc33a9c387c5c0975e0cdbfde9db /lib | |
parent | 857047d956aa0e78e105df2330346dbd6fcd8c35 (diff) | |
download | puppet-18c5165bea26151d446ff9ae63aeee108cb210ef.tar.gz puppet-18c5165bea26151d446ff9ae63aeee108cb210ef.tar.xz puppet-18c5165bea26151d446ff9ae63aeee108cb210ef.zip |
Adds partial IPv6 support to authstore
This removes some of the IPv4 centricism from authstore's handling
of IP addresses. It isn't full IPv6 support (and doesn't even fully
handle all the cases within its limited scope, as ruby's IPAddr
library does not work with hybrid addresses), but it should simplify
adding IPv6 support when the time comes.
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/puppet/network/authstore.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/puppet/network/authstore.rb b/lib/puppet/network/authstore.rb index b4bf320b3..a171537fc 100755 --- a/lib/puppet/network/authstore.rb +++ b/lib/puppet/network/authstore.rb @@ -218,14 +218,20 @@ module Puppet # Parse our input pattern and figure out what kind of allowal # statement it is. The output of this is used for later matching. - Octet = '(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])' - IPv4 = "#{Octet}\.#{Octet}\.#{Octet}\.#{Octet}" + Octet = '(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])' + IPv4 = "#{Octet}\.#{Octet}\.#{Octet}\.#{Octet}" + IPv6_full = "_:_:_:_:_:_:_:_|_:_:_:_:_:_::_?|_:_:_:_:_::((_:)?_)?|_:_:_:_::((_:){0,2}_)?|_:_:_::((_:){0,3}_)?|_:_::((_:){0,4}_)?|_::((_:){0,5}_)?|::((_:){0,6}_)?" + IPv6_partial = "_:_:_:_:_:_:|_:_:_:_::(_:)?|_:_::(_:){0,2}|_::(_:){0,3}" + # It should be: + # IP = "#{IPv4}|#{IPv6_full}|(#{IPv6_partial}#{IPv4})".gsub(/_/,'([0-9a-fA-F]{1,4})').gsub(/\(/,'(?:') + # but ruby's ipaddr lib doesn't support the hybrid format + IP = "#{IPv4}|#{IPv6_full}".gsub(/_/,'([0-9a-fA-F]{1,4})').gsub(/\(/,'(?:') def parse(value) @name,@exact,@length,@pattern = *case value - when /^#{IPv4}\/(\d+)$/ # 12.34.56.78/24 + when /^(?:#{IP})\/(\d+)$/ # 12.34.56.78/24, a001:b002::efff/120, c444:1000:2000::9:192.168.0.1/112 [:ip,:inexact,$1.to_i,IPAddr.new(value)] - when /^#{IPv4}$/ # 10.20.30.40 - [:ip,:exact,32,IPAddr.new(value)] + when /^(#{IP})$/ # 10.20.30.40, + [:ip,:exact,nil,IPAddr.new(value)] when /^(#{Octet}\.){1,3}\*$/ # an ip address with a '*' at the end segments = value.split(".")[0..-2] bits = 8*segments.length |