Skip to content

Commit 438b8a9

Browse files
committed
chg: Use best source from ipasnhistory if possible.
1 parent 536b82c commit 438b8a9

4 files changed

Lines changed: 64 additions & 65 deletions

File tree

bin/dbinsert.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _to_run_forever(self):
5757
if not data:
5858
self.logger.warning(f'No data for UUID {uuid}. This should not happen, but lets move on.')
5959
continue
60-
for_query.append({'ip': data['ip'], 'address_family': data['address_family'], 'source': 'caida',
60+
for_query.append({'ip': data['ip'], 'address_family': data['address_family'],
6161
'date': data['datetime'], 'precision_delta': {'days': 3}})
6262
try:
6363
responses = self.ipasn.mass_query(for_query)
@@ -89,11 +89,11 @@ def _to_run_forever(self):
8989
# routing info is missing, need to try again later.
9090
retry.append(uuid)
9191
continue
92-
if 'asn' in entry and entry['asn'] is None:
93-
self.logger.warning(f"Unable to find the AS number associated to {data['ip']} - {data['datetime']} (got None). This should not happen...")
92+
if 'asn' in entry and entry['asn'] in [None, '0']:
93+
self.logger.warning(f"Unable to find the AS number associated to {data['ip']} - {data['datetime']} (got {entry['asn']}).")
9494
continue
95-
if 'prefix' in entry and entry['prefix'] is None:
96-
self.logger.warning(f"Unable to find the prefix associated to {data['ip']} - {data['datetime']} (got None). This should not happen...")
95+
if 'prefix' in entry and entry['prefix'] in [None, '0.0.0.0/0', '::/0']:
96+
self.logger.warning(f"Unable to find the prefix associated to {data['ip']} - {data['datetime']} (got {entry['prefix']}).")
9797
continue
9898

9999
# Format: <YYYY-MM-DD>|sources -> set([<source>, ...])

bin/sanitizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _sanitize_ip(self, pipeline: Redis, uuid: str, data: Dict) -> Optional[Dict]
5757
'date': datetime.date().isoformat(), 'datetime': datetime.isoformat()})
5858
pipeline.sadd('to_insert', uuid)
5959

60-
return {'ip': str(ip), 'address_family': address_family, 'source': 'caida',
60+
return {'ip': str(ip), 'address_family': address_family,
6161
'date': datetime.isoformat(), 'precision_delta': {'days': 3}}
6262

6363
def _sanitize_network(self, pipeline: Redis, uuid: str, data: Dict) -> List[Dict]:
@@ -90,7 +90,7 @@ def _sanitize_network(self, pipeline: Redis, uuid: str, data: Dict) -> List[Dict
9090
'date': datetime.date().isoformat(), 'datetime': datetime.isoformat()})
9191
pipeline.sadd('to_insert', uuid)
9292

93-
for_cache.append({'ip': str(ip), 'address_family': address_family, 'source': 'caida',
93+
for_cache.append({'ip': str(ip), 'address_family': address_family,
9494
'date': datetime.isoformat(), 'precision_delta': {'days': 3}})
9595
return for_cache
9696

0 commit comments

Comments
 (0)