@@ -2707,6 +2707,43 @@ def GetDbSize(self, exceptions="log"):
27072707 return result
27082708 #end define
27092709
2710+ def check_adnl (self ):
2711+ telemetry = self .local .db .get ("sendTelemetry" , False )
2712+ check_adnl = self .local .db .get ("checkAdnl" , telemetry )
2713+ if not check_adnl :
2714+ return
2715+ url = 'http://45.129.96.53/adnl_check'
2716+ try :
2717+ data = self .get_local_adnl_data ()
2718+ response = requests .post (url , json = data , timeout = 3 ).json ()
2719+ except Exception as e :
2720+ self .local .add_log (f'Failed to check adnl connection: { type (e )} : { e } ' )
2721+ return False
2722+ result = response .json ().get ("ok" )
2723+ if not result :
2724+ self .local .add_log (f'Failed to check adnl connection to local node: { response .get ("message" )} ' , 'error' )
2725+ return result
2726+ #end define
2727+
2728+ def get_local_adnl_data (self ):
2729+
2730+ def int2ip (dec ):
2731+ import socket
2732+ return socket .inet_ntoa (struct .pack ("!i" , dec ))
2733+
2734+ vconfig = self .GetValidatorConfig ()
2735+
2736+ data = {"ip" : int2ip (vconfig ["addrs" ][0 ]["ip" ]), "port" : vconfig ["addrs" ][0 ]["port" ]}
2737+
2738+ dht_id = vconfig ["dht" ][0 ]["id" ]
2739+ dht_id_hex = base64 .b64decode (dht_id ).hex ().upper ()
2740+
2741+ result = self .validatorConsole .Run (f"exportpub { dht_id_hex } " )
2742+ pubkey = parse (result , "got public key: " , "\n " )
2743+ data ["pubkey" ] = base64 .b64encode (base64 .b64decode (pubkey )[4 :])
2744+ return data
2745+ #end define
2746+
27102747 def Result2List (self , text ):
27112748 buff = parse (text , "result:" , "\n " )
27122749 if buff is None or "error" in buff :
0 commit comments