X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Fiface.c;h=60a4f4939168df95c15a2d0ab21ad845843a2bb7;hb=eb9711fa034b60bacd458c3726d215787b859cf1;hp=ad83fe465680da0f4823ef71740595fe990ef8b5;hpb=4cee342544b5d31022462ba522eed9959ebbd9dd;p=catta diff --git a/avahi-core/iface.c b/avahi-core/iface.c index ad83fe4..60a4f49 100644 --- a/avahi-core/iface.c +++ b/avahi-core/iface.c @@ -73,7 +73,7 @@ void avahi_interface_address_update_rrs(AvahiInterfaceAddress *a, int remove_rrs avahi_address_snprint(t, sizeof(t), &a->address); avahi_log_info("Registering new address record for %s on %s.%s.", t, a->interface->hardware->name, p == AVAHI_PROTO_UNSPEC ? "*" : avahi_proto_to_string(p)); - if (avahi_server_add_address(m->server, a->entry_group, a->interface->hardware->index, p, 0, NULL, &a->address) < 0) { + if (avahi_server_add_address(m->server, a->entry_group, a->interface->hardware->index, p, m->server->config.publish_no_reverse ? AVAHI_PUBLISH_NO_REVERSE : 0, NULL, &a->address) < 0) { avahi_log_warn(__FILE__": avahi_server_add_address() failed: %s", avahi_strerror(m->server->error)); avahi_s_entry_group_free(a->entry_group); a->entry_group = NULL; @@ -390,6 +390,9 @@ AvahiHwInterface *avahi_hw_interface_new(AvahiInterfaceMonitor *m, AvahiIfIndex hw->index = idx; hw->mac_address_size = 0; hw->entry_group = NULL; + hw->ratelimit_begin.tv_sec = 0; + hw->ratelimit_begin.tv_usec = 0; + hw->ratelimit_counter = 0; AVAHI_LLIST_HEAD_INIT(AvahiInterface, hw->interfaces); AVAHI_LLIST_PREPEND(AvahiHwInterface, hardware, m->hw_interfaces, hw); @@ -571,6 +574,27 @@ void avahi_interface_send_packet_unicast(AvahiInterface *i, AvahiDnsPacket *p, c assert(!a || a->proto == i->protocol); + if (i->monitor->server->config.ratelimit_interval > 0) { + struct timeval now, end; + + gettimeofday(&now, NULL); + + end = i->hardware->ratelimit_begin; + avahi_timeval_add(&end, i->monitor->server->config.ratelimit_interval); + + if (i->hardware->ratelimit_begin.tv_sec <= 0 || + avahi_timeval_compare(&end, &now) < 0) { + + i->hardware->ratelimit_begin = now; + i->hardware->ratelimit_counter = 0; + } + + if (i->hardware->ratelimit_counter > i->monitor->server->config.ratelimit_burst) + return; + + i->hardware->ratelimit_counter++; + } + if (i->protocol == AVAHI_PROTO_INET && i->monitor->server->fd_ipv4 >= 0) avahi_send_dns_packet_ipv4(i->monitor->server->fd_ipv4, i->hardware->index, p, i->mcast_joined ? &i->local_mcast_address.data.ipv4 : NULL, a ? &a->data.ipv4 : NULL, port); else if (i->protocol == AVAHI_PROTO_INET6 && i->monitor->server->fd_ipv6 >= 0)