summaryrefslogtreecommitdiff
blob: 8f13aaf50289df6c81baeed6b0f6f7f5a1300c7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Index: avahi-daemon/static-hosts.c
===================================================================
--- avahi-daemon/static-hosts.c	(revision 1365)
+++ avahi-daemon/static-hosts.c	(revision 1366)
@@ -110,7 +110,9 @@
 static void add_static_host_to_server(StaticHost *h)
 {
     AvahiAddress a;
+    AvahiProtocol p;
     int err;
+    const AvahiServerConfig *config;
 
     if (!h->group)
         if (!(h->group = avahi_s_entry_group_new (avahi_server, entry_group_callback, h))) {
@@ -123,7 +125,12 @@
         return;
     }
 
-    if ((err = avahi_server_add_address(avahi_server, h->group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, h->host, &a))) {
+    config = avahi_server_get_config(avahi_server);
+    
+    p = (a.proto == AVAHI_PROTO_INET && config->publish_a_on_ipv6) ||
+        (a.proto == AVAHI_PROTO_INET6 && config->publish_aaaa_on_ipv4) ? AVAHI_PROTO_UNSPEC : a.proto;
+    
+    if ((err = avahi_server_add_address(avahi_server, h->group, AVAHI_IF_UNSPEC, p, 0, h->host, &a))) {
         avahi_log_error ("Static host name %s: avahi_server_add_address failure: %s", h->host, avahi_strerror(err));
         return;
     }
Index: avahi-daemon/main.c
===================================================================
--- avahi-daemon/main.c	(revision 1365)
+++ avahi-daemon/main.c	(revision 1366)
@@ -442,7 +442,7 @@
 static int is_yes(const char *s) {
     assert(s);
     
-    return *s == 'y' || *s == 'Y';
+    return *s == 'y' || *s == 'Y' || *s == '1' || *s == 't' || *s == 'T';
 }
 
 static int load_config_file(DaemonConfig *c) {
@@ -541,8 +541,12 @@
                     c->server_config.add_service_cookie = is_yes(p->value);
                 else if (strcasecmp(p->key, "publish-dns-servers") == 0) {
                     avahi_strfreev(c->publish_dns_servers);
-                    c->publish_dns_servers = avahi_split_csv(p->value); 
-                } else {
+                    c->publish_dns_servers = avahi_split_csv(p->value);
+                } else if (strcasecmp(p->key, "publish-a-on-ipv6") == 0)
+                    c->server_config.publish_a_on_ipv6 = is_yes(p->value);
+                else if (strcasecmp(p->key, "publish-aaaa-on-ipv4") == 0)
+                    c->server_config.publish_aaaa_on_ipv4 = is_yes(p->value);
+                else {
                     avahi_log_error("Invalid configuration key \"%s\" in group \"%s\"\n", p->key, g->name);
                     goto finish;
                 }
Index: avahi-daemon/avahi-daemon.conf
===================================================================
--- avahi-daemon/avahi-daemon.conf	(revision 1365)
+++ avahi-daemon/avahi-daemon.conf	(revision 1366)
@@ -45,6 +45,8 @@
 #publish-domain=yes
 #publish-dns-servers=192.168.50.1, 192.168.50.2
 #publish-resolv-conf-dns-servers=yes
+#publish-aaaa-on-ipv4=yes
+#publish-a-on-ipv6=no
 
 [reflector]
 #enable-reflector=no
Index: man/avahi-daemon.conf.5.xml.in
===================================================================
--- man/avahi-daemon.conf.5.xml.in	(revision 1365)
+++ man/avahi-daemon.conf.5.xml.in	(revision 1366)
@@ -223,6 +223,22 @@
         SIGHUP to have it reload this file. Defaults to "no".</p>
       </option>
 
+      <option>
+        <p><opt>publish-aaaa-on-ipv4=</opt> Takes a boolean value
+        ("yes" or "no"). If set to "yes" avahi-daemon will publish an
+        IPv6 AAAA record via IPv4, i.e. the local IPv6 addresses can be
+        resolved using an IPv4 transport. Only useful when IPv4 is
+        enabled with <opt>use-ipv4=true</opt>. Defaults to "yes".</p>
+      </option>
+
+      <option>
+        <p><opt>publish-a-on-ipv6=</opt> Takes a boolean value
+        ("yes" or "no"). If set to "yes" avahi-daemon will publish an
+        IPv4 A record via IPv6, i.e. the local IPv4 addresses can be
+        resolved using an IPv6 transport. Only useful when IPv6 is
+        enabled with <opt>use-ipv6=true</opt>. Defaults to "no".</p>
+      </option>
+
     </section>
 
 	<section name="Section [reflector]">