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

[or-cvs] r7059: Make it possible for dns_init() to fail; note failure of eve (in tor/trunk: . src/or)



Author: nickm
Date: 2006-08-14 17:44:34 -0400 (Mon, 14 Aug 2006)
New Revision: 7059

Modified:
   tor/trunk/
   tor/trunk/src/or/dns.c
   tor/trunk/src/or/or.h
Log:
 r7046@Kushana:  nickm | 2006-08-05 13:57:04 -0400
 Make it possible for dns_init() to fail; note failure of eventdns configuratoin.



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:7045
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:7383
   + 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:7046
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:7383

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2006-08-14 21:44:29 UTC (rev 7058)
+++ tor/trunk/src/or/dns.c	2006-08-14 21:44:34 UTC (rev 7059)
@@ -105,7 +105,7 @@
 static int spawn_dnsworker(void);
 static int spawn_enough_dnsworkers(void);
 #else
-static void configure_nameservers(void);
+static int configure_nameservers(void);
 #endif
 static void _assert_cache_ok(void);
 #ifdef DEBUG_DNS_CACHE
@@ -160,15 +160,17 @@
 #endif
 
 /** Initialize the DNS subsystem; called by the OR process. */
-void
+int
 dns_init(void)
 {
   init_cache_map();
   dnsworkers_rotate();
 #ifdef USE_EVENTDNS
   if (server_mode(get_options()))
-    configure_nameservers();
+    return configure_nameservers();
+  return 0;
 #endif
+#endif
 }
 
 uint32_t
@@ -1180,7 +1182,7 @@
   return 0;
 }
 static int nameservers_configured = 0;
-static void
+static int
 configure_nameservers(void)
 {
   or_options_t *options;
@@ -1195,16 +1197,37 @@
         struct in_addr in;
         if (tor_inet_aton(ip, &in)) {
           log_info(LD_EXIT, "Adding nameserver '%s'", ip);
-          eventdns_nameserver_add(in.s_addr);
+          if (eventdns_nameserver_add(in.s_addr))
+            log_warn(LD_EXIT, "Unable to add nameserver '%s'", ip);
         }
       });
+    if (eventdns_count_nameservers() == 0) {
+      log_err(LD_EXIT, "Unable to add any configured nameserver.  "
+              "Either remove the Nameservers line from your configuration, or "
+              "put in a namerserver that we can parse.");
+      return -1;
+    }
   } else {
 #ifdef MS_WINDOWS
-    eventdns_config_windows_nameservers();
+    if (eventdns_config_windows_nameservers())
+      return -1;
+    if (eventdns_count_nameservers() == 0) {
+      log_err(LD_EXIT, "Unable to find any platform nameservers in "
+              "your Windows configuration.  Perhaps you should add a "
+              "Nameservers line to your torrc?");
+      return -1;
+    }
 #else
     log_info(LD_EXIT, "Parsing /etc/resolv.conf");
-    eventdns_resolv_conf_parse(DNS_OPTION_NAMESERVERS|DNS_OPTION_MISC,
-                               "/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_err(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
   }
   nameservers_configured = 1;

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2006-08-14 21:44:29 UTC (rev 7058)
+++ tor/trunk/src/or/or.h	2006-08-14 21:44:34 UTC (rev 7059)
@@ -2123,7 +2123,7 @@
 
 /********************************* dns.c ***************************/
 
-void dns_init(void);
+int dns_init(void);
 void dns_free_all(void);
 uint32_t dns_clip_ttl(uint32_t ttl);
 int connection_dns_finished_flushing(connection_t *conn);