diff options
author | AnilDaoud <anil+git@via.ecp.fr> | 2019-05-22T05·27+0800 |
---|---|---|
committer | Daniel Høyer Iversen <mail@dahoiv.net> | 2019-05-22T05·27+0200 |
commit | b8fdf337c9a60d74437bf88fa07134e651f7c0fa (patch) | |
tree | 75bf29ba68a6dfab2e3a3cce4e736a52d59bc504 | |
parent | a75f98720ec22e9857ef815f594952f34ed5485c (diff) |
cleaner local ip address lookup (#244)
-rw-r--r-- | broadlink/__init__.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/broadlink/__init__.py b/broadlink/__init__.py index 582f64d7fe82..c3b2cecd1a7d 100644 --- a/broadlink/__init__.py +++ b/broadlink/__init__.py @@ -63,9 +63,7 @@ def gendevice(devtype, host, mac): def discover(timeout=None, local_ip_address=None): if local_ip_address is None: - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.connect(('8.8.8.8', 53)) # connecting to a UDP address doesn't send packets - local_ip_address = s.getsockname()[0] + local_ip_address = socket.gethostbyname(socket.gethostname()) address = local_ip_address.split('.') cs = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) cs.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) |