Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to lookup abuse-c-objects #10

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions uwhoisd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ def whois(self, query: str) -> str:
zone = 'ipv6'
elif query.lower().startswith('as') and query.lower()[2:].isdigit():
zone = 'asn'
elif not utils.is_well_formed_fqdn(query):
# if query is no ip, asn or fqdn
# it's probably a NIC handle (Network Information Centre handle)
# probably an abuse-c object
zone = 'NIC-handle'
else:
# Domain, strip hostname part if needed
query, zone = self._strip_hostname(query)
Expand Down
5 changes: 1 addition & 4 deletions uwhoisd/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ def on_connect(self):
if self._timed_out:
return
whois_query = self.data.decode().strip().lower()
if not utils.is_well_formed_fqdn(whois_query) and ':' not in whois_query and not whois_query.lower().startswith('as'):
whois_entry = "; Bad request: '{0}'\r\n".format(whois_query)
else:
whois_entry = self.query_fct(whois_query)
whois_entry = self.query_fct(whois_query)
yield self.stream.write(whois_entry.encode())
except tornado.iostream.StreamClosedError:
logger.warning('Connection closed by %s.', self.client)
Expand Down
Loading