Created
January 27, 2024 10:44
-
-
Save 0xB10C/b06d3f3b5dba081de9eaf6b4bc340c36 to your computer and use it in GitHub Desktop.
IRR timestamps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ftplib import FTP | |
sources = [ | |
{"server": "ftp.afrinic.net", "directory": "pub/dbase/", "names": ["afrinic.db.gz"], "supports_mlsd": False}, | |
{"server": "ftp.apnic.net", "directory": "pub/apnic/whois/", "names": ["apnic.db.route.gz", "apnic.db.route6.gz"], "supports_mlsd": True}, | |
{"server": "ftp.arin.net", "directory": "pub/rr/", "names": ["arin.db.gz"], "supports_mlsd": True}, | |
{"server": "ftp.ripe.net", "directory": "ripe/dbase/split/", "names": ["ripe.db.route.gz", "ripe.db.route6.gz"], "supports_mlsd": True}, | |
{"server": "ftp.lacnic.net", "directory": "lacnic/irr/", "names": ["lacnic.db.gz"], "supports_mlsd": False}, | |
] | |
for source in sources: | |
ftp = FTP(source["server"]) | |
ftp.login() | |
ftp.cwd(source["directory"]) | |
if source["supports_mlsd"]: | |
for name, facts in ftp.mlsd(): | |
if name in source["names"]: | |
print(facts["modify"], name, facts["size"], sep="\t\t\t"); | |
else: | |
def callback(line): | |
for name in source["names"]: | |
if name in line: | |
print(line.replace("ftp", " ").replace(" ", "").split(" ")) | |
ftp.retrlines('LIST', callback) | |
ftp.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment