Bring some clarity to behavior of net_is_disabled() vs DisableNetwork vs we_are_hibernating()
We have at least three ways to say "no network for us, please": net_is_disabled()
vs options->DisableNetwork
vs we_are_hibernating()
.
Currently, net_is_disabled()
is true if either of the other is true. DisableNetwork
can be set like any other option. And we_are_hibernating()
is true if we are currently in any hibernation state other than "live and alert" -- for example, if we are entering hibernation in a little while, or if we are shutting down cleanly.
They have the following behavior:
net_is_disabled() --
- makes us not continue pending pt configuration. ##
- stops reachability tests ##
- stops retrying listeners
- stops constructing predicted circuits.
- stops uploading info about HS descriptors
- stops launching/checking port-forwarding app
- stops warning about unreachable orport/dirport
- stops us from warning if we mark ourself as down.
- means that our dirport is unreachable.
- means that our dirport shouldn't be advertised.
DisableNetwork --
- close all noncontroller stuff and note that circuits won't work, immediately, during options_act_reversible (?)
- Used to decide whether to launch ClientTransportPlugins and ServerTransportPlugins. ##
- Affects discriptor.
- Categorically prevents any outgoing socket.
- Categorically prevents any outgoing DNS resolve.
- Categorically prevents DNS testing and probing.
- Prevents any descriptor upload.
- Prevents fetching bridge descriptors.
- Stops checking for need for new descriptor.
- Stops launching upness checks
- stops testing reachability
- Stops updating ns downloads at all
- Causes dir fetches to get delayed
- Causes descriptor downloads not to get updated.
we_are_hibernating() --
- makes all create cells get destroyed.
- causes all BEGIN cells to get closed.
- makes us recommendation-ignore bootstrap problems. ##
- makes us decide that we are down, to dirserv_set_router_is_running. ##
- makes us expire unused OR connections.
- makes us suppress reachability tests.
- makes us advertise no capacity, and say that we're hibernating.
complex:
- we_are_hibernating() and DisableNetwork are used together in options_act_reversible to decide how and why to call retry_all_listeners()
These may all be correct, but we should try to make it so their function is more obvious, and there's a more clear division of what we do when.
Motivation: For #2149 (moved) we want to add yet another way for Tor to 'turn itself off'.