Skip to content

Instantly share code, notes, and snippets.

@0xB10C
Created January 27, 2024 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xB10C/b06d3f3b5dba081de9eaf6b4bc340c36 to your computer and use it in GitHub Desktop.
Save 0xB10C/b06d3f3b5dba081de9eaf6b4bc340c36 to your computer and use it in GitHub Desktop.
IRR timestamps
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