mirror of
https://github.com/C24Be/AS_Network_List.git
synced 2026-01-25 15:31:12 +03:00
whois
This commit is contained in:
@@ -8,7 +8,7 @@ import re
|
|||||||
|
|
||||||
whois_server = "whois.ripe.net"
|
whois_server = "whois.ripe.net"
|
||||||
|
|
||||||
def whois_query(whois_server, query):
|
def whois_query(whois_server, query, get_field="netname"):
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
s.connect((whois_server, 43))
|
s.connect((whois_server, 43))
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ def whois_query(whois_server, query):
|
|||||||
s.close()
|
s.close()
|
||||||
|
|
||||||
for line in response.split('\n'):
|
for line in response.split('\n'):
|
||||||
if line.startswith('inetnum'):
|
if line.startswith(get_field + ':'):
|
||||||
return line.strip()
|
return line.strip()
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@@ -55,7 +55,7 @@ def extract_netname(filename_or_url):
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
if re.match(r'^netname:', line):
|
if re.match(r'^netname:', line):
|
||||||
netname = line.split(':')[1].strip()
|
netname = line.split(':')[1].strip()
|
||||||
response = whois_query(whois_server, netname)
|
response = whois_query(whois_server, netname, "inetnum")
|
||||||
if response is not None:
|
if response is not None:
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
print(f"# Network name: {netname}")
|
print(f"# Network name: {netname}")
|
||||||
|
|||||||
Reference in New Issue
Block a user