Add whois short infor per AS

This commit is contained in:
Be
2024-03-01 09:32:47 +01:00
parent 5b74c36ce4
commit fa40cde691
2 changed files with 9 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
import requests import requests
import argparse import argparse
from cymruwhois import Client
def get_as_prefixes(asn): def get_as_prefixes(asn):
url = f"https://stat.ripe.net/data/announced-prefixes/data.json?resource={asn}" url = f"https://stat.ripe.net/data/announced-prefixes/data.json?resource={asn}"
@@ -13,6 +14,11 @@ def get_as_prefixes(asn):
else: else:
return [] return []
def get_as_whois(asn):
c = Client()
r = c.lookup(asn)
return r.owner
def main(): def main():
parser = argparse.ArgumentParser(description='./as_network_list.py -q AS61280') parser = argparse.ArgumentParser(description='./as_network_list.py -q AS61280')
parser.add_argument('asn', help='The AS number to get prefixes for.') parser.add_argument('asn', help='The AS number to get prefixes for.')
@@ -21,9 +27,11 @@ def main():
asn = args.asn asn = args.asn
prefixes = get_as_prefixes(asn) prefixes = get_as_prefixes(asn)
whois_info = get_as_whois(asn)
if not args.quiet: if not args.quiet:
print(f"Prefixes announced by {asn}:") print(f"Prefixes announced by {asn}:")
print(f"Whois info for {asn}: {whois_info}")
for prefix in prefixes: for prefix in prefixes:
print(prefix) print(prefix)

View File

@@ -1,5 +1,6 @@
certifi==2024.2.2 certifi==2024.2.2
charset-normalizer==3.3.2 charset-normalizer==3.3.2
cymruwhois==1.6
idna==3.6 idna==3.6
requests==2.31.0 requests==2.31.0
urllib3==2.2.1 urllib3==2.2.1