Closes ticket 29357, and comes with appropriate notions of caution.
--- /dev/null
+ o Minor features (dormant mode):
+ - Add a DormantCanceledByStartup option to tell Tor that it should
+ treat a startup event as cancelling any previous dormant state.
+ Integrators should use this option with caution: it should
+ only be used if Tor is being started because of something that the
+ user did, and not if Tor is being automatically started in the
+ background. Closes ticket 29357.
After the first time Tor starts, it begins in dormant mode if it was
dormant before, and not otherwise. (Default: 0)
+[[DormantCanceledByStartup]] **DormantCanceledByStartup** **0**|**1**::
+ By default, Tor starts in active mode if it was active the last time
+ it was shut down, and in dormant mode if it was dormant. But if
+ this option is true, Tor treats every startup event as user
+ activity, and Tor will never start in Dormant mode, even if it has
+ been unused for a long time on previous runs. (Default: 0)
+ +
+ Note: Packagers and application developers should change the value of
+ this option only with great caution: it has the potential to
+ create spurious traffic on the network. This option should only
+ be used if Tor is started by an affirmative user activity (like
+ clicking on an applcation or running a command), and not if Tor
+ is launched for some other reason (for example, by a startup
+ process, or by an application that launches itself on every login.)
+
SERVER OPTIONS
--------------
V(DormantClientTimeout, INTERVAL, "24 hours"),
V(DormantTimeoutDisabledByIdleStreams, BOOL, "1"),
V(DormantOnFirstStartup, BOOL, "0"),
+ V(DormantCanceledByStartup, BOOL, "0"),
/* DoS circuit creation options. */
V(DoSCircuitCreationEnabled, AUTOBOOL, "auto"),
V(DoSCircuitCreationMinConnections, UINT, "0"),
/** Boolean: true if Tor should be dormant the first time it starts with
* a datadirectory; false otherwise. */
int DormantOnFirstStartup;
+ /**
+ * Boolean: true if Tor should treat every startup event as cancelling
+ * a possible previous dormant state.
+ **/
+ int DormantCanceledByStartup;
};
#endif
last_activity = now - 60 * state->MinutesSinceUserActivity;
participating_on_network = true;
}
+ if (get_options()->DormantCanceledByStartup) {
+ last_activity = now;
+ participating_on_network = true;
+ }
reset_user_activity(last_activity);
}
tt_assert(is_participating_on_network());
tt_i64_op(get_last_user_activity_time(), OP_EQ, start - 123*60);
+ // If we would start dormant, but DormantCanceledByStartup is set, then
+ // we start up non-dormant.
+ state->Dormant = 1;
+ get_options_mutable()->DormantCanceledByStartup = 1;
+ netstatus_load_from_state(state, start);
+ tt_assert(is_participating_on_network());
+ tt_i64_op(get_last_user_activity_time(), OP_EQ, start);
+
done:
or_state_free(state);
}