Skip to content

Commit

Permalink
better range check for unallocated ASNs for #9
Browse files Browse the repository at this point in the history
  • Loading branch information
grizz committed Apr 15, 2020
1 parent ed1ffcb commit c7f77d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Unreleased:
added: []
changed: []
deprecated: []
fixed: []
fixed:
- better range check for unallocated ASNs
removed: []
security: []
9 changes: 8 additions & 1 deletion rdap/objects.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from builtins import object
from rdap.exceptions import RdapNotFoundError


class RdapObject(object):
Expand Down Expand Up @@ -139,6 +139,13 @@ class RdapAsn(RdapObject):
"""

def __init__(self, data, rdapc=None):
# check for ASN range, meaning it's delegated and unallocated
if data:
start = data.get("startAutnum", None)
end = data.get("endAutnum", None)
if start and end and start != end:
raise RdapNotFoundError("AS{} returned a block, so it is not allocated".format(start))

super().__init__(data, rdapc)


Expand Down

0 comments on commit c7f77d1

Please sign in to comment.