]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix DNS-SD lookups of local services with Avahi (Issue #970)
authorMichael R Sweet <msweet@msweet.org>
Thu, 30 May 2024 12:09:52 +0000 (08:09 -0400)
committerMichael R Sweet <msweet@msweet.org>
Thu, 30 May 2024 12:09:52 +0000 (08:09 -0400)
CHANGES.md
cups/dnssd.c

index 0d1db365a5a2b4398556aeadf8218bb63c91f6f6..fe5016fe08faf1d76fb0ae962669283cc50631dc 100644 (file)
@@ -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.
index f124c32afd3f2246511ac84f95f179c53a529ad0..d72f0d1f66706f2fb5f1e48d559d72cf44a3c81f 100644 (file)
@@ -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))
   {