diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2017-02-21 21:28:00 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-05-08 13:49:22 -0400 |
commit | d5a151a06788c28ac1c50398c6e571d484774f47 (patch) | |
tree | d2e4f2719130250e428f1991a01511c89e589a29 /src/test/test_channelpadding.c | |
parent | b0e92634d85a3bf7612a6ce0339b96e4aad1e0bb (diff) | |
download | tor-d5a151a06788c28ac1c50398c6e571d484774f47.tar.gz tor-d5a151a06788c28ac1c50398c6e571d484774f47.zip |
Bug 17592: Clean up connection timeout logic.
This unifies CircuitIdleTimeout and PredictedCircsRelevanceTime into a single
option, and randomizes it.
It also gives us control over the default value as well as relay-to-relay
connection lifespan through the consensus.
Conflicts:
src/or/circuituse.c
src/or/config.c
src/or/main.c
src/test/testing_common.c
Diffstat (limited to 'src/test/test_channelpadding.c')
-rw-r--r-- | src/test/test_channelpadding.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/test_channelpadding.c b/src/test/test_channelpadding.c index b6591eac7b..de88bb21bd 100644 --- a/src/test/test_channelpadding.c +++ b/src/test/test_channelpadding.c @@ -359,6 +359,7 @@ test_channelpadding_consensus(void *arg) * consensus defaults * 4. Relay-to-relay padding can be enabled/disabled in consensus * 5. Can enable/disable padding before actually using a connection + * 6. Can we control circ and TLS conn lifetime from the consensus? */ channel_t *chan; routerstatus_t *relay = tor_malloc_zero(sizeof(routerstatus_t)); @@ -491,6 +492,43 @@ test_channelpadding_consensus(void *arg) tt_int_op(decision, OP_EQ, CHANNELPADDING_WONTPAD); tt_assert(!chan->pending_padding_callback); + /* Test 6: Can we control circ and TLS conn lifetime from the consensus? */ + val = channelpadding_get_channel_idle_timeout(NULL, 0); + tt_int_op(val, OP_GE, 180); + tt_int_op(val, OP_LE, 180+90); + val = channelpadding_get_channel_idle_timeout(chan, 0); + tt_int_op(val, OP_GE, 180); + tt_int_op(val, OP_LE, 180+90); + options->ReducedConnectionPadding = 1; + val = channelpadding_get_channel_idle_timeout(chan, 0); + tt_int_op(val, OP_GE, 180/2); + tt_int_op(val, OP_LE, (180+90)/2); + + options->ReducedConnectionPadding = 0; + options->ORPort_set = 1; + smartlist_add(current_md_consensus->net_params, + (void*)"nf_conntimeout_relays=600"); + val = channelpadding_get_channel_idle_timeout(chan, 1); + tt_int_op(val, OP_GE, 450); + tt_int_op(val, OP_LE, 750); + + val = channelpadding_get_circuits_available_timeout(); + tt_int_op(val, OP_GE, 30*60); + tt_int_op(val, OP_LE, 30*60*2); + + options->ReducedConnectionPadding = 1; + smartlist_add(current_md_consensus->net_params, + (void*)"nf_conntimeout_clients=600"); + val = channelpadding_get_circuits_available_timeout(); + tt_int_op(val, OP_GE, 600/2); + tt_int_op(val, OP_LE, 600*2/2); + + options->ReducedConnectionPadding = 0; + options->CircuitsAvailableTimeout = 24*60*60; + val = channelpadding_get_circuits_available_timeout(); + tt_int_op(val, OP_GE, 24*60*60); + tt_int_op(val, OP_LE, 24*60*60*2); + done: free_fake_channeltls((channel_tls_t*)chan); smartlist_free(connection_array); |