diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index fe2ffb37..9f65af15 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -2600,24 +2600,6 @@ 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): diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index ba606750..a4202c8c 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf_8 -*- import base64 +import random import subprocess import json import psutil @@ -10,6 +11,8 @@ from functools import partial +import requests + from mypylib.mypylib import ( int2ip, get_git_author_and_repo, @@ -218,7 +221,6 @@ def PreUp(local: MyPyClass, ton: MyTonCore): CheckMytonctrlUpdate(local) check_installer_user(local) check_vport(local, ton) - ton.check_adnl() warnings(local, ton) # CheckTonUpdate() #end define @@ -484,9 +486,40 @@ def check_slashed(local, ton): print_warning(local, "slashed_warning") #end define +def check_adnl(local, ton): + telemetry = ton.local.db.get("sendTelemetry", False) + check_adnl = ton.local.db.get("checkAdnl", telemetry) + local.add_log('Checking ADNL connection to local node', 'info') + if not check_adnl: + return + hosts = ['45.129.96.53', '5.154.181.153', '2.56.126.137', '91.194.11.68', '45.12.134.214', '138.124.184.27', '103.106.3.171'] + hosts = random.sample(hosts, k=3) + data = ton.get_local_adnl_data() + error = '' + ok = True + for host in hosts: + url = f'http://{host}/adnl_check' + try: + response = requests.post(url, json=data, timeout=5).json() + except Exception as e: + ok = False + error = f'{{red}}Failed to check ADNL connection to local node: {type(e)}: {e}{{endc}}' + continue + result = response.get("ok") + if result: + ok = True + break + if not result: + ok = False + error = f'{{red}}Failed to check ADNL connection to local node: {response.get("message")}{{endc}}' + if not ok: + print_warning(local, error) +#end define + def warnings(local, ton): local.try_function(check_disk_usage, args=[local, ton]) local.try_function(check_sync, args=[local, ton]) + local.try_function(check_adnl, args=[local, ton]) local.try_function(check_validator_balance, args=[local, ton]) local.try_function(check_vps, args=[local, ton]) local.try_function(check_tg_channel, args=[local, ton])