[or-cvs] touchups all over

Roger Dingledine arma at seul.org
Sun Jul 4 22:48:13 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	config.c connection.c main.c router.c routerlist.c 
Log Message:
touchups all over
put uptime in descriptor


Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- config.c	29 Jun 2004 19:46:06 -0000	1.122
+++ config.c	4 Jul 2004 22:48:11 -0000	1.123
@@ -259,8 +259,6 @@
   return 0;
 }
 
-/* XXX are there any other specifiers we want to give so making
- * a several-thousand-byte string is less painful? */
 const char default_dirservers_string[] =
 "router moria1 18.244.0.188 9001 9021 9031\n"
 "platform Tor 0.0.6rc1 on Linux moria.mit.edu i686\n"
@@ -380,15 +378,16 @@
 
 /** Set <b>options</b> to a reasonable default.
  *
- * Call this function when they're using the default torrc but
- * we can't find it. For now, we just hard-code what comes in the
- * default torrc.
+ * Call this function when we can't find any torrc config file.
  */
-static int config_assign_default(or_options_t *options) {
+static int config_assign_defaults(or_options_t *options) {
 
   /* set them up as a client only */
   options->SocksPort = 9050;
 
+  config_free_lines(options->ExitPolicy);
+  options->ExitPolicy = config_line_prepend(NULL, "ExitPolicy", "reject *:*");
+
   /* plus give them a dirservers file */
   if(config_assign_default_dirservers() < 0)
     return -1;
@@ -585,7 +584,7 @@
   if(!cf) {
     if(using_default_torrc == 1) {
       log(LOG_NOTICE, "Configuration file '%s' not present, using reasonable defaults.",fname);
-      if(config_assign_default(options) < 0)
+      if(config_assign_defaults(options) < 0)
         return -1;
     } else {
       log(LOG_WARN, "Unable to open configuration file '%s'.",fname);
@@ -631,13 +630,6 @@
     result = -1;
   }
 
-#if 0
-  if(options->ORPort && options->DataDirectory == NULL) {
-    log(LOG_WARN,"DataDirectory option required if ORPort is set, but not found.");
-    result = -1;
-  }
-#endif
-
   if (options->ORPort) {
     if (options->Nickname == NULL) {
       log_fn(LOG_WARN,"Nickname required if ORPort is set, but not found.");
@@ -676,7 +668,7 @@
     result = -1;
   }
 
-  if(options->DirPort && options->RecommendedVersions == NULL) {
+  if(options->AuthoritativeDir && options->RecommendedVersions == NULL) {
     log(LOG_WARN,"Directory servers must configure RecommendedVersions.");
     result = -1;
   }

Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.234
retrieving revision 1.235
diff -u -d -r1.234 -r1.235
--- connection.c	2 Jul 2004 23:40:03 -0000	1.234
+++ connection.c	4 Jul 2004 22:48:11 -0000	1.235
@@ -235,8 +235,9 @@
     return;
   }
   if (conn->outbuf_flushlen) {
-    log_fn(LOG_INFO,"Closing connection (fd %d, type %s, state %d) with data on outbuf.",
-           conn->s, CONN_TYPE_TO_STRING(conn->type), conn->state);
+    log_fn(LOG_INFO,"fd %d, type %s, state %d, %d bytes on outbuf.",
+           conn->s, CONN_TYPE_TO_STRING(conn->type),
+           conn->state, conn->outbuf_flushlen);
   }
   tor_close_socket(conn->s);
   conn->s = -1;

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.287
retrieving revision 1.288
diff -u -d -r1.287 -r1.288
--- main.c	30 Jun 2004 21:48:02 -0000	1.287
+++ main.c	4 Jul 2004 22:48:11 -0000	1.288
@@ -28,7 +28,7 @@
 /** How many bytes have we read since we started the process? */
 static uint64_t stats_n_bytes_read = 0;
 /** How many seconds have we been running? */
-static long stats_n_seconds_reading = 0;
+long stats_n_seconds_uptime = 0;
 
 /** Array of all open connections; each element corresponds to the element of
  * poll_array in the same position.  The first nfds elements are valid. */
@@ -536,7 +536,7 @@
 
   if(now.tv_sec > current_second) { /* the second has rolled over. check more stuff. */
 
-    ++stats_n_seconds_reading;
+    ++stats_n_seconds_uptime;
     assert_all_pending_dns_resolves_ok();
     run_scheduled_events(now.tv_sec);
     assert_all_pending_dns_resolves_ok();
@@ -844,9 +844,9 @@
            100*(((double)stats_n_data_bytes_received) /
                 (stats_n_data_cells_received*RELAY_PAYLOAD_SIZE)) );
 
-  if (stats_n_seconds_reading)
+  if (stats_n_seconds_uptime)
     log(severity,"Average bandwidth used: %d bytes/sec",
-           (int) (stats_n_bytes_read/stats_n_seconds_reading));
+           (int) (stats_n_bytes_read/stats_n_seconds_uptime));
 
   rep_hist_dump_stats(now,severity);
   rend_service_dump_stats(severity);

Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- router.c	2 Jul 2004 23:40:03 -0000	1.58
+++ router.c	4 Jul 2004 22:48:11 -0000	1.59
@@ -11,6 +11,7 @@
  **/
 
 extern or_options_t options; /* command-line and config-file options */
+extern long stats_n_seconds_uptime;
 
 /** Exposed for test.c. */ void get_platform_str(char *platform, int len);
 
@@ -474,7 +475,8 @@
  */
 void get_platform_str(char *platform, int len)
 {
-  snprintf(platform, len-1, "Tor %s on %s", VERSION, get_uname());
+  snprintf(platform, len-1, "Tor %s (up %ld sec) on %s",
+           VERSION, stats_n_seconds_uptime, get_uname());
   platform[len-1] = '\0';
   return;
 }

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- routerlist.c	4 Jul 2004 04:52:43 -0000	1.93
+++ routerlist.c	4 Jul 2004 22:48:11 -0000	1.94
@@ -124,7 +124,7 @@
       if (router->is_running)
         smartlist_add(sl,router);
       else
-        log_fn(LOG_INFO,"Nickname list includes '%s' which is known but down.",nick);
+        log_fn(LOG_WARN,"Nickname list includes '%s' which is known but down.",nick);
     } else
       log_fn(has_fetched_directory ? LOG_WARN : LOG_INFO,
              "Nickname list includes '%s' which isn't a known router.",nick);



More information about the tor-commits mailing list