Skip to content
Merged

dev #241

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
16 changes: 16 additions & 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()
check_vport(local, ton)
warnings(local, ton)
# CheckTonUpdate()
#end define

Expand Down Expand Up @@ -454,6 +455,21 @@ def CheckMytonctrlUpdate(local):
color_print(local.translate("mytonctrl_update_available"))
#end define

def print_warning(local, warning_name: str):
color_print("============================================================================================")
color_print(local.translate(warning_name))
color_print("============================================================================================")
#end define

def check_disk_usage(local, ton):
usage = ton.GetDbUsage()
if usage > 90:
print_warning(local, "disk_usage_warning")
#end define

def warnings(local, ton):
check_disk_usage(local, ton)

def CheckTonUpdate(local):
git_path = "/usr/src/ton"
result = check_git_update(git_path)
Expand Down
6 changes: 6 additions & 0 deletions mytoninstaller/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import json
import re
import subprocess
import requests
import base64
Expand Down Expand Up @@ -118,8 +119,13 @@ def CreateLocalConfig(local, initBlock, localConfigPath=defaultLocalConfigPath):


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

Expand Down