Skip to content

Commit

Permalink
fix issue in win32.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-X-Net committed Aug 10, 2023
1 parent bc0515e commit 27f6c58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions code/default/smart_router/local/dns_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import ssl
import random
import struct
import fcntl
import subprocess

current_path = os.path.dirname(os.path.abspath(__file__))
Expand All @@ -39,6 +38,7 @@

def get_local_ips():
def get_ip_address(NICname):
import fcntl
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
Expand Down Expand Up @@ -71,6 +71,11 @@ def get_ip_address(NICname):
ips = [b'127.0.0.1']
elif sys.platform == "ios":
ips = [b'127.0.0.1']
elif sys.platform == "win32":
ips = [ip for ip in socket.gethostbyname_ex(socket.gethostname())[2]]
ips = utils.to_bytes(ips)
if b"127.0.0.1" not in ips:
ips.append(b"127.0.0.1")
else:
ips = []
try:
Expand All @@ -82,7 +87,7 @@ def get_ip_address(NICname):
xlog.warn("get ip address e:%r", e)
ips = [b'127.0.0.1']

xlog.debug("ips: %s", ips)
xlog.debug("local ips: %s", ips)
return ips


Expand Down

0 comments on commit 27f6c58

Please sign in to comment.