From 5abe0c955cca92331eb0cbaa8c48512726f6d6bc Mon Sep 17 00:00:00 2001 From: ed Date: Thu, 17 Nov 2022 09:08:58 +0000 Subject: [PATCH] this spec is confusing --- copyparty/__main__.py | 3 ++- copyparty/mdns.py | 14 ++++++++------ copyparty/multicast.py | 2 ++ copyparty/stolen/dnslib/dns.py | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 2c8cfba2..eedccee8 100755 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -663,7 +663,7 @@ def run_argparse( ap2 = ap.add_argument_group("Zeroconf options") ap2.add_argument("--zm", action="store_true", help="announce the enabled protocols over mDNS (multicast DNS-SD) -- compatible with KDE, gnome, macOS, ...") - ap2.add_argument("--zm4", action="store_true", help="IPv4 only -- try this if some clients don't work") + ap2.add_argument("--zm4", action="store_true", help="IPv4 only -- try this if some clients can't connect") ap2.add_argument("--zm6", action="store_true", help="IPv6 only") ap2.add_argument("--zmv", action="store_true", help="verbose mdns") ap2.add_argument("--zmvv", action="store_true", help="verboser mdns") @@ -674,6 +674,7 @@ def run_argparse( ap2.add_argument("--zm-ls", metavar="PATH", type=str, default="", help="link a specific folder for smb shares") ap2.add_argument("--zm-mnic", action="store_true", help="merge NICs which share subnets; assume that same subnet means same network") ap2.add_argument("--zm-msub", action="store_true", help="merge subnets on each NIC -- always enabled for ipv6 -- reduces network load, but gnome-gvfs clients may stop working") + ap2.add_argument("--zm-noneg", action="store_true", help="disable NSEC replies -- try this if some clients don't see copyparty") ap2.add_argument("--mc-hop", metavar="SEC", type=int, default=0, help="rejoin multicast groups every SEC seconds (workaround for some switches/routers which cause mDNS to suddenly stop working after some time); try [\033[32m300\033[0m] or [\033[32m180\033[0m]") ap2 = ap.add_argument_group('FTP options') diff --git a/copyparty/mdns.py b/copyparty/mdns.py index 2a82a9b4..13bda0aa 100644 --- a/copyparty/mdns.py +++ b/copyparty/mdns.py @@ -175,12 +175,6 @@ class MDNS(MCast): sreply.add_answer(r120) bye.add_answer(r0) - if not have4 or not have6: - ns = NSEC(self.hn, ["AAAA" if have4 else "A"]) - r = RR(self.hn, QTYPE.NSEC, DC.F_IN, 120, ns) - areply.add_ar(r) - sreply.add_ar(r) - for sclass, props in self.svcs.items(): sname = props["name"] sport = props["port"] @@ -216,6 +210,14 @@ class MDNS(MCast): r = RR(sfqdn, QTYPE.TXT, DC.F_IN, 4500, TXT(txts)) sreply.add_answer(r) + if not (have4 and have6) and not self.args.zm_noneg: + have = "AAAA" if have6 else "A" + ns = NSEC(self.hn, [have, "PTR", "SRV", "TXT"]) + r = RR(self.hn, QTYPE.NSEC, DC.F_IN, 120, ns) + areply.add_ar(r) + if len(sreply.pack()) < 1400: + sreply.add_ar(r) + srv.bp_probe = probe.pack() srv.bp_ip = areply.pack() srv.bp_svc = sreply.pack() diff --git a/copyparty/multicast.py b/copyparty/multicast.py index ccefde4c..092cc3b4 100644 --- a/copyparty/multicast.py +++ b/copyparty/multicast.py @@ -41,6 +41,8 @@ class MC_Sck(object): self.net = net self.ips = {ip: net} self.v6 = ":" in ip + self.have4 = ":" not in ip + self.have6 = ":" in ip class MCast(object): diff --git a/copyparty/stolen/dnslib/dns.py b/copyparty/stolen/dnslib/dns.py index 07f1ad2c..57cda37f 100644 --- a/copyparty/stolen/dnslib/dns.py +++ b/copyparty/stolen/dnslib/dns.py @@ -105,7 +105,7 @@ class DNSRecord(object): self, header=None, questions=None, rr=None, q=None, a=None, auth=None, ar=None ) -> None: self.header = header or DNSHeader() - self.questions = questions or [] + self.questions: list[DNSQuestion] = questions or [] self.rr = rr or [] self.auth = auth or [] self.ar = ar or []