Skip to content

Commit

Permalink
Fix ipv6 query and parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
pogzyb committed Feb 9, 2024
1 parent f6a7748 commit c2798d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions asyncwhois/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ def whois(
ip = convert_to_ip(ip)
query_chain: list[str] = self.query_obj.run(ip)
authoritative_answer = query_chain[-1]
parsed_dict: dict[IPBaseKeys, Any] = self.parse_obj.parse(
authoritative_answer, ip
)
parsed_dict: dict[IPBaseKeys, Any] = {}
if isinstance(ip, ipaddress.IPv4Address):
parsed_dict = self.parse_obj.parse(authoritative_answer, ip)
query_string = (

Check warning on line 155 in asyncwhois/client.py

View check run for this annotation

Codecov / codecov/patch

asyncwhois/client.py#L148-L155

Added lines #L148 - L155 were not covered by tests
authoritative_answer if self.authoritative_only else "\n".join(query_chain)
)
Expand Down
10 changes: 8 additions & 2 deletions asyncwhois/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ async def _aio_send_and_recv(
def run(self, search_term: str, server: str = None) -> list[str]:
data = search_term + "\r\n"
if not server:
server_regex = self.refer_regex
if ":" in data: # ipv6
server_regex = r"whois: *(.+)"

Check warning on line 114 in asyncwhois/query.py

View check run for this annotation

Codecov / codecov/patch

asyncwhois/query.py#L114

Added line #L114 was not covered by tests
else:
server_regex = self.refer_regex
server = self.iana_server
else:
server_regex = self.whois_server_regex

Check warning on line 119 in asyncwhois/query.py

View check run for this annotation

Codecov / codecov/patch

asyncwhois/query.py#L119

Added line #L119 was not covered by tests
Expand All @@ -119,7 +122,10 @@ def run(self, search_term: str, server: str = None) -> list[str]:
async def aio_run(self, search_term: str, server: str = None) -> list[str]:
data = search_term + "\r\n"
if not server:
server_regex = self.refer_regex
if ":" in data: # ipv6
server_regex = r"whois: *(.+)"

Check warning on line 126 in asyncwhois/query.py

View check run for this annotation

Codecov / codecov/patch

asyncwhois/query.py#L126

Added line #L126 was not covered by tests
else:
server_regex = self.refer_regex
server = self.iana_server
else:
server_regex = self.whois_server_regex

Check warning on line 131 in asyncwhois/query.py

View check run for this annotation

Codecov / codecov/patch

asyncwhois/query.py#L131

Added line #L131 was not covered by tests
Expand Down

0 comments on commit c2798d3

Please sign in to comment.