Adding timeout to fetch the IANA RDAP JSON, just in case

Signed-off-by: Alarig Le Lay <alelay@scaleway.com>
This commit is contained in:
Alarig Le Lay 2024-07-19 12:04:13 +02:00
parent de5a36c380
commit cb96bb23be
No known key found for this signature in database
GPG key ID: 948D6BC249D8EBFF

View file

@ -22,7 +22,7 @@ def expiration(domain):
'/tmp/iana_rdap_cache', '/tmp/iana_rdap_cache',
cache_control=True cache_control=True
) )
req = session.get('https://data.iana.org/rdap/dns.json') req = session.get('https://data.iana.org/rdap/dns.json', timeout=120)
for k,v in req.json()['services']: for k,v in req.json()['services']:
for x in k: for x in k:
list2dict.append({'name':x, 'url':v[0]}) list2dict.append({'name':x, 'url':v[0]})
@ -76,7 +76,7 @@ def expiration(domain):
today = datetime.datetime.now() today = datetime.datetime.now()
delta = datetime.datetime.strptime(fecha, '%Y-%m-%d') - today delta = datetime.datetime.strptime(fecha, '%Y-%m-%d') - today
return(delta.days) return delta.days
# data acquisition # data acquisition