diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-11-28 15:44:10 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-11-28 15:44:10 -0500 |
commit | df9b76460c38936b67ef42f5b261b39e2ec7144e (patch) | |
tree | c5a47b8120a7372e61a3284a5332dc88f7d3439e /src/or/routerlist.c | |
parent | b5a306e82c684bdd30b832fdfd9e2b55c06b54ae (diff) | |
download | tor-df9b76460c38936b67ef42f5b261b39e2ec7144e.tar.gz tor-df9b76460c38936b67ef42f5b261b39e2ec7144e.zip |
New 'DisableNetwork' option to prevent Tor from using the network
Some controllers want this so they can mess with Tor's configuration
for a while via the control port before actually letting Tor out of
the house.
We do this with a new DisableNetwork option, that prevents Tor from
making any outbound connections or binding any non-control
listeners. Additionally, it shuts down the same functionality as
shuts down when we are hibernating, plus the code that launches
directory downloads.
To make sure I didn't miss anything, I added a clause straight to
connection_connect, so that we won't even try to open an outbound
socket when the network is disabled. In my testing, I made this an
assert, but since I probably missed something, I've turned it into a
BUG warning for testing.
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r-- | src/or/routerlist.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c index d97b978f43..689df99c57 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -3244,7 +3244,7 @@ router_set_status(const char *digest, int up) log_debug(LD_DIR,"Marking router %s as %s.", node_describe(node), up ? "up" : "down"); #endif - if (!up && node_is_me(node) && !we_are_hibernating()) + if (!up && node_is_me(node) && !net_is_disabled()) log_warn(LD_NET, "We just marked ourself as down. Are your external " "addresses reachable?"); node->is_running = up; @@ -4009,6 +4009,8 @@ signed_desc_digest_is_recognized(signed_descriptor_t *desc) void update_all_descriptor_downloads(time_t now) { + if (get_options()->DisableNetwork) + return; update_router_descriptor_downloads(now); update_microdesc_downloads(now); launch_dummy_descriptor_download_as_needed(now, get_options()); @@ -4021,6 +4023,8 @@ routerlist_retry_directory_downloads(time_t now) { router_reset_status_download_failures(); router_reset_descriptor_download_failures(); + if (get_options()->DisableNetwork) + return; update_networkstatus_downloads(now); update_all_descriptor_downloads(now); } |