Skip to content

Commit 22b2c7a

Browse files
authored
Merge pull request #241 from yungwine/mytonctrl2_dev
dev
2 parents 7582c79 + e8244a4 commit 22b2c7a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

mytonctrl/mytonctrl.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ def PreUp(local, ton):
242242
CheckMytonctrlUpdate(local)
243243
check_installer_user()
244244
check_vport(local, ton)
245+
warnings(local, ton)
245246
# CheckTonUpdate()
246247
#end define
247248

@@ -454,6 +455,21 @@ def CheckMytonctrlUpdate(local):
454455
color_print(local.translate("mytonctrl_update_available"))
455456
#end define
456457

458+
def print_warning(local, warning_name: str):
459+
color_print("============================================================================================")
460+
color_print(local.translate(warning_name))
461+
color_print("============================================================================================")
462+
#end define
463+
464+
def check_disk_usage(local, ton):
465+
usage = ton.GetDbUsage()
466+
if usage > 90:
467+
print_warning(local, "disk_usage_warning")
468+
#end define
469+
470+
def warnings(local, ton):
471+
check_disk_usage(local, ton)
472+
457473
def CheckTonUpdate(local):
458474
git_path = "/usr/src/ton"
459475
result = check_git_update(git_path)

mytoninstaller/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import json
3+
import re
34
import subprocess
45
import requests
56
import base64
@@ -118,8 +119,13 @@ def CreateLocalConfig(local, initBlock, localConfigPath=defaultLocalConfigPath):
118119

119120

120121
def get_own_ip():
122+
pat = re.compile(r"^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$")
121123
requests.packages.urllib3.util.connection.HAS_IPV6 = False
122124
ip = requests.get("https://ifconfig.me/ip").text
125+
if not pat.fullmatch(ip):
126+
ip = requests.get("https://ipinfo.io/ip").text
127+
if not pat.fullmatch(ip):
128+
raise Exception('Cannot get own IP address')
123129
return ip
124130
#end define
125131

0 commit comments

Comments
 (0)