]> 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:15:42 +0000 (08:15 -0400)
committerMichael R Sweet <msweet@msweet.org>
Thu, 30 May 2024 12:15:42 +0000 (08:15 -0400)
CHANGES.md
cups/http-support.c

index c10fdd0c3581e0debbd88dda83b6dbd217438938..c903681f53862e11914ade6df6feb62909679cb3 100644 (file)
@@ -11,6 +11,7 @@ Changes in CUPS v2.4.9 (TBA)
 - Really raised `cups_enum_dests()` timeout for listing available IPP printers
   (Issue #751)...
 - Fixed `Host` header regression (Issue #967)
+- Fixed DNS-SD lookups of local services with Avahi (Issue #970)
 
 
 Changes in CUPS v2.4.8 (2024-04-26)
index 51a098acdcc1ffe6f9f28bc9f2fd7323930e7fba..8bdf23505e9ab4965a318515617bcb0dfb20c675 100644 (file)
@@ -2540,6 +2540,18 @@ http_resolve_cb(
     return;
   }
 
+  // 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("5http_resolve_cb: Mapping 127.0.0.1 to localhost.");
+    hostTarget = "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("5http_resolve_cb: Mapping ::1 to localhost.");
+    hostTarget = "localhost";
+  }
+
  /*
   * If we have a UUID, compare it...
   */