Re: [Dnsmasq-discuss] [PATCH] decrease the amount of individual sites listed in log

2017-02-11 Thread Simon Kelley
Patch applied. Many thanks.


Cheers,

Simon.

On 07/02/17 18:03, Hannu Nyman wrote:
> By default 30 first servers are listed individually to system log, and
> then a count of the remaining items. With e.g. a NXDOMAIN based adblock
> service, dnsmasq lists 30 unnecessary ad sites every time when dnsmasq
> evaluates the list. But the actual nameservers in use are evaluated last
> and are not displayed as they get included in the "remaining items" total.
> 
> Handle the "local addresses only" separately and list only a few of them.
> Remove the "local addresses only" from the general count.
> 
> Signed-off-by: Hannu Nyman 
> ---
> 
> --- a/src/config.h
> +++ b/src/config.h
> @@ -27,6 +27,7 @@
>  #define FORWARD_TEST 50 /* try all servers every 50 queries */
>  #define FORWARD_TIME 20 /* or 20 seconds */
>  #define SERVERS_LOGGED 30 /* Only log this many servers when logging state */
> +#define LOCALS_LOGGED 8 /* Only log this many local addresses when logging 
> state */
>  #define RANDOM_SOCKS 64 /* max simultaneous random ports */
>  #define LEASE_RETRY 60 /* on error, retry writing leasefile after 
> LEASE_RETRY seconds */
>  #define CACHESIZ 150 /* default cache size */
> --- a/src/network.c
> +++ b/src/network.c
> @@ -1438,6 +1438,7 @@ void check_servers(void)
>struct server *serv;
>struct serverfd *sfd, *tmp, **up;
>int port = 0, count;
> +  int locals = 0;
>  
>/* interface may be new since startup */
>if (!option_bool(OPT_NOWILD))
> @@ -1541,7 +1542,11 @@ void check_servers(void)
>   s1 = _("domain"), s2 = serv->domain;
> 
> if (serv->flags & SERV_NO_ADDR)
> - my_syslog(LOG_INFO, _("using local addresses only for %s %s"), 
> s1, s2);
> + {
> +   count--;
> +   if (++locals <= LOCALS_LOGGED)
> + my_syslog(LOG_INFO, _("using local addresses only for 
> %s %s"), s1, s2);
> + }
> else if (serv->flags & SERV_USE_RESOLV)
>   my_syslog(LOG_INFO, _("using standard nameservers for %s %s"), 
> s1, s2);
> else 
> @@ -1558,6 +1563,8 @@ void check_servers(void)
>   }
>  }
>
> +  if (locals > LOCALS_LOGGED)
> +my_syslog(LOG_INFO, _("using %d more local addresses"), locals - 
> LOCALS_LOGGED);
>if (count - 1 > SERVERS_LOGGED)
>  my_syslog(LOG_INFO, _("using %d more nameservers"), count - 
> SERVERS_LOGGED - 1);
>  
> 


___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] [PATCH] decrease the amount of individual sites listed in log

2017-02-08 Thread Kevin Darbyshire-Bryant

Oooh that's a useful tidy'upper!

Like it.

Kevin

On 07/02/17 18:03, Hannu Nyman wrote:

By default 30 first servers are listed individually to system log, and
then a count of the remaining items. With e.g. a NXDOMAIN based adblock
service, dnsmasq lists 30 unnecessary ad sites every time when dnsmasq
evaluates the list. But the actual nameservers in use are evaluated last
and are not displayed as they get included in the "remaining items" total.

Handle the "local addresses only" separately and list only a few of them.
Remove the "local addresses only" from the general count.

Signed-off-by: Hannu Nyman 


___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


[Dnsmasq-discuss] [PATCH] decrease the amount of individual sites listed in log

2017-02-07 Thread Hannu Nyman
By default 30 first servers are listed individually to system log, and
then a count of the remaining items. With e.g. a NXDOMAIN based adblock
service, dnsmasq lists 30 unnecessary ad sites every time when dnsmasq
evaluates the list. But the actual nameservers in use are evaluated last
and are not displayed as they get included in the "remaining items" total.

Handle the "local addresses only" separately and list only a few of them.
Remove the "local addresses only" from the general count.

Signed-off-by: Hannu Nyman 
---

--- a/src/config.h
+++ b/src/config.h
@@ -27,6 +27,7 @@
 #define FORWARD_TEST 50 /* try all servers every 50 queries */
 #define FORWARD_TIME 20 /* or 20 seconds */
 #define SERVERS_LOGGED 30 /* Only log this many servers when logging state */
+#define LOCALS_LOGGED 8 /* Only log this many local addresses when logging 
state */
 #define RANDOM_SOCKS 64 /* max simultaneous random ports */
 #define LEASE_RETRY 60 /* on error, retry writing leasefile after LEASE_RETRY 
seconds */
 #define CACHESIZ 150 /* default cache size */
--- a/src/network.c
+++ b/src/network.c
@@ -1438,6 +1438,7 @@ void check_servers(void)
   struct server *serv;
   struct serverfd *sfd, *tmp, **up;
   int port = 0, count;
+  int locals = 0;
 
   /* interface may be new since startup */
   if (!option_bool(OPT_NOWILD))
@@ -1541,7 +1542,11 @@ void check_servers(void)
s1 = _("domain"), s2 = serv->domain;
  
  if (serv->flags & SERV_NO_ADDR)
-   my_syslog(LOG_INFO, _("using local addresses only for %s %s"), 
s1, s2);
+   {
+ count--;
+ if (++locals <= LOCALS_LOGGED)
+   my_syslog(LOG_INFO, _("using local addresses only for 
%s %s"), s1, s2);
+   }
  else if (serv->flags & SERV_USE_RESOLV)
my_syslog(LOG_INFO, _("using standard nameservers for %s %s"), 
s1, s2);
  else 
@@ -1558,6 +1563,8 @@ void check_servers(void)
}
 }
   
+  if (locals > LOCALS_LOGGED)
+my_syslog(LOG_INFO, _("using %d more local addresses"), locals - 
LOCALS_LOGGED);
   if (count - 1 > SERVERS_LOGGED)
 my_syslog(LOG_INFO, _("using %d more nameservers"), count - SERVERS_LOGGED 
- 1);
 
-- 
2.11.0


___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss