Skip to content

Commit

Permalink
qr-code: better fallback ip when no default-route
Browse files Browse the repository at this point in the history
  • Loading branch information
9001 committed May 5, 2024
1 parent f849197 commit 25139a4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions copyparty/tcpsrv.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,12 @@ def _set_wintitle(self, vs: dict[str, dict[str, int]]) -> None:
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
Expand Down

0 comments on commit 25139a4

Please sign in to comment.