[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r8254: Change configuration strategy for eventdns. Instead of elabo (in tor/trunk: . doc src/or)



Author: nickm
Date: 2006-08-27 23:15:50 -0400 (Sun, 27 Aug 2006)
New Revision: 8254

Modified:
   tor/trunk/
   tor/trunk/doc/TODO
   tor/trunk/src/or/config.c
   tor/trunk/src/or/dns.c
   tor/trunk/src/or/or.h
Log:
 r8607@Kushana:  nickm | 2006-08-27 15:45:42 -0400
 Change configuration strategy for eventdns. Instead of elaborate option set, just allow the user to specify another resolv.conf to use.



Property changes on: tor/trunk
___________________________________________________________________
Name: svk:merge
   - 17f730b7-d419-0410-b50f-85ee4b70197a:/local/or/tor/trunk:8290
1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
96637b51-b116-0410-a10e-9941ebb49b64:/tor/branches/spec:7005
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:8606
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7030
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/trans-ap:7315
c95137ef-5f19-0410-b913-86e773d04f59:/tor/trunk:8576
   + 17f730b7-d419-0410-b50f-85ee4b70197a:/local/or/tor/trunk:8290
1f724f9b-111a-0410-b636-93f1a77c1813:/local/or/tor/trunk:8207
96637b51-b116-0410-a10e-9941ebb49b64:/tor/branches/spec:7005
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/eventdns:8607
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/mmap:7030
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6950
c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/trans-ap:7315
c95137ef-5f19-0410-b913-86e773d04f59:/tor/trunk:8576

Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO	2006-08-28 03:15:47 UTC (rev 8253)
+++ tor/trunk/doc/TODO	2006-08-28 03:15:50 UTC (rev 8254)
@@ -96,10 +96,12 @@
         o Implement
         . Enable
         - Test
-      - Make the Nameservers option documented, and make it work right on
+      X Make the Nameservers option documented, and make it work right on
         reload.
       o Fail when we have no configured nameservers!
       o Make it the default on platforms where it works.
+      - Make resolv.conf (or local equivalent) get checked on reload,
+        settable while running, etc.
       - Add ipv6 support; make API closer to getaddrinfo().  (i.e., allow a
         single AAAA/A query, return cname as well)
       - Teach it to be able to listen for A and PTR requests to be processed.

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2006-08-28 03:15:47 UTC (rev 8253)
+++ tor/trunk/src/or/config.c	2006-08-28 03:15:50 UTC (rev 8254)
@@ -188,7 +188,6 @@
   OBSOLETE("MonthlyAccountingStart"),
   VAR("MyFamily",            STRING,   MyFamily,             NULL),
   VAR("NewCircuitPeriod",    INTERVAL, NewCircuitPeriod,     "30 seconds"),
-  VAR("Nameservers",         CSV,      Nameservers,          ""),
   VAR("NamingAuthoritativeDirectory",BOOL, NamingAuthoritativeDir, "0"),
   VAR("Nickname",            STRING,   Nickname,             NULL),
   VAR("NoPublish",           BOOL,     NoPublish,            "0"),
@@ -216,11 +215,13 @@
   VAR("RendNodes",           STRING,   RendNodes,            NULL),
   VAR("RendPostPeriod",      INTERVAL, RendPostPeriod,       "1 hour"),
   VAR("RephistTrackTime",    INTERVAL, RephistTrackTime,     "24 hours"),
+  VAR("ResolvConf",          STRING,   ResolvConf,           NULL),
   OBSOLETE("RouterFile"),
   VAR("RunAsDaemon",         BOOL,     RunAsDaemon,          "0"),
   VAR("RunTesting",          BOOL,     RunTesting,           "0"),
   VAR("SafeLogging",         BOOL,     SafeLogging,          "1"),
   VAR("SafeSocks",           BOOL,     SafeSocks,            "0"),
+  VAR("SearchDomains",       BOOL,     SearchDomains,        "0"),
   VAR("ShutdownWaitLength",  INTERVAL, ShutdownWaitLength,   "30 seconds"),
   VAR("SocksListenAddress",  LINELIST, SocksListenAddress,   NULL),
   VAR("SocksPolicy",         LINELIST, SocksPolicy,          NULL),
@@ -1982,7 +1983,9 @@
   return 0;
 }
 
-/* Return 0 if every element of sl is a string holding an IP address, or if sl
+#if 0
+/* XXXX Unused. */
+/** Return 0 if every element of sl is a string holding an IP address, or if sl
  * is NULL.  Otherwise set *msg and return -1. */
 static int
 validate_ips_csv(smartlist_t *sl, const char *name, char **msg)
@@ -2005,6 +2008,7 @@
   });
   return 0;
 }
+#endif
 
 /** Lowest allowable value for RendPostPeriod; if this is too low, hidden
  * services can overload the directory system. */
@@ -2239,9 +2243,6 @@
   if (validate_ports_csv(options->LongLivedPorts, "LongLivedPorts", msg) < 0)
     return -1;
 
