Traceroute visualizer written in python
python
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

geo6.py 697B

1234567891011121314151617181920212223
  1. import csv
  2. import GeoIP
  3. gi6 = GeoIP.open("/usr/share/GeoIP/GeoIPv6.dat",GeoIP.GEOIP_STANDARD)
  4. countries = {}
  5. with open('mapData/countries.csv') as csvfile:
  6. reader = csv.DictReader(csvfile, delimiter=',', quotechar='"')
  7. rows = [r for r in reader]
  8. countries = {row['Alpha-2 code']:{'lon':row['Longitude (average)'],'lat': row['Latitude (average)']}
  9. for row in rows}
  10. countries.update({row['Alpha-3 code']:{'lon':row['Longitude (average)'],'lat': row['Latitude (average)']}
  11. for row in rows})
  12. def ip62coord(ipv6):
  13. res = gi6.country_code_by_addr_v6(ipv6)
  14. if res is not None:
  15. if res in countries:
  16. coord = countries[res]
  17. return float(coord['lon']), float(coord['lat'])
  18. return None