]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a DormantTimeoutEnabled to disable dormant mode entirely
authorNick Mathewson <nickm@torproject.org>
Fri, 12 Mar 2021 13:40:26 +0000 (08:40 -0500)
committerDavid Goulet <dgoulet@torproject.org>
Tue, 23 Mar 2021 13:40:58 +0000 (09:40 -0400)
(If you need to do this in an older version you can just set
DormantClientTimeout to something huge.)

Closes #40228.

changes/ticket40228 [new file with mode: 0644]
doc/man/tor.1.txt
src/app/config/config.c
src/app/config/or_options_st.h
src/core/mainloop/mainloop.c
src/core/mainloop/netstatus.c
src/test/test_mainloop.c

diff --git a/changes/ticket40228 b/changes/ticket40228
new file mode 100644 (file)
index 0000000..297204d
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor features (dormant mode):
+    - Add a new 'DormantTimeoutEnabled' option to allow coarse-grained
+      control over whether the client ever becomes dormant from inactivity.
+      Most people won't need this. Closes ticket 40228.
index b57c6ec70a1b2dffe0e828b3dc5305186958dce4..bec45dee6aae27dceef76d46f141c519936ec654 100644 (file)
@@ -1888,6 +1888,12 @@ The following options control when Tor enters and leaves dormant mode:
     counts as client activity for the purpose of DormantClientTimeout.
     If false, then only network activity counts. (Default: 1)
 
+[[DormantTimeoutEnabled]] **DormantTimeoutEnabled** **0**|**1**::
+    If false, then no amount of time without activity is sufficient to
+    make Tor go dormant.  Setting this option to zero is only recommended for
+    special-purpose applications that need to use the Tor binary for
+    something other than sending or receiving Tor traffic. (Default: 1)
+
 == NODE SELECTION OPTIONS
 
 // These options are in alphabetical order, with exceptions as noted.
index fa74907b3d6ebf01bc1e26c6fa35f846615eac7d..5b36554851831b57a234cd75da27f2f6218e20fe 100644 (file)
@@ -424,8 +424,9 @@ static const config_var_t option_vars_[] = {
   OBSOLETE("DynamicDHGroups"),
   VPORT(DNSPort),
   OBSOLETE("DNSListenAddress"),
-  V(DormantClientTimeout,         INTERVAL, "24 hours"),
-  V(DormantTimeoutDisabledByIdleStreams, BOOL,     "1"),
+  V(DormantClientTimeout,        INTERVAL, "24 hours"),
+  V(DormantTimeoutEnabled,       BOOL,     "1"),
+  V(DormantTimeoutDisabledByIdleStreams,   BOOL,     "1"),
   V(DormantOnFirstStartup,       BOOL,      "0"),
   V(DormantCanceledByStartup,    BOOL,      "0"),
   /* DoS circuit creation options. */
index 4364f145ed488d6837ee86e790575af6427ad1c6..af38be585ff7131e5cdf3e23e5d2ef6f40bdc17d 100644 (file)
@@ -1065,6 +1065,13 @@ struct or_options_t {
    **/
   int DormantClientTimeout;
 
+  /**
+   * Boolean: If enabled, then we consider the timeout when deciding whether
+   * to be dormant.  If not enabled, then only the SIGNAL ACTIVE/DORMANT
+   * controls can change our status.
+   **/
+  int DormantTimeoutEnabled;
+
   /** Boolean: true if having an idle stream is sufficient to prevent a client
    * from becoming dormant.
    **/
index 77ab6f26c8b139c551a2b7e4d9866ed7a9e9ee9a..dcd88b1a86a0b06c7e1d0765480863ccb14d2541 100644 (file)
@@ -1823,6 +1823,12 @@ check_network_participation_callback(time_t now, const or_options_t *options)
     goto found_activity;
   }
 
+  /* If we aren't allowed to become dormant, then participation doesn't
+     matter */
+  if (! options->DormantTimeoutEnabled) {
+    goto found_activity;
+  }
+
   /* If we're running an onion service, we can't become dormant. */
   /* XXXX this would be nice to change, so that we can be dormant with a
    * service. */
index 7367c68219f0ed887b4fa6dd13acc7551ab38a2f..fc386c191e51bacbc12b079d8060c85fae76bfe8 100644 (file)
@@ -154,6 +154,9 @@ netstatus_load_from_state(const mainloop_state_t *state, time_t now)
     last_activity = now;
     participating_on_network = true;
   }
+  if (! get_options()->DormantTimeoutEnabled) {
+    participating_on_network = true;
+  }
   reset_user_activity(last_activity);
 }
 
index c4e60d9da570c84add0d18dcbe8bc89ee2ce8e87..a9bb714a0ff3524d0fadb01b7e504a5dd7e26178 100644 (file)
@@ -231,6 +231,8 @@ test_mainloop_check_participation(void *arg)
   const time_t start = 1542658829;
   const time_t ONE_DAY = 24*60*60;
 
+  options->DormantTimeoutEnabled = 1;
+
   // Suppose we've been idle for a day or two
   reset_user_activity(start - 2*ONE_DAY);
   set_network_participation(true);