From 5305b28a869365577d5d40b45dbeaa24a748d7ac Mon Sep 17 00:00:00 2001 From: thl-cmk <thl-cmk@outlook.com> Date: Fri, 3 Feb 2023 08:14:27 +0100 Subject: [PATCH] changed local ip-address detecteion removed 127.*, fe80::* amd ::1 --- pnp/open-pnp.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pnp/open-pnp.py b/pnp/open-pnp.py index 28e4c6d..634ce2f 100755 --- a/pnp/open-pnp.py +++ b/pnp/open-pnp.py @@ -590,9 +590,17 @@ def get_local_ip_addresses() -> List[str]: _addresses = [] adapters = get_adapters() for adapter in adapters: - if adapter.nice_name not in ['lo']: - for ip in adapter.ips: - _addresses.append(ip.ip) + for ip in adapter.ips: + drop_ip = False + if ip.is_IPv4: + ip_addr= ip.ip + elif ip.is_IPv6: + ip_addr = ip.ip[0] + for entry in ['127.', 'fe80::', '::1']: + if str(ip_addr).lower().startswith(entry): + drop_ip = True + if not drop_ip: + _addresses.append(ip_addr) return _addresses -- GitLab