diff options
author | George Kadianakis <desnacked@riseup.net> | 2017-07-18 16:06:12 +0300 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-08-08 20:29:34 -0400 |
commit | 2e5a2d64bd4d26323a226d1069b960b28bd25440 (patch) | |
tree | 4482242eed9d5448e32ea69091fcc82083156edb /src/or/hs_common.c | |
parent | 6c00bd1f10f4683824deeaa7dd8a23aaf6b9a40e (diff) | |
download | tor-2e5a2d64bd4d26323a226d1069b960b28bd25440.tar.gz tor-2e5a2d64bd4d26323a226d1069b960b28bd25440.zip |
prop224: Refactor the overlap function to not use absolute time.
We consider to be in overlap mode when we are in the period of time between a
fresh SRV and the beginning of the new time period (in the normal network this
is between 00:00 and 12:00 UTC). This commit edits that function to use the
above semantic logic instead of absolute times.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_common.c')
-rw-r--r-- | src/or/hs_common.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/or/hs_common.c b/src/or/hs_common.c index 9c3d2c1711..20b470ff6c 100644 --- a/src/or/hs_common.c +++ b/src/or/hs_common.c @@ -908,7 +908,8 @@ hs_build_blinded_keypair(const ed25519_keypair_t *kp, MOCK_IMPL(int, hs_overlap_mode_is_active, (const networkstatus_t *consensus, time_t now)) { - struct tm valid_after_tm; + time_t valid_after; + time_t srv_start_time, tp_start_time; if (!consensus) { consensus = networkstatus_get_live_consensus(now); @@ -917,16 +918,18 @@ hs_overlap_mode_is_active, (const networkstatus_t *consensus, time_t now)) } } - /* XXX: Futur commits will change this to a slot system so it can be - * fine tuned better for testing networks in terms of timings. */ + /* We consider to be in overlap mode when we are in the period of time + * between a fresh SRV and the beginning of the new time period (in the + * normal network this is between 00:00 (inclusive) and 12:00 UTC + * (exclusive)) */ + valid_after = consensus->valid_after; + srv_start_time =sr_state_get_start_time_of_current_protocol_run(valid_after); + tp_start_time = hs_get_start_time_of_next_time_period(srv_start_time); - /* From the spec: "Specifically, when a hidden service fetches a consensus - * with "valid-after" between 00:00UTC and 12:00UTC, it goes into - * "descriptor overlap" mode." */ - tor_gmtime_r(&consensus->valid_after, &valid_after_tm); - if (valid_after_tm.tm_hour > 0 && valid_after_tm.tm_hour < 12) { + if (valid_after >= srv_start_time && valid_after < tp_start_time) { return 1; } + return 0; } |