aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2019-04-05 14:51:21 +0300
committerGeorge Kadianakis <desnacked@riseup.net>2019-04-05 14:51:21 +0300
commit747b74c1825de055bd027c9c74088efdd61d7481 (patch)
tree2b38483f2da46e5772bff124e9f76ad5710aa2d7 /src
parentd016bbaa7dfb3586c682c0070b79e174e8a73c19 (diff)
parentd194f6bedf48410132b03fdab06b679512c14db1 (diff)
downloadtor-747b74c1825de055bd027c9c74088efdd61d7481.tar.gz
tor-747b74c1825de055bd027c9c74088efdd61d7481.zip
Merge branch 'tor-github/pr/800' into maint-0.4.0
Diffstat (limited to 'src')
-rw-r--r--src/app/config/config.c1
-rw-r--r--src/app/config/or_options_st.h5
-rw-r--r--src/core/mainloop/netstatus.c4
-rw-r--r--src/test/test_mainloop.c8
4 files changed, 18 insertions, 0 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 8e0bfbe797..dc213ce2fc 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -396,6 +396,7 @@ static config_var_t option_vars_[] = {
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"),
diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h
index 06e11d3c75..bd707fd193 100644
--- a/src/app/config/or_options_st.h
+++ b/src/app/config/or_options_st.h
@@ -1092,6 +1092,11 @@ struct or_options_t {
/** 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
diff --git a/src/core/mainloop/netstatus.c b/src/core/mainloop/netstatus.c
index fc5a465ff7..4924888598 100644
--- a/src/core/mainloop/netstatus.c
+++ b/src/core/mainloop/netstatus.c
@@ -144,6 +144,10 @@ netstatus_load_from_state(const or_state_t *state, time_t now)
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);
}
diff --git a/src/test/test_mainloop.c b/src/test/test_mainloop.c
index 2c3449305a..ed6b8a9b66 100644
--- a/src/test/test_mainloop.c
+++ b/src/test/test_mainloop.c
@@ -317,6 +317,14 @@ test_mainloop_dormant_load_state(void *arg)
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);
}