dns: reply to A/AAAA questions for additional hostnames
authorJohn Crispin <john@phrozen.org>
Sun, 21 Apr 2024 17:44:07 +0000 (19:44 +0200)
committerJohn Crispin <john@phrozen.org>
Tue, 17 Sep 2024 15:59:50 +0000 (17:59 +0200)
Signed-off-by: John Crispin <john@phrozen.org>
dns.c

diff --git a/dns.c b/dns.c
index 2b5a3906c4d55b1d66ddbaeea10f54621735881c..f6f0be5cc1181eda18a29ddd586749cf096fa3d2 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -358,6 +358,7 @@ static void
 parse_question(struct interface *iface, struct sockaddr *from, char *name, struct dns_question *q)
 {
        struct sockaddr *to = NULL;
+       struct hostname *h;
        char *host;
 
        /* TODO: Multicast if more than one quarter of TTL has passed */
@@ -404,8 +405,15 @@ parse_question(struct interface *iface, struct sockaddr *from, char *name, struc
                host = strstr(name, ".local");
                if (host)
                        *host = '\0';
-               if (!strcmp(umdns_host_label, name))
+               if (!strcmp(umdns_host_label, name)) {
                        dns_reply_a(iface, to, announce_ttl, NULL);
+               } else {
+                       if (host)
+                               *host = '.';
+                       vlist_for_each_element(&hostnames, h, node)
+                               if (!strcmp(h->hostname, name))
+                                       dns_reply_a(iface, to, announce_ttl, h->hostname);
+               }
                break;
        };
 }