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

[or-cvs] make it clearer to the human that his server is testing



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

Modified Files:
	circuitbuild.c connection.c main.c or.h router.c 
Log Message:
make it clearer to the human that his server is testing
its reachability. tell him when it succeeds, or when 20
minutes pass and it hasn't succeeded yet.


Index: circuitbuild.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuitbuild.c,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- circuitbuild.c	23 Mar 2005 06:21:47 -0000	1.93
+++ circuitbuild.c	26 Mar 2005 01:43:39 -0000	1.94
@@ -463,9 +463,14 @@
       log_fn(LOG_INFO,"circuit built!");
       circuit_reset_failure_count(0);
       if (!has_completed_circuit) {
+        or_options_t *options = get_options();
         has_completed_circuit=1;
         log_fn(LOG_NOTICE,"Tor has successfully opened a circuit. Looks like it's working.");
         /* XXX009 Log a count of known routers here */
+        if (server_mode(options) && !check_whether_ports_reachable())
+          log_fn(LOG_NOTICE,"Now checking whether ORPort %s %s reachable...",
+                 options->DirPort ? "and DirPort" : "",
+                 options->DirPort ? "are" : "is");
       }
       circuit_rep_hist_note_result(circ);
       circuit_has_opened(circ); /* do other actions as necessary */

Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.347
retrieving revision 1.348
diff -u -d -r1.347 -r1.348
--- connection.c	25 Mar 2005 11:12:14 -0000	1.347
+++ connection.c	26 Mar 2005 01:43:39 -0000	1.348
@@ -1163,7 +1163,6 @@
         connection_edge_end_errno(conn, conn->cpath_layer);
 
       connection_close_immediate(conn); /* Don't flush; connection is dead. */
-      conn->has_sent_end = 1;
       connection_mark_for_close(conn);
       return -1;
     }

Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.471
retrieving revision 1.472
diff -u -d -r1.471 -r1.472
--- main.c	25 Mar 2005 11:23:03 -0000	1.471
+++ main.c	26 Mar 2005 01:43:39 -0000	1.472
@@ -775,6 +775,7 @@
   size_t bytes_written;
   size_t bytes_read;
   int seconds_elapsed;
+  or_options_t *options = get_options();
   if (!timeout_event) {
     timeout_event = tor_malloc_zero(sizeof(struct event));
     evtimer_set(timeout_event, second_elapsed_callback, NULL);
@@ -797,7 +798,7 @@
   seconds_elapsed = current_second ? (now.tv_sec - current_second) : 0;
   stats_n_bytes_read += bytes_read;
   stats_n_bytes_written += bytes_written;
-  if (accounting_is_enabled(get_options()))
+  if (accounting_is_enabled(options))
     accounting_add_bytes(bytes_read, bytes_written, seconds_elapsed);
   control_event_bandwidth_used((uint32_t)bytes_read,(uint32_t)bytes_written);
 
@@ -805,6 +806,17 @@
   stats_prev_global_read_bucket = global_read_bucket;
   stats_prev_global_write_bucket = global_write_bucket;
 
+#define TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT (20*60) /* 20 minutes */
+  if (server_mode(options) &&
+      stats_n_seconds_working < TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT &&
+      stats_n_seconds_working+seconds_elapsed >=
+        TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT &&
+      !check_whether_ports_reachable()) {
+    routerinfo_t *me = router_get_my_routerinfo();
+    tor_assert(me);
+    log_fn(LOG_WARN,"Your server (%s:%d) has not managed to confirm that it is reachable. Please check your firewalls, ports, address, etc.", me->address, me->or_port);
+  }
+
   /* if more than 10s have elapsed, probably the clock jumped: doesn't count. */
   if (seconds_elapsed < 100)
     stats_n_seconds_working += seconds_elapsed;
@@ -932,11 +944,11 @@
       int e = errno;
       /* let the program survive things like ^z */
       if (e != EINTR) {
-        log_fn(LOG_ERR,"poll failed: %s [%d]",
+        log_fn(LOG_ERR,"event poll failed: %s [%d]",
                tor_socket_strerror(e), e);
         return -1;
       } else {
-        log_fn(LOG_DEBUG,"poll interrupted.");
+        log_fn(LOG_DEBUG,"event poll interrupted.");
         /* You can't trust the results of this poll(). Go back to the
          * top of the big for loop. */
         continue;

Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.572
retrieving revision 1.573
diff -u -d -r1.572 -r1.573
--- or.h	23 Mar 2005 19:15:10 -0000	1.572
+++ or.h	26 Mar 2005 01:43:39 -0000	1.573
@@ -1694,6 +1694,7 @@
 crypto_pk_env_t *init_key_from_file(const char *fname);
 int init_keys(void);
 
+int check_whether_ports_reachable(void);
 void consider_testing_reachability(void);
 void router_orport_found_reachable(void);
 void router_dirport_found_reachable(void);

Index: router.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -d -r1.159 -r1.160
--- router.c	22 Mar 2005 20:41:28 -0000	1.159
+++ router.c	26 Mar 2005 01:43:39 -0000	1.160
@@ -381,6 +381,15 @@
 /** Whether we can reach our DirPort from the outside. */
 static int can_reach_dir_port = 0;
 
+/** Return 1 if all open ports are known reachable; else return 0. */
+int check_whether_ports_reachable(void) {
+  if (!can_reach_or_port)
+    return 0;
+  if (get_options()->DirPort && !can_reach_dir_port)
+    return 0;
+  return 1;
+}
+
 void consider_testing_reachability(void) {
   routerinfo_t *me = router_get_my_routerinfo();
 
@@ -397,11 +406,17 @@
   }
 }
 
+static void ports_now_reachable(void) {
+  log_fn(LOG_NOTICE,"Your server is reachable. Publishing server descriptor.");
+}
+
 /** Annotate that we found our ORPort reachable. */
 void router_orport_found_reachable(void) {
   if (!can_reach_or_port) {
     log_fn(LOG_NOTICE,"Your ORPort is reachable from the outside. Excellent.");
     can_reach_or_port = 1;
+    if (check_whether_ports_reachable())
+      ports_now_reachable();
   }
 }
 
@@ -410,6 +425,8 @@
   if (!can_reach_dir_port) {
     log_fn(LOG_NOTICE,"Your DirPort is reachable from the outside. Excellent.");
     can_reach_dir_port = 1;
+    if (check_whether_ports_reachable())
+      ports_now_reachable();
   }
 }
 
@@ -474,12 +491,7 @@
   if (options->AuthoritativeDir)
     return 1;
 
-  if (!can_reach_or_port)
-    return 0;
-  if (options->DirPort && !can_reach_dir_port)
-    return 0;
-
-  return 1;
+  return check_whether_ports_reachable();
 }
 
 void consider_publishable_server(time_t now, int force) {