summaryrefslogtreecommitdiffstats
path: root/retiolum/scripts/adv_graphgen/tinc_stats/Geo.py
diff options
context:
space:
mode:
Diffstat (limited to 'retiolum/scripts/adv_graphgen/tinc_stats/Geo.py')
-rwxr-xr-xretiolum/scripts/adv_graphgen/tinc_stats/Geo.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/retiolum/scripts/adv_graphgen/tinc_stats/Geo.py b/retiolum/scripts/adv_graphgen/tinc_stats/Geo.py
new file mode 100755
index 00000000..ba3f6738
--- /dev/null
+++ b/retiolum/scripts/adv_graphgen/tinc_stats/Geo.py
@@ -0,0 +1,13 @@
+#!/usr/bin/python3
+# -*- coding: utf8 -*-
+import sys,json
+from Graph import delete_unused_nodes
+
+if __name__ == "__main__":
+ from pygeoip import GeoIP
+ gi = GeoIP("GeoLiteCity.dat")
+ for node,data in delete_unused_nodes(json.load(sys.stdin)).items():
+ try:
+ print ("%s in %s"%(node,gi.record_by_addr(data["external-ip"])["city"]))
+ except:
+ print ("%s myself"%node)