From e557dd651b9c4c9aaac27588e7a5a789e0713e73 Mon Sep 17 00:00:00 2001 From: Baptiste Jonglez Date: Tue, 28 Jan 2014 15:45:03 +0100 Subject: [PATCH] Catch possible exceptions thrown by the ASN DNS resolver --- lg.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lg.py b/lg.py index c39aa22..5b2b93c 100644 --- a/lg.py +++ b/lg.py @@ -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("|") ]