-  if (validate_ips_csv(options->Nameservers, "Nameservers", msg) < 0)
-    return -1;
-
   if (options->FascistFirewall && !options->ReachableAddresses) {
     if (options->FirewallPorts && smartlist_len(options->FirewallPorts)) {
       /* We already have firewall ports set, so migrate them to

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2006-08-28 03:15:47 UTC (rev 8253)
+++ tor/trunk/src/or/dns.c	2006-08-28 03:15:50 UTC (rev 8254)
@@ -952,6 +952,7 @@
   int *fdarray = data;
   int fd;
   int result;
+  int search = get_options()->SearchDomains;
 
   /* log_fn(LOG_NOTICE,"After spawn: fdarray @%d has %d:%d", (int)fdarray,
    * fdarray[0],fdarray[1]); */
@@ -990,7 +991,7 @@
       spawn_exit();
     }
     /* Add a period to prevent local domain search, and NUL-terminate. */
-    if (address[address_len-1] != '.') {
+    if (address[address_len-1] != '.' && !search) {
       address[address_len] = '.';
       address[address_len+1] = '\0';
     } else {
@@ -1193,50 +1194,40 @@
 configure_nameservers(void)
 {
   or_options_t *options;
+  const char *conf_fname;
+  struct stat st;
   if (nameservers_configured)
     return 0;
   options = get_options();
   eventdns_set_log_fn(eventdns_log_cb);
-  if (options->Nameservers && smartlist_len(options->Nameservers)) {
-    log_info(LD_EXIT, "Configuring nameservers from Tor configuration");
-    SMARTLIST_FOREACH(options->Nameservers, const char *, ip,
-      {
-        struct in_addr in;
-        if (tor_inet_aton(ip, &in)) {
-          log_info(LD_EXIT, "Adding nameserver '%s'", ip);
-          if (eventdns_nameserver_add(in.s_addr))
-            log_warn(LD_EXIT, "Unable to add nameserver '%s'", ip);
-        }
-      });
+
+  conf_fname = options->ResolvConf;
+#ifndef MS_WINDOWS
+  if (!conf_fname) conf_fname = "/etc/resolv.conf";
+#endif
+
+  if (conf_fname) {
+    log_info(LD_EXIT, "Parsing resolver configuration in '%s'", conf_fname);
+    if (eventdns_resolv_conf_parse(DNS_OPTIONS_ALL, conf_fname))
+      return -1;
     if (eventdns_count_nameservers() == 0) {
-      log_warn(LD_EXIT, "Unable to add any configured nameserver. "
-               "Either remove the Nameservers line from your configuration, "
-               "or put in a nameserver that we can parse.");
+      log_warn(LD_EXIT, "Unable to find any nameservers in '%s'.", conf_fname);
       return -1;
     }
-  } else {
+  }
 #ifdef MS_WINDOWS
+  else {
     if (eventdns_config_windows_nameservers())
       return -1;
     if (eventdns_count_nameservers() == 0) {
       log_warn(LD_EXIT, "Unable to find any platform nameservers in "
-               "your Windows configuration.  Perhaps you should add a "
-               "Nameservers line to your torrc?");
+               "your Windows configuration.  Perhaps you should list a "
+               "ResolvConf file in your torrc?");
       return -1;
     }
-#else
-    log_info(LD_EXIT, "Parsing /etc/resolv.conf");
-    if (eventdns_resolv_conf_parse(DNS_OPTION_NAMESERVERS|DNS_OPTION_MISC,
-                                   "/etc/resolv.conf"))
-      return -1;
-    if (eventdns_count_nameservers() == 0) {
-      log_warn(LD_EXIT, "Unable to find any platform nameservers in "
-               "/etc/resolv.conf.  Perhaps you should add a Nameservers line "
-               "to your torrc?");
-      return -1;
-    }
-#endif
   }
+#endif
+
   nameservers_configured = 1;
   return 0;
 }
@@ -1282,12 +1273,13 @@
 {
   char *addr = tor_strdup(exitconn->_base.address);
   int r;
+  int options = get_options()->SearchDomains ? 0 : DNS_QUERY_NO_SEARCH;
   if (!nameservers_configured)
     if (configure_nameservers() < 0)
       return -1;
   log_info(LD_EXIT, "Launching eventdns request for %s",
            escaped_safe_str(exitconn->_base.address));
-  r = eventdns_resolve_ipv4(exitconn->_base.address, DNS_QUERY_NO_SEARCH,
+  r = eventdns_resolve_ipv4(exitconn->_base.address, options,
                             eventdns_callback, addr);
   if (r) {
     log_warn(LD_EXIT, "eventdns rejected address %s: error %d.",

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2006-08-28 03:15:47 UTC (rev 8253)
+++ tor/trunk/src/or/or.h	2006-08-28 03:15:50 UTC (rev 8254)
@@ -1556,8 +1556,12 @@
 
   char *VirtualAddrNetwork; /**< Address and mask to hand out for virtual
                              * MAPADDRESS requests. */
-  smartlist_t *Nameservers; /**< If provided, overrides the platform nameserver
-                             * list. when using eventdns. */
+  int SearchDomains; /**< If provided, we don't force exit addresses to be
+                      * fqdns, but rather search for them in the local
+                      * domains. */
+  char *ResolvConf; /**< If provided, we configure our internal resolver from
+                     * the file here rather than from /etc/resolv.conf (unix)
+                     * or the registry (windows) */
 } or_options_t;
 
 /** Persistent state for an onion router, as saved to disk. */