]> git.meshlink.io Git - catta/blobdiff - avahi-core/server.c
forgot to pull the publish_no_reverse change to the example.
[catta] / avahi-core / server.c
index 938c54de362574153c6a2284ed9f823d830c2856..b348269d59dd15544eace1b9c399f86b8fe67e9c 100644 (file)
@@ -49,7 +49,7 @@
 #include "domain-util.h"
 #include "rr-util.h"
 
-#define AVAHI_DEFAULT_CACHE_ENTRIES_MAX 500
+#define AVAHI_DEFAULT_CACHE_ENTRIES_MAX 4096
 
 static void enum_aux_records(AvahiServer *s, AvahiInterface *i, const char *name, uint16_t type, void (*callback)(AvahiServer *s, AvahiRecord *r, int flush_cache, void* userdata), void* userdata) {
     assert(s);
@@ -513,12 +513,20 @@ static void reflect_response(AvahiServer *s, AvahiInterface *i, AvahiRecord *r,
 
 static void* reflect_cache_walk_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEntry *e, void* userdata) {
     AvahiServer *s = userdata;
+    AvahiRecord* r;
 
     assert(c);
     assert(pattern);
     assert(e);
     assert(s);
 
+    /* Don't reflect cache entry with ipv6 link-local addresses. */
+    r = e->record;
+    if ((r->key->type == AVAHI_DNS_TYPE_AAAA) &&
+            (r->data.aaaa.address.address[0] == 0xFE) &&
+            (r->data.aaaa.address.address[1] == 0x80))
+      return NULL;
+
     avahi_record_list_push(s->record_list, e->record, e->cache_flush, 0, 0);
     return NULL;
 }
@@ -923,10 +931,9 @@ static void dispatch_packet(AvahiServer *s, AvahiDnsPacket *p, const AvahiAddres
     if (avahi_dns_packet_is_query(p)) {
         int legacy_unicast = 0;
 
-        if (avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ARCOUNT) != 0) {
-            avahi_log_warn("Invalid query packet.");
-            return;
-        }
+        /* For queries EDNS0 might allow ARCOUNT != 0. We ignore the
+         * AR section completely here, so far. Until the day we add
+         * EDNS0 support. */
 
         if (port != AVAHI_MDNS_PORT) {
             /* Legacy Unicast */
@@ -1216,6 +1223,7 @@ static void register_stuff(AvahiServer *s) {
     register_browse_domain(s);
     avahi_interface_monitor_update_rrs(s->monitor, 0);
 
+    assert(s->n_host_rr_pending > 0);
     s->n_host_rr_pending --;
 
     if (s->n_host_rr_pending == 0)
@@ -1242,13 +1250,14 @@ int avahi_server_set_host_name(AvahiServer *s, const char *host_name) {
 
     AVAHI_CHECK_VALIDITY(s, !host_name || avahi_is_valid_host_name(host_name), AVAHI_ERR_INVALID_HOST_NAME);
 
-    if (!host_name) {
+    if (!host_name)
         hn = avahi_get_host_name_strdup();
-        hn[strcspn(hn, ".")] = 0;
-        host_name = hn;
-    }
+    else
+        hn = avahi_normalize_name_strdup(host_name);
+
+    hn[strcspn(hn, ".")] = 0;
 
-    if (avahi_domain_equal(s->host_name, host_name) && s->state != AVAHI_SERVER_COLLISION) {
+    if (avahi_domain_equal(s->host_name, hn) && s->state != AVAHI_SERVER_COLLISION) {
         avahi_free(hn);
         return avahi_server_set_errno(s, AVAHI_ERR_NO_CHANGE);
     }
@@ -1256,7 +1265,7 @@ int avahi_server_set_host_name(AvahiServer *s, const char *host_name) {
     withdraw_host_rrs(s);
 
     avahi_free(s->host_name);
-    s->host_name = hn ? hn : avahi_strdup(host_name);
+    s->host_name = hn;
 
     update_fqdn(s);
 
@@ -1270,10 +1279,10 @@ int avahi_server_set_domain_name(AvahiServer *s, const char *domain_name) {
 
     AVAHI_CHECK_VALIDITY(s, !domain_name || avahi_is_valid_domain_name(domain_name), AVAHI_ERR_INVALID_DOMAIN_NAME);
 
-    if (!domain_name) {
+    if (!domain_name)
         dn = avahi_strdup("local");
-        domain_name = dn;
-    }
+    else
+        dn = avahi_normalize_name_strdup(domain_name);
 
     if (avahi_domain_equal(s->domain_name, domain_name)) {
         avahi_free(dn);
@@ -1283,7 +1292,7 @@ int avahi_server_set_domain_name(AvahiServer *s, const char *domain_name) {
     withdraw_host_rrs(s);
 
     avahi_free(s->domain_name);
-    s->domain_name = avahi_normalize_name_strdup(domain_name);
+    s->domain_name = dn;
     update_fqdn(s);
 
     register_stuff(s);
@@ -1386,6 +1395,7 @@ AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig
     s->need_entry_cleanup = 0;
     s->need_group_cleanup = 0;
     s->need_browser_cleanup = 0;
+    s->cleanup_time_event = NULL;
     s->hinfo_entry_group = NULL;
     s->browse_domain_entry_group = NULL;
     s->error = AVAHI_OK;
@@ -1485,6 +1495,9 @@ void avahi_server_free(AvahiServer* s) {
         avahi_wide_area_engine_free(s->wide_area_lookup_engine);
     avahi_multicast_lookup_engine_free(s->multicast_lookup_engine);
 
+    if (s->cleanup_time_event)
+        avahi_time_event_free(s->cleanup_time_event);
+
     avahi_time_event_queue_free(s->time_event_queue);
 
     /* Free watches */
@@ -1569,9 +1582,10 @@ AvahiServerConfig* avahi_server_config_init(AvahiServerConfig *c) {
     c->host_name = NULL;
     c->domain_name = NULL;
     c->check_response_ttl = 0;
-    c->publish_hinfo = 1;
+    c->publish_hinfo = 0;
     c->publish_addresses = 1;
-    c->publish_workstation = 1;
+    c->publish_no_reverse = 0;
+    c->publish_workstation = 0;
     c->publish_domain = 1;
     c->use_iff_running = 0;
     c->enable_reflector = 0;
@@ -1586,6 +1600,8 @@ AvahiServerConfig* avahi_server_config_init(AvahiServerConfig *c) {
     c->publish_aaaa_on_ipv4 = 1;
     c->publish_a_on_ipv6 = 0;
     c->n_cache_entries_max = AVAHI_DEFAULT_CACHE_ENTRIES_MAX;
+    c->ratelimit_interval = 0;
+    c->ratelimit_burst = 0;
 
     return c;
 }