add socket base ip lookup

This commit is contained in:
j 2016-01-07 17:33:18 +05:30
parent 7e63150c6e
commit 031b6ca7cd

View file

@ -286,6 +286,13 @@ def get_local_ipv4():
local_ip = re.compile('inet (\d+\.\d+\.\d+.\d+)').findall(local_ip[0])
if local_ip:
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
def update_dict(root, data):