Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Setting:
'overlayTelemetryUrl': Setting(None, 'https://telemetry.toncenter.com/report_overlays', 'Overlay telemetry url'),
'duplicateApi': Setting(None, 'sendTelemetry', 'Duplicate external to Toncenter'),
'duplicateApiUrl': Setting(None, 'https://[testnet.]toncenter.com/api/v2/sendBoc', 'Toncenter api url for duplicate'),
'checkAdnl': Setting(None, 'sendTelemetry', 'Check local udp port and adnl connection'),
'liteclient_timeout': Setting(None, 3, 'Liteclient default timeout'),
'console_timeout': Setting(None, 3, 'Validator console default timeout'),
'fift_timeout': Setting(None, 3, 'Fift default timeout'),
Expand Down
37 changes: 37 additions & 0 deletions mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -2707,6 +2707,43 @@ def GetDbSize(self, exceptions="log"):
return result
#end define

def check_adnl(self):
telemetry = self.local.db.get("sendTelemetry", False)
check_adnl = self.local.db.get("checkAdnl", telemetry)
if not check_adnl:
return
url = 'http://45.129.96.53/adnl_check'
try:
data = self.get_local_adnl_data()
response = requests.post(url, json=data, timeout=5).json()
except Exception as e:
self.local.add_log(f'Failed to check adnl connection: {type(e)}: {e}', 'error')
return False
result = response.get("ok")
if not result:
self.local.add_log(f'Failed to check adnl connection to local node: {response.get("message")}', 'error')
return result
#end define

def get_local_adnl_data(self):

def int2ip(dec):
import socket
return socket.inet_ntoa(struct.pack("!i", dec))

vconfig = self.GetValidatorConfig()

data = {"host": int2ip(vconfig["addrs"][0]["ip"]), "port": vconfig["addrs"][0]["port"]}

dht_id = vconfig["dht"][0]["id"]
dht_id_hex = base64.b64decode(dht_id).hex().upper()

result = self.validatorConsole.Run(f"exportpub {dht_id_hex}")
pubkey = parse(result, "got public key: ", "\n")
data["pubkey"] = base64.b64encode(base64.b64decode(pubkey)[4:]).decode()
return data
#end define

def Result2List(self, text):
buff = parse(text, "result:", "\n")
if buff is None or "error" in buff:
Expand Down
1 change: 1 addition & 0 deletions mytonctrl/mytonctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def PreUp(local, ton):
CheckMytonctrlUpdate(local)
check_installer_user(local)
check_vport(local, ton)
ton.check_adnl()
warnings(local, ton)
# CheckTonUpdate()
#end define
Expand Down