[cvslog] [CVS] Module eggdrop1.6: Change committed

cvs at eggheads.org cvs at eggheads.org
Fri Apr 1 05:59:59 CST 2011


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.6
Commit time: 2011-04-01 11:59:59 UTC
Committer  : Rumen Stoyanov <pseudo at egg6.net>

Modified files:
     eggdrop.conf doc/Changes1.6 doc/html/mod-dns.html
     doc/settings/mod.dns src/patch.h src/mod/dns.mod/coredns.c
     src/mod/dns.mod/dns.c

Log message:

Replaced most dns.mod preprocessor definitions with config variables. Added support for user-specified dns servers and non-standard ports. Backport of the 1.8 patch.

---------------------- diff included ----------------------
Index: eggdrop1.6/doc/Changes1.6
diff -u eggdrop1.6/doc/Changes1.6:1.96 eggdrop1.6/doc/Changes1.6:1.97
--- eggdrop1.6/doc/Changes1.6:1.96	Mon Jul 12 10:18:09 2010
+++ eggdrop1.6/doc/Changes1.6	Fri Apr  1 05:59:49 2011
@@ -1,10 +1,23 @@
-$Id: Changes1.6,v 1.96 2010/07/12 16:18:09 thommey Exp $
+$Id: Changes1.6,v 1.97 2011/04/01 11:59:49 pseudo Exp $
 
 Eggdrop Changes (since version 1.6.0)
 
     _____________________________________________________________________
 
-1.6.20 (CVS):
+1.6.21 (CVS):
+
+  - Replaced most dns.mod preprocessor definitions with config variables.
+  - Added support for user-specified dns servers and non-standard ports.
+    This is most important for Cygwin 1.7, where the dns server list won't
+    get initialized under some common conditions.
+  - Added a trace to the new variable dns-servers, allowing scripts to get
+    or set the current dns server list.
+  - Added the servers list to the dns module information displayed by
+    .status all
+    Patch by: pseudo
+
+
+1.6.20 (July 23, 2010):
 
   - Add sanity check to check-stoned event. Prevents eggdrop from
     disconnecting in case of drift timers.
Index: eggdrop1.6/doc/html/mod-dns.html
diff -u eggdrop1.6/doc/html/mod-dns.html:1.22 eggdrop1.6/doc/html/mod-dns.html:1.23
--- eggdrop1.6/doc/html/mod-dns.html:1.22	Sun Feb 13 08:19:32 2011
+++ eggdrop1.6/doc/html/mod-dns.html	Fri Apr  1 05:59:49 2011
@@ -1,5 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<!-- $Id: mod-dns.html,v 1.22 2011/02/13 14:19:32 simple Exp $ -->
+<!-- $Id: mod-dns.html,v 1.23 2011/04/01 11:59:49 pseudo Exp $ -->
 
 <html>
   <head>
@@ -30,6 +30,53 @@
       dns module:</p>
 
       <p><strong>loadmodule dns</strong></p>
+
+      <p>There are also some variables you can set in your config
+      file:</p>
+    </blockquote>
+
+    <blockquote>
+      <dl>
+        <dt><strong>set dns-servers &quot;8.8.8.8 8.8.4.4&quot;</strong></dt>
+
+        <dd>
+          <p>In case your bot has trouble finding dns servers or you want to
+          use specific ones, you can set them here. The value is a list of
+          dns servers. The relative order doesn't matter. You can also
+          specify a non-standard port. <br>
+          The default is to use the system specified dns servers. You don't
+          need to modify this setting normally.</p>
+        </dd>
+
+        <dt><strong>set dns-cache 86400</strong></dt>
+
+        <dd>
+          <p>Specify how long should the DNS module cache replies at
+          maximum. The value must be in seconds. Note that it will respect
+          the TTL of the reply and this is just an upper boundary.</p>
+        </dd>
+
+        <dt><strong>set dns-negcache 600</strong></dt>
+
+        <dd>
+          <p>Specify how long should the DNS module cache negative replies
+          (NXDOMAIN, DNS Lookup failed). The value must be in seconds.</p>
+        </dd>
+
+        <dt><strong>set dns-maxsends 4</strong></dt>
+
+        <dd>
+          <p>How many times should the DNS module resend the query for a
+          given domain if it receives no reply?</p>
+        </dd>
+
+        <dt><strong>set dns-retrydelay 3</strong></dt>
+
+        <dd>
+          <p>Specify how long should the DNS module wait for a reply before
+          resending the query. The value must be in seconds.</p>
+        </dd>
+    </dl>
     </blockquote>
     <hr>
 
Index: eggdrop1.6/doc/settings/mod.dns
diff -u eggdrop1.6/doc/settings/mod.dns:1.19 eggdrop1.6/doc/settings/mod.dns:1.20
--- eggdrop1.6/doc/settings/mod.dns:1.19	Sun Feb 13 08:19:33 2011
+++ eggdrop1.6/doc/settings/mod.dns	Fri Apr  1 05:59:49 2011
@@ -1,7 +1,7 @@
-$Id: mod.dns,v 1.19 2011/02/13 14:19:33 simple Exp $
+$Id: mod.dns,v 1.20 2011/04/01 11:59:49 pseudo Exp $
 
 DNS Module
-Last revised: February 12, 2002
+Last revised: September 26, 2010
     _____________________________________________________________________
 
                                  DNS Module
@@ -18,6 +18,38 @@
 
     loadmodule dns
 
+  There are also some variables you can set in your config file:
+
+    set dns-servers "8.8.8.8 8.8.4.4"
+      In case your bot has trouble finding dns servers or you want to use
+      specific ones, you can set them here. The value is a list of dns servers.
+      The relative order doesn't matter. You can also specify a non-standard
+      port.
+      The default is to use the system specified dns servers. You don't need to
+      modify this normally.
+
+
+    set dns-cache 86400
+      Specify how long should the DNS module cache replies at maximum. The
+      value must be in seconds.
+      Note that it will respect the TTL of the reply and this is just an upper
+      boundary.
+
+
+    set dns-negcache 600
+      Specify how long should the DNS module cache negative replies (NXDOMAIN,
+      DNS Lookup failed). The value must be in seconds.
+
+
+    set dns-maxsends 4
+      How many times should the DNS module resend the query for a given domain
+      if it receives no reply?
+
+
+    set dns-retrydelay 3
+      Specify how long should the DNS module wait for a reply before resending
+      the query. The value must be in seconds.
+
     _____________________________________________________________________
 
   Copyright (C) 2000 - 2011 Eggheads Development Team
Index: eggdrop1.6/eggdrop.conf
diff -u eggdrop1.6/eggdrop.conf:1.66 eggdrop1.6/eggdrop.conf:1.67
--- eggdrop1.6/eggdrop.conf:1.66	Mon Jul  5 06:07:05 2010
+++ eggdrop1.6/eggdrop.conf	Fri Apr  1 05:59:49 2011
@@ -1,7 +1,7 @@
 #! /path/to/executable/eggdrop
 # ^- This should contain a fully qualified path to your Eggdrop executable.
 #
-# $Id: eggdrop.conf,v 1.66 2010/07/05 12:07:05 pseudo Exp $
+# $Id: eggdrop.conf,v 1.67 2011/04/01 11:59:49 pseudo Exp $
 #
 # This is a sample Eggdrop configuration file which includes all possible
 # settings that can be used to configure your bot.
@@ -464,6 +464,30 @@
 # resolve, which will often let it timeout on all other connections.
 loadmodule dns
 
+# In case your bot has trouble finding dns servers or you want to use
+# specific ones, you can set them here. The value is a list of dns servers.
+# The order doesn't matter. You can also specify a non-standard port.
+# The default is to use the system specified dns servers. You don't need to
+# modify this setting normally.
+#set dns-servers "8.8.8.8 8.8.4.4"
+
+# Specify how long should the DNS module cache replies at maximum. The value
+# must be in seconds.
+# Note that it will respect the TTL of the reply and this is just an upper
+# boundary.
+set dns-cache 86400
+
+# Specify how long should the DNS module cache negative replies (NXDOMAIN,
+# DNS Lookup failed). The value must be in seconds.
+set dns-negcache 600
+
+# How many times should the DNS module resend the query for a given domain
+# if it receives no reply?
+set dns-maxsends 4
+
+# Specify how long should the DNS module wait for a reply before resending the
+# query. The value must be in seconds.
+set dns-retrydelay 3
 
 #### CHANNELS MODULE ####
 
Index: eggdrop1.6/src/mod/dns.mod/coredns.c
diff -u eggdrop1.6/src/mod/dns.mod/coredns.c:1.36 eggdrop1.6/src/mod/dns.mod/coredns.c:1.37
--- eggdrop1.6/src/mod/dns.mod/coredns.c:1.36	Sun Feb 13 08:19:33 2011
+++ eggdrop1.6/src/mod/dns.mod/coredns.c	Fri Apr  1 05:59:49 2011
@@ -5,7 +5,7 @@
  *
  * Modified/written by Fabian Knittel <fknittel at gmx.de>
  *
- * $Id: coredns.c,v 1.36 2011/02/13 14:19:33 simple Exp $
+ * $Id: coredns.c,v 1.37 2011/04/01 11:59:49 pseudo Exp $
  */
 /*
  * Portions Copyright (C) 1999 - 2011 Eggheads Development Team
@@ -47,10 +47,6 @@
 
 #define BASH_SIZE        8192   /* Size of hash tables */
 #define HOSTNAMELEN       255   /* From RFC */
-#define RES_RETRYDELAY      3
-#define RES_MAXSENDS        4
-#define RES_FAILEDDELAY   600   /* TTL for failed records (in seconds). */
-#define RES_MAX_TTL     86400   /* Maximum TTL (in seconds). */
 
 #define RES_ERR "DNS Resolver error: "
 #define RES_MSG "DNS Resolver: "
@@ -595,7 +591,7 @@
 {
   rp->sends++;
   /* Update expire time */
-  rp->expiretime = now + (RES_RETRYDELAY * rp->sends);
+  rp->expiretime = now + (dns_retrydelay * rp->sends);
   /* Add (back) to expire list */
   linkresolve(rp);
 
@@ -634,7 +630,7 @@
 {
   if (rp->state == STATE_FINISHED)
     return;
-  rp->expiretime = now + RES_FAILEDDELAY;
+  rp->expiretime = now + dns_negcache;
   rp->state = STATE_FAILED;
 
   /* Expire time was changed, reinsert entry to maintain order */
@@ -653,10 +649,10 @@
   rp->state = STATE_FINISHED;
 
   /* Do not cache entries for too long. */
-  if (ttl < RES_MAX_TTL)
+  if (ttl < dns_cache)
     rp->expiretime = now + (time_t) ttl;
   else
-    rp->expiretime = now + RES_MAX_TTL;
+    rp->expiretime = now + dns_cache;
 
   /* Expire time was changed, reinsert entry to maintain order */
   untieresolve(rp);
@@ -976,7 +972,7 @@
       unlinkresolve(rp);
       break;
     case STATE_PTRREQ:         /* T_PTR send timed out */
-      if (rp->sends <= RES_MAXSENDS) {
+      if (rp->sends <= dns_maxsends) {
         ddebug1(RES_MSG "Resend #%d for \"PTR\" query...", rp->sends - 1);
         resendrequest(rp, T_PTR);
       } else {
@@ -985,7 +981,7 @@
       }
       break;
     case STATE_AREQ:           /* T_A send timed out */
-      if (rp->sends <= RES_MAXSENDS) {
+      if (rp->sends <= dns_maxsends) {
         ddebug1(RES_MSG "Resend #%d for \"A\" query...", rp->sends - 1);
         resendrequest(rp, T_A);
       } else {
@@ -1110,10 +1106,8 @@
 
   /* Initialise the resolv library. */
   res_init();
-  if (!_res.nscount) {
-    putlog(LOG_MISC, "*", "No nameservers defined.");
-    return 0;
-  }
+  if (!_res.nscount)
+    putlog(LOG_MISC, "*", "No nameservers found.");
   _res.options |= RES_RECURSE | RES_DEFNAMES | RES_DNSRCH;
   for (i = 0; i < _res.nscount; i++)
     _res.nsaddr_list[i].sin_family = AF_INET;
Index: eggdrop1.6/src/mod/dns.mod/dns.c
diff -u eggdrop1.6/src/mod/dns.mod/dns.c:1.41 eggdrop1.6/src/mod/dns.mod/dns.c:1.42
--- eggdrop1.6/src/mod/dns.mod/dns.c:1.41	Sun Feb 13 08:19:33 2011
+++ eggdrop1.6/src/mod/dns.mod/dns.c	Fri Apr  1 05:59:49 2011
@@ -4,7 +4,7 @@
  *
  * Written by Fabian Knittel <fknittel at gmx.de>
  *
- * $Id: dns.c,v 1.41 2011/02/13 14:19:33 simple Exp $
+ * $Id: dns.c,v 1.42 2011/04/01 11:59:49 pseudo Exp $
  */
 /*
  * Copyright (C) 1999 - 2011 Eggheads Development Team
@@ -34,6 +34,13 @@
 
 static Function *global = NULL;
 
+static int dns_maxsends = 4;
+static int dns_retrydelay = 3;
+static int dns_cache = 86400;
+static int dns_negcache = 600;
+
+static char dns_servers[121] = "";
+
 #include "coredns.c"
 
 
@@ -115,6 +122,66 @@
   NULL
 };
 
+static tcl_ints dnsints[] = {
+  {"dns-maxsends",   &dns_maxsends,   0},
+  {"dns-retrydelay", &dns_retrydelay, 0},
+  {"dns-cache",      &dns_cache,      0},
+  {"dns-negcache",   &dns_negcache,   0},
+  {NULL,             NULL,            0}
+};
+
+static tcl_strings dnsstrings[] = {
+  {"dns-servers", dns_servers, 120,           0},
+  {NULL,          NULL,          0,           0}
+};
+
+static char *dns_change(ClientData cdata, Tcl_Interp *irp,
+                           EGG_CONST char *name1,
+                           EGG_CONST char *name2, int flags)
+{
+  char buf[121], *p;
+  unsigned short port;
+  int i, lc, code;
+  EGG_CONST char **list, *slist;
+
+  if (flags & (TCL_TRACE_READS | TCL_TRACE_UNSETS)) {
+    Tcl_DString ds;
+    
+    Tcl_DStringInit(&ds);
+    for (i = 0; i < _res.nscount; i++) {
+      snprintf(buf, sizeof buf, "%s:%d", iptostr((struct sockaddr *)
+               &_res.nsaddr_list[i]), ntohs(_res.nsaddr_list[i].sin_port));
+      Tcl_DStringAppendElement(&ds, buf);
+    }
+    slist = Tcl_DStringValue(&ds);
+    Tcl_SetVar2(interp, name1, name2, slist, TCL_GLOBAL_ONLY);
+    Tcl_DStringFree(&ds);
+  } else { /* TCL_TRACE_WRITES */
+    slist = Tcl_GetVar2(interp, name1, name2, TCL_GLOBAL_ONLY);
+    code = Tcl_SplitList(interp, slist, &lc, &list);
+    if (code == TCL_ERROR)
+      return "variable must be a list";
+    /* reinitialize the list */
+    _res.nscount = 0;
+    for (i = 0; i < lc; i++) {
+      if ((p = strchr(list[i], ':'))) {
+        *p++ = 0;
+        /* allow non-standard ports */
+        port = atoi(p);
+      } else
+        port = NAMESERVER_PORT; /* port 53 */
+      /* Ignore invalid addresses */
+      if (egg_inet_aton(list[i], &_res.nsaddr_list[_res.nscount].sin_addr)) {
+        _res.nsaddr_list[_res.nscount].sin_port = htons(port);
+        _res.nsaddr_list[_res.nscount].sin_family = AF_INET;
+        _res.nscount++;
+      }
+    }
+    Tcl_Free((char *) list);
+  }
+  return NULL;
+}
+
 
 /*
  *    DNS module related code
@@ -154,9 +221,14 @@
 static int dns_report(int idx, int details)
 {
   if (details) {
-    int size = dns_expmem();
+    int i, size = dns_expmem();
 
     dprintf(idx, "    Async DNS resolver is active.\n");
+    dprintf(idx, "    DNS server list:");
+    for (i = 0; i < _res.nscount; i++)
+      dprintf(idx, " %s:%d", iptostr((struct sockaddr *) &_res.nsaddr_list[i]),
+              ntohs(_res.nsaddr_list[i].sin_port));
+    dprintf(idx, "\n");
     dprintf(idx, "    Using %d byte%s of memory\n", size,
             (size != 1) ? "s" : "");
   }
@@ -170,6 +242,11 @@
   del_hook(HOOK_DNS_HOSTBYIP, (Function) dns_lookup);
   del_hook(HOOK_DNS_IPBYHOST, (Function) dns_forward);
   del_hook(HOOK_SECONDLY, (Function) dns_check_expires);
+  rem_tcl_ints(dnsints);
+  rem_tcl_strings(dnsstrings);
+  Tcl_UntraceVar(interp, "dns-servers",
+                 TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
+                 dns_change, NULL);
 
   for (i = 0; i < dcc_total; i++) {
     if (dcc[i].type == &DCC_DNS && dcc[i].sock == resfd) {
@@ -218,8 +295,13 @@
   dcc[idx].timeval = now;
   strcpy(dcc[idx].nick, "(dns)");
 
+  Tcl_TraceVar(interp, "dns-servers",
+               TCL_TRACE_READS | TCL_TRACE_WRITES | TCL_TRACE_UNSETS,
+               dns_change, NULL);
   add_hook(HOOK_SECONDLY, (Function) dns_check_expires);
   add_hook(HOOK_DNS_HOSTBYIP, (Function) dns_lookup);
   add_hook(HOOK_DNS_IPBYHOST, (Function) dns_forward);
+  add_tcl_ints(dnsints);
+  add_tcl_strings(dnsstrings);
   return NULL;
 }
Index: eggdrop1.6/src/patch.h
diff -u eggdrop1.6/src/patch.h:1.1257 eggdrop1.6/src/patch.h:1.1258
--- eggdrop1.6/src/patch.h:1.1257	Sun Feb 13 08:19:33 2011
+++ eggdrop1.6/src/patch.h	Fri Apr  1 05:59:49 2011
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  *
- * $Id: patch.h,v 1.1257 2011/02/13 14:19:33 simple Exp $
+ * $Id: patch.h,v 1.1258 2011/04/01 11:59:49 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("1278951196");            /* current unixtime */
+patch("1301658548");            /* current unixtime */
 /*
  *
  *
  */
-patch("driftstoned");
+patch("dnssettings");
 /*
  *
  *
----------------------- End of diff -----------------------


More information about the Changes mailing list