internet_ip plugin 0.2

This commit is contained in:
Jokob-sk
2023-09-20 21:53:22 +10:00
parent add9800f42
commit c08b70a38d
18 changed files with 495 additions and 439 deletions

View File

@@ -291,26 +291,6 @@ def check_IP_format (pIP):
#-------------------------------------------------------------------------------
def get_internet_IP ():
# BUGFIX #46 - curl http://ipv4.icanhazip.com repeatedly is very slow
# Using 'dig'
dig_args = ['dig', '+short'] + conf.DIG_GET_IP_ARG.strip().split()
try:
cmd_output = subprocess.check_output (dig_args, universal_newlines=True)
except subprocess.CalledProcessError as e:
mylog('none', [e.output])
cmd_output = '' # no internet
# Check result is an IP
IP = check_IP_format (cmd_output)
# Handle invalid response
if IP == '':
IP = '0.0.0.0'
return IP
#-------------------------------------------------------------------------------
def resolve_device_name_dig (pMAC, pIP):