Skip to content

Commit

Permalink
follow related and registration links in RDAP data to query child RDA…
Browse files Browse the repository at this point in the history
…P servers which will have more information, resolves #26
  • Loading branch information
meeb committed Apr 20, 2024
1 parent da30c17 commit 9961fca
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions whoisit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,24 @@ def domain(domain_name, raw=False, allow_insecure_ssl=False, session=None):
query_type='domain', query_value=domain_name)
q = Query(session, method, url)
response = q.request()
return response if raw else parse(_bootstrap, 'domain', domain_name, response)

if raw:
return response
# Attempt to follow the 'related' or 'registration' links if the TLD has
# an upstream RDAP endpoint that may have more information
relresponse = None
for link in response.get('links', []):
rel = link.get('rel', '')
if rel in ('related', 'registration'):
relhref = link.get('href', '')
if relhref:
print(f'MAKING SUBREQUEST TO {relhref}')
relq = Query(session, method, relhref)
relresponse = relq.request()
break
if relresponse:
return parse(_bootstrap, 'domain', domain_name, relresponse)
else:
return parse(_bootstrap, 'domain', domain_name, response)

def ip(ip_address_or_network, rir=None, raw=False, allow_insecure_ssl=False, session=None):
session = get_session(session, allow_insecure_ssl=allow_insecure_ssl)
Expand Down

0 comments on commit 9961fca

Please sign in to comment.