diff --git a/whoisit/__init__.py b/whoisit/__init__.py index 3d6f3d1..a8fdb07 100644 --- a/whoisit/__init__.py +++ b/whoisit/__init__.py @@ -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)