diff --git a/copyparty/mdns.py b/copyparty/mdns.py index 0dde707d..d80e5142 100644 --- a/copyparty/mdns.py +++ b/copyparty/mdns.py @@ -27,7 +27,7 @@ from .stolen.dnslib import ( DNSRecord, set_avahi_379, ) -from .util import CachedSet, Daemon, Netdev, list_ips, min_ex +from .util import IP6_LL, CachedSet, Daemon, Netdev, list_ips, min_ex if TYPE_CHECKING: from .svchub import SvcHub @@ -375,7 +375,7 @@ class MDNS(MCast): cip = addr[0] v6 = ":" in cip if (cip.startswith("169.254") and not self.ll_ok) or ( - v6 and not cip.startswith("fe80") + v6 and not cip.startswith(IP6_LL) ): return diff --git a/copyparty/multicast.py b/copyparty/multicast.py index 766dc15d..ea2f223e 100644 --- a/copyparty/multicast.py +++ b/copyparty/multicast.py @@ -15,7 +15,7 @@ from ipaddress import ( ) from .__init__ import MACOS, TYPE_CHECKING -from .util import Daemon, Netdev, find_prefix, min_ex, spack +from .util import IP6_LL, IP64_LL, Daemon, Netdev, find_prefix, min_ex, spack if TYPE_CHECKING: from .svchub import SvcHub @@ -145,7 +145,7 @@ class MCast(object): all_selected = ips[:] # discard non-linklocal ipv6 - ips = [x for x in ips if ":" not in x or x.startswith("fe80")] + ips = [x for x in ips if ":" not in x or x.startswith(IP6_LL)] if not ips: raise NoIPs() @@ -183,7 +183,7 @@ class MCast(object): srv.ips[oth_ip.split("/")[0]] = ipaddress.ip_network(oth_ip, False) # gvfs breaks if a linklocal ip appears in a dns reply - ll = {k: v for k, v in srv.ips.items() if k.startswith(("169.254", "fe80"))} + ll = {k: v for k, v in srv.ips.items() if k.startswith(IP64_LL)} rt = {k: v for k, v in srv.ips.items() if k not in ll} if self.args.ll or not rt: diff --git a/copyparty/tcpsrv.py b/copyparty/tcpsrv.py index 8d355251..b29b75f7 100644 --- a/copyparty/tcpsrv.py +++ b/copyparty/tcpsrv.py @@ -16,6 +16,7 @@ from .util import ( E_ADDR_NOT_AVAIL, E_UNREACH, HAVE_IPV6, + IP6_LL, IP6ALL, VF_CAREFUL, Netdev, @@ -140,12 +141,12 @@ class TcpSrv(object): # keep IPv6 LL-only nics ll_ok: set[str] = set() for ip, nd in self.netdevs.items(): - if not ip.startswith("fe80"): + if not ip.startswith(IP6_LL): continue just_ll = True for ip2, nd2 in self.netdevs.items(): - if nd == nd2 and ":" in ip2 and not ip2.startswith("fe80"): + if nd == nd2 and ":" in ip2 and not ip2.startswith(IP6_LL): just_ll = False if just_ll or self.args.ll: @@ -164,7 +165,7 @@ class TcpSrv(object): title_vars = [x[1:] for x in self.args.wintitle.split(" ") if x.startswith("$")] t = "available @ {}://{}:{}/ (\033[33m{}\033[0m)" for ip, desc in sorted(eps.items(), key=lambda x: x[1]): - if ip.startswith("fe80") and ip not in ll_ok: + if ip.startswith(IP6_LL) and ip not in ll_ok: continue for port in sorted(self.args.p): diff --git a/copyparty/util.py b/copyparty/util.py index 7e9d4bb1..97351f3c 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -112,6 +112,8 @@ E_ACCESS = _ens("EACCES WSAEACCES") E_UNREACH = _ens("EHOSTUNREACH WSAEHOSTUNREACH ENETUNREACH WSAENETUNREACH") IP6ALL = "0:0:0:0:0:0:0:0" +IP6_LL = ("fe8", "fe9", "fea", "feb") +IP64_LL = ("fe8", "fe9", "fea", "feb", "169.254") try: