From 107dec9ed1c93b8d02ebb14ff9a135fe7c4013ef Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 24 Sep 2026 19:31:21 +0000 Subject: [PATCH] ifaddr: winxp fix --- copyparty/stolen/ifaddr/_win32.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/copyparty/stolen/ifaddr/_win32.py b/copyparty/stolen/ifaddr/_win32.py index db0d3d407..17d26b01a 100644 --- a/copyparty/stolen/ifaddr/_win32.py +++ b/copyparty/stolen/ifaddr/_win32.py @@ -2,6 +2,7 @@ from __future__ import print_function, unicode_literals import ctypes +import sys from ctypes import wintypes if True: # pylint: disable=using-constant-test @@ -9,6 +10,9 @@ if True: # pylint: disable=using-constant-test from . import _shared as shared +WINVER = sys.getwindowsversion() +LE_XP = WINVER.major < 6 + NO_ERROR = 0 ERROR_BUFFER_OVERFLOW = 111 MAX_ADAPTER_NAME_LENGTH = 256 @@ -83,7 +87,10 @@ def enumerate_interfaces_of_adapter( t = "sockaddr_to_ip({}) returned None" raise Exception(t.format(address.Address.lpSockaddr)) - network_prefix = address.OnLinkPrefixLength + if LE_XP: + network_prefix = 16 if str(ip).startswith("169.254") else 24 + else: + network_prefix = address.OnLinkPrefixLength yield shared.IP(ip, network_prefix, nice_name)