fix: Make sure to pass an IP to ipasn.query

pull/12/head
Raphaël Vinot 2019-03-15 18:00:28 +01:00
parent dd4d5b5bb7
commit 35adef8336
1 changed files with 7 additions and 1 deletions

View File

@ -166,12 +166,18 @@ def ipasn():
d = request.form d = request.form
elif request.method == 'GET': elif request.method == 'GET':
d = request.args d = request.args
if not d or 'ip' not in d: if not d or 'ip' not in d:
return render_template('ipasn.html') return render_template('ipasn.html')
else:
if isinstance(d['ip'], list):
ip = d['ip'][0]
else:
ip = d['ip']
ipasn = get_ipasn() ipasn = get_ipasn()
q = Querying() q = Querying()
response = ipasn.query(first=(date.today() - timedelta(days=60)).isoformat(), response = ipasn.query(first=(date.today() - timedelta(days=60)).isoformat(),
aggregate=True, **d) aggregate=True, ip=ip)
for r in response['response']: for r in response['response']:
r['asn_description'] = [] r['asn_description'] = []
asn_descriptions = q.get_asn_descriptions(asn=r['asn'], all_descriptions=True) asn_descriptions = q.get_asn_descriptions(asn=r['asn'], all_descriptions=True)