|
|
|
@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
|
|
|
|
|
#server for collecting views of the network |
|
|
|
|
#server for collecting DHT info |
|
|
|
|
|
|
|
|
|
import json |
|
|
|
|
import time |
|
|
|
@ -26,7 +26,6 @@ def check_coords(coords):
@@ -26,7 +26,6 @@ def check_coords(coords):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def valid_ipv6_check(ipv6add): |
|
|
|
|
import ipaddress |
|
|
|
|
try: |
|
|
|
|
if ipaddress.IPv6Address(unicode(ipv6add)): |
|
|
|
|
addr = True |
|
|
|
@ -47,11 +46,11 @@ def isdatabase(db_path):
@@ -47,11 +46,11 @@ def isdatabase(db_path):
|
|
|
|
|
conn.commit() |
|
|
|
|
# c.commit() |
|
|
|
|
except Error as e: |
|
|
|
|
print(e) |
|
|
|
|
print e |
|
|
|
|
finally: |
|
|
|
|
conn.close() |
|
|
|
|
else: |
|
|
|
|
print("found database will not create a new one") |
|
|
|
|
print"found database will not create a new one" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def insert_new_entry(db_path, ipv6, coords, utimestamp): |
|
|
|
@ -63,22 +62,22 @@ def insert_new_entry(db_path, ipv6, coords, utimestamp):
@@ -63,22 +62,22 @@ def insert_new_entry(db_path, ipv6, coords, utimestamp):
|
|
|
|
|
conn.commit() |
|
|
|
|
conn.close() |
|
|
|
|
except Error as e: |
|
|
|
|
print(e) |
|
|
|
|
print e |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def error_check_insert_into_db(dht, switchpeers): |
|
|
|
|
try: |
|
|
|
|
if "success" == dht.get("status"): |
|
|
|
|
if dht.get("status") == "success": |
|
|
|
|
for x, y in dht["response"]["dht"].iteritems(): |
|
|
|
|
if valid_ipv6_check(x) and check_coords(y["coords"]): |
|
|
|
|
insert_new_entry(DB_PATH, x, y["coords"], int(time.time())) |
|
|
|
|
|
|
|
|
|
if "success" == dht.get("status"): |
|
|
|
|
if dht.get("status") == "success": |
|
|
|
|
for x in switchpeers["response"]["switchpeers"].iteritems(): |
|
|
|
|
if valid_ipv6_check(x[1]["ip"]) and check_coords(x[1]["coords"]): |
|
|
|
|
insert_new_entry(DB_PATH, x[1]["ip"], x[1]["coords"], int(time.time())) |
|
|
|
|
except: |
|
|
|
|
print("error in json file, aborting") |
|
|
|
|
print"error in json file, aborting" |
|
|
|
|
|
|
|
|
|
def proccess_incoming_data(datty, addr): |
|
|
|
|
print addr |
|
|
|
|