Catch possible exceptions thrown by the ASN DNS resolver

This commit is contained in:
Baptiste Jonglez 2014-01-28 15:45:03 +01:00
parent 2418d13d07
commit e557dd651b
1 changed files with 4 additions and 1 deletions

5
lg.py
View File

@ -48,7 +48,10 @@ app.logger.addHandler(file_handler)
def get_asn_from_as(n):
asn_zone = app.config.get("ASN_ZONE", "asn.cymru.com")
data = resolve("AS%s.%s" % (n, asn_zone) ,"TXT").replace("'","").replace('"','')
try:
data = resolve("AS%s.%s" % (n, asn_zone) ,"TXT").replace("'","").replace('"','')
except:
return " "*5
return [ field.strip() for field in data.split("|") ]