From 25139a4358eff9fac21179d542242ac8dbfad5d2 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 5 May 2024 23:36:05 +0000 Subject: [PATCH] qr-code: better fallback ip when no default-route --- copyparty/tcpsrv.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/copyparty/tcpsrv.py b/copyparty/tcpsrv.py index 4bbea2c9..8d00eaab 100644 --- a/copyparty/tcpsrv.py +++ b/copyparty/tcpsrv.py @@ -463,6 +463,12 @@ class TcpSrv(object): sys.stderr.flush() def _qr(self, t1: dict[str, list[int]], t2: dict[str, list[int]]) -> str: + t2c = {zs: zli for zs, zli in t2.items() if zs in ("127.0.0.1", "::1")} + t2b = {zs: zli for zs, zli in t2.items() if ":" in zs and zs not in t2c} + t2 = {zs: zli for zs, zli in t2.items() if zs not in t2b and zs not in t2c} + t2.update(t2b) # first ipv4, then ipv6... + t2.update(t2c) # ...and finally localhost + ip = None ips = list(t1) + list(t2) qri = self.args.qri