add socket base ip lookup
This commit is contained in:
parent
7e63150c6e
commit
031b6ca7cd
1 changed files with 7 additions and 0 deletions
|
@ -286,6 +286,13 @@ def get_local_ipv4():
|
||||||
local_ip = re.compile('inet (\d+\.\d+\.\d+.\d+)').findall(local_ip[0])
|
local_ip = re.compile('inet (\d+\.\d+\.\d+.\d+)').findall(local_ip[0])
|
||||||
if local_ip:
|
if local_ip:
|
||||||
ip = local_ip[0]
|
ip = local_ip[0]
|
||||||
|
if not ip:
|
||||||
|
try:
|
||||||
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
s.connect(("8.8.8.8", 53))
|
||||||
|
return s.getsockname()[0]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
return ip
|
return ip
|
||||||
|
|
||||||
def update_dict(root, data):
|
def update_dict(root, data):
|
||||||
|
|
Loading…
Reference in a new issue