diff options
author | Rob Austein <sra@hactrn.net> | 2012-11-28 01:17:25 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2012-11-28 01:17:25 +0000 |
commit | 770ba2f6b7958dab863fc3d311498ef4de1fb206 (patch) | |
tree | 59f500bf6575b0e102fd228f26c99d6a796e065d /rpkid | |
parent | e2fb2b8b2e7545900a4a1fcc43eca1d16c7cb0c8 (diff) |
Teach resource_range_ip.parse_str() to autodetect IP version. Closes #338.
svn path=/trunk/; revision=4921
Diffstat (limited to 'rpkid')
-rw-r--r-- | rpkid/rpki/resource_set.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/rpkid/rpki/resource_set.py b/rpkid/rpki/resource_set.py index 27f6df6e..519af61e 100644 --- a/rpkid/rpki/resource_set.py +++ b/rpkid/rpki/resource_set.py @@ -188,10 +188,15 @@ class resource_range_ip(resource_range): """ r = re_address_range.match(x) if r: - return cls(rpki.POW.IPAddress(r.group(1)), rpki.POW.IPAddress(r.group(2))) + return cls.from_strings(r.group(1), r.group(2)) r = re_prefix.match(x) if r: - return cls.make_prefix(rpki.POW.IPAddress(r.group(1)), int(r.group(2))) + a = rpki.POW.IPAddress(r.group(1)) + if cls is resource_range_ip and a.version == 4: + cls = resource_range_ipv4 + if cls is resource_range_ip and a.version == 6: + cls = resource_range_ipv6 + return cls.make_prefix(a, int(r.group(2))) raise rpki.exceptions.BadIPResource, 'Bad IP resource "%s"' % (x) @classmethod |