From: Michael R Sweet Date: Thu, 30 May 2024 12:09:52 +0000 (-0400) Subject: Fix DNS-SD lookups of local services with Avahi (Issue #970) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94eb38f0cee18895afc89f5143a2acb145852a0f;p=thirdparty%2Fcups.git Fix DNS-SD lookups of local services with Avahi (Issue #970) --- diff --git a/CHANGES.md b/CHANGES.md index 0d1db365a5..fe5016fe08 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -90,6 +90,7 @@ Changes in CUPS v2.5b1 (TBA) - Fixed encoding of `IPP_TAG_EXTENSION` values in IPP messages (Issue #913) - Fixed sending response headers to client (Issue #927) - Fixed `Host` header regression (Issue #967) +- Fixed DNS-SD lookups of local services with Avahi (Issue #970) - Fixed CGI program initialization and validation of form checkbox and text fields. - Fixed finishing support in ippeveps. diff --git a/cups/dnssd.c b/cups/dnssd.c index f124c32afd..d72f0d1f66 100644 --- a/cups/dnssd.c +++ b/cups/dnssd.c @@ -2409,9 +2409,20 @@ avahi_resolve_cb( (void)resolver; (void)protocol; - (void)address; (void)flags; + // Map the addresses "127.0.0.1" (IPv4) and "::1" (IPv6) to "localhost" to work around a well-known Avahi registration bug for local-only services (Issue #970) + if (address->proto == AVAHI_PROTO_INET && address->data.ipv4.address == htonl(0x7f000001)) + { + DEBUG_puts("4avahi_resolve_cb: Mapping 127.0.0.1 to localhost."); + host = "localhost"; + } + else if (address->proto == AVAHI_PROTO_INET6 && address->data.ipv6.address[0] == 0 && address->data.ipv6.address[1] == 0 && address->data.ipv6.address[2] == 0 && address->data.ipv6.address[3] == 0 && address->data.ipv6.address[4] == 0 && address->data.ipv6.address[5] == 0 && address->data.ipv6.address[6] == 0 && address->data.ipv6.address[7] == 0 && address->data.ipv6.address[8] == 0 && address->data.ipv6.address[9] == 0 && address->data.ipv6.address[10] == 0 && address->data.ipv6.address[11] == 0 && address->data.ipv6.address[12] == 0 && address->data.ipv6.address[13] == 0 && address->data.ipv6.address[14] == 0 && address->data.ipv6.address[15] == 1) + { + DEBUG_puts("4avahi_resolve_cb: Mapping ::1 to localhost."); + host = "localhost"; + } + // Convert TXT key/value pairs into CUPS option array... for (txtpair = txtrec; txtpair; txtpair = avahi_string_list_get_next(txtpair)) {