[or-cvs] still publish your descriptor if orport is reachable but di...
Roger Dingledine
arma at seul.org
Thu Mar 31 19:26:36 UTC 2005
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 circuituse.c main.c or.h router.c
Log Message:
still publish your descriptor if orport is reachable but dirport isn't
when building testing circs for orport testing, require high-bandwidth
nodes, so fewer circs fail. complain about unreachable orport separately
from unreachable dirport.
Index: circuitbuild.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuitbuild.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -d -r1.98 -r1.99
--- circuitbuild.c 31 Mar 2005 07:46:59 -0000 1.98
+++ circuitbuild.c 31 Mar 2005 19:26:33 -0000 1.99
@@ -467,7 +467,7 @@
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())
+ if (server_mode(options) && !check_whether_orport_reachable())
log_fn(LOG_NOTICE,"Now checking whether ORPort %s %s reachable... (this may take several minutes)",
options->DirPort ? "and DirPort" : "",
options->DirPort ? "are" : "is");
Index: circuituse.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- circuituse.c 24 Mar 2005 06:18:59 -0000 1.61
+++ circuituse.c 31 Mar 2005 19:26:33 -0000 1.62
@@ -562,7 +562,7 @@
routerinfo_t *me = router_get_my_routerinfo();
if (!at_last_hop)
- circuit_launch_by_router(CIRCUIT_PURPOSE_TESTING, me, 0, 0, 1);
+ circuit_launch_by_router(CIRCUIT_PURPOSE_TESTING, me, 0, 1, 1);
else
log_fn(LOG_INFO,"Our testing circuit (to see if your ORPort is reachable) has failed. I'll try again later.");
}
Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.478
retrieving revision 1.479
diff -u -d -r1.478 -r1.479
--- main.c 29 Mar 2005 03:48:31 -0000 1.478
+++ main.c 31 Mar 2005 19:26:33 -0000 1.479
@@ -813,14 +813,17 @@
if (server_mode(options) &&
!we_are_hibernating() &&
- !check_whether_ports_reachable() &&
stats_n_seconds_working / TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT !=
(stats_n_seconds_working+seconds_elapsed) /
TIMEOUT_UNTIL_UNREACHABILITY_COMPLAINT) {
/* every 20 minutes, check and complain if necessary */
routerinfo_t *me = router_get_my_routerinfo();
- 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 ? me->address : options->Address, options->ORPort);
+ if (!check_whether_orport_reachable())
+ log_fn(LOG_WARN,"Your server (%s:%d) has not managed to confirm that its ORPort is reachable. Please check your firewalls, ports, address, etc.",
+ me ? me->address : options->Address, options->ORPort);
+ if (!check_whether_dirport_reachable())
+ log_fn(LOG_WARN,"Your server (%s:%d) has not managed to confirm that its DirPort is reachable. Please check your firewalls, ports, address, etc.",
+ me ? me->address : options->Address, options->DirPort);
}
/* if more than 10s have elapsed, probably the clock jumped: doesn't count. */
Index: or.h
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.578
retrieving revision 1.579
diff -u -d -r1.578 -r1.579
--- or.h 28 Mar 2005 01:07:14 -0000 1.578
+++ or.h 31 Mar 2005 19:26:33 -0000 1.579
@@ -1711,7 +1711,8 @@
crypto_pk_env_t *init_key_from_file(const char *fname);
int init_keys(void);
-int check_whether_ports_reachable(void);
+int check_whether_orport_reachable(void);
+int check_whether_dirport_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.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- router.c 27 Mar 2005 11:52:15 -0000 1.161
+++ router.c 31 Mar 2005 19:26:33 -0000 1.162
@@ -381,13 +381,13 @@
/** 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;
+/** Return 1 if or port is known reachable; else return 0. */
+int check_whether_orport_reachable(void) {
+ return can_reach_or_port;
+}
+/** Return 1 if we don't have a dirport configured, or if it's reachable. */
+int check_whether_dirport_reachable(void) {
+ return !get_options()->DirPort || can_reach_dir_port;
}
void consider_testing_reachability(void) {
@@ -397,11 +397,11 @@
return;
}
- if (!can_reach_or_port) {
- circuit_launch_by_router(CIRCUIT_PURPOSE_TESTING, me, 0, 0, 1);
+ if (!check_whether_orport_reachable()) {
+ circuit_launch_by_router(CIRCUIT_PURPOSE_TESTING, me, 0, 1, 1);
}
- if (!can_reach_dir_port && me->dir_port) {
+ if (!check_whether_dirport_reachable()) {
if (me) {
directory_initiate_command_router(me, DIR_PURPOSE_FETCH_DIR, 1, NULL, NULL, 0);
} else {
@@ -410,17 +410,11 @@
}
}
-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.");
+ log_fn(LOG_NOTICE,"Your ORPort is reachable from the outside. Excellent. Publishing server descriptor.");
can_reach_or_port = 1;
- if (check_whether_ports_reachable())
- ports_now_reachable();
}
}
@@ -429,8 +423,6 @@
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();
}
}
@@ -495,7 +487,7 @@
if (options->AuthoritativeDir)
return 1;
- return check_whether_ports_reachable();
+ return check_whether_orport_reachable();
}
void consider_publishable_server(time_t now, int force) {
@@ -687,7 +679,8 @@
ri->nickname = tor_strdup(options->Nickname);
ri->addr = addr;
ri->or_port = options->ORPort;
- ri->dir_port = hibernating ? 0 : options->DirPort;
+ ri->dir_port = (hibernating || !check_whether_dirport_reachable()) ?
+ 0 : options->DirPort;
ri->published_on = time(NULL);
ri->onion_pkey = crypto_pk_dup_key(get_onion_key()); /* must invoke from main thread */
ri->identity_pkey = crypto_pk_dup_key(get_identity_key());
More information about the tor-commits
mailing list