chg: Update IPASN View.

pull/12/head
Raphaël Vinot 2019-03-15 17:37:44 +01:00
parent 4f2898af7c
commit 40195dd999
3 changed files with 24 additions and 7 deletions

2
Pipfile.lock generated
View File

@ -323,7 +323,7 @@
"pyipasnhistory": {
"editable": true,
"git": "https://github.com/D4-project/IPASN-History.git/",
"ref": "e846cd36fe1ed6b22f60890bba89f84e61b62e59",
"ref": "263fea1879267719093238d9bbd95b186b96948a",
"subdirectory": "client"
},
"pymispgalaxies": {

View File

@ -169,7 +169,16 @@ def ipasn():
if not d or 'ip' not in d:
return render_template('ipasn.html')
ipasn = get_ipasn()
response = ipasn.query(first=(date.today() - timedelta(days=60)).isoformat(), **d)
q = Querying()
response = ipasn.query(first=(date.today() - timedelta(days=60)).isoformat(),
aggregate=True, **d)
for r in response['response']:
r['asn_description'] = []
asn_descriptions = q.get_asn_descriptions(asn=r['asn'], all_descriptions=True)
for timestamp in sorted(asn_descriptions.keys()):
if r['first_seen'] <= timestamp <= r['last_seen']:
r['asn_description'].append(asn_descriptions[timestamp])
return render_template('ipasn.html', ipasn_details=response['response'],
**response['meta'])

View File

@ -25,15 +25,23 @@
{% if ipasn_details %}
<table class="table">
<tr>
<th>Date</th>
<th>First Seen</th>
<th>Last Seen</th>
<th>ASN</th>
<th>ASN Description</th>
<th>Prefix</th>
</tr>
{% for date, details in ipasn_details.items() %}
{% for entry in ipasn_details %}
<tr>
<td>{{ date }}</td>
<td>{{ details['asn'] }}</td>
<td>{{ details['prefix'] }}</td>
<td>{{ entry['first_seen'] }}</td>
<td>{{ entry['last_seen'] }}</td>
<td>{{ entry['asn'] }}</td>
<td>
{% for asn_description in entry['asn_descriptions'] %}
{{ asn_description }} </br>
{% endfor %}
</td>
<td>{{ entry['prefix'] }}</td>
</tr>
{% endfor %}
</table>