Skip to content

Commit

Permalink
Merge pull request #99 from pogzyb/fix-query-server-check
Browse files Browse the repository at this point in the history
Fix query server check
  • Loading branch information
pogzyb authored Nov 4, 2024
2 parents 7cb3527 + 003e95a commit 2209bfd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion asyncwhois/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def _do_query(
whois_server
and whois_server != server
and not whois_server.startswith("http")
and not whois_server.startswith("www.")
):
# recursive call to find more authoritative server
chain = self._do_query(
Expand All @@ -173,10 +174,12 @@ async def _aio_do_query(
# parse response for the referred WHOIS server name
whois_server = self._find_match(regex, query_output)
whois_server = whois_server.lower()
# check for another legitimate server name
if (
whois_server
and whois_server != server
and not whois_server.startswith("http")
and not whois_server.startswith("www.")
):
# recursive call to find the authoritative server
chain = await self._aio_do_query(
Expand All @@ -197,7 +200,8 @@ def __init__(
self.server = server

@staticmethod
def _get_server_name(tld: str) -> Union[str, None]:
def _get_server_name(domain_name: str) -> Union[str, None]:
tld = domain_name.split(".")[-1]
tld_converted = tld.upper().replace("-", "_")
for servers in [CountryCodeTLD, GenericTLD, SponsoredTLD]:
if hasattr(servers, tld_converted):
Expand Down
4 changes: 2 additions & 2 deletions asyncwhois/tldparsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ class RegexFR(TLDParser):

class RegexBR(TLDParser):
tld_specific_expressions: ExpressionDict = {
TLDBaseKeys.CREATED: r"created: ",
TLDBaseKeys.UPDATED: r"changed: ",
TLDBaseKeys.CREATED: r"created: *([^#\n]*)",
TLDBaseKeys.UPDATED: r"changed: *(.+)",
TLDBaseKeys.STATUS: r"status: *(.+)",
TLDBaseKeys.REGISTRANT_NAME: r"responsible: *(.+)",
TLDBaseKeys.REGISTRANT_COUNTRY: r"country: *(.+)",
Expand Down

0 comments on commit 2209bfd

Please sign in to comment.