def write(self, path):
self.writer.write(path)
- def import_rir(self, rir):
- with open(rir.filename_asnums, "rb") as f:
+ def import_ases(self, filename):
+ with open(filename, "rb") as f:
for block in util.iterate_over_blocks(f):
self._parse_asnum_block(block)
- with open(rir.filename_networks, "rb") as f:
+ def import_networks(self, filename):
+ with open(filename, "rb") as f:
for block in util.iterate_over_blocks(f):
self._parse_network_block(block)
+ def import_rir(self, rir):
+ self.import_ases(rir.filename_asnums)
+ self.import_networks(rir.filename_networks)
+
def _parse_asnum_block(self, block):
asn = None
name = None
logging.warning("Skipping network %s, because one already exists at this address" % network)
return
- # Save attributes
- n.country_code = country
+ # Translate some special country codes into flags
+ if country == "A1":
+ n.set_flag(location.NETWORK_FLAG_ANONYMOUS_PROXY)
+ elif country == "A2":
+ n.set_flag(location.NETWORK_FLAG_SATELLITE_PROVIDER)
+ elif country == "A3":
+ n.set_flag(location.NETWORK_FLAG_ANYCAST)
+
+ # Set all other country codes
+ else:
+ n.country_code = country
+
+ # Set ASN if available
if asn:
n.asn = asn