diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2017-06-23 18:34:41 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-09-12 10:28:45 -0400 |
commit | 6d221c8f371a0c1809552b699f1afab8cde3bd31 (patch) | |
tree | f03bda8eca62ccf13b3f0a32af1baf595865bfd0 /src/or | |
parent | 79e2e4d3cbabff41675aa1f7defb67f4acba398c (diff) | |
download | tor-6d221c8f371a0c1809552b699f1afab8cde3bd31.tar.gz tor-6d221c8f371a0c1809552b699f1afab8cde3bd31.zip |
Ticket #17857: Apply padding off-switch to existing connections.
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/channel.c | 30 | ||||
-rw-r--r-- | src/or/channelpadding.c | 26 | ||||
-rw-r--r-- | src/or/channelpadding.h | 5 |
3 files changed, 47 insertions, 14 deletions
diff --git a/src/or/channel.c b/src/or/channel.c index 8348ffd649..17b2191b77 100644 --- a/src/or/channel.c +++ b/src/or/channel.c @@ -66,6 +66,7 @@ #include "scheduler.h" #include "compat_time.h" #include "networkstatus.h" +#include "rendservice.h" /* Global lists of channels */ @@ -2712,17 +2713,26 @@ channel_do_open_actions(channel_t *chan) /* Disable or reduce padding according to user prefs. */ if (chan->padding_enabled || get_options()->ConnectionPadding == 1) { - if (!get_options()->ConnectionPadding || - (get_options()->Tor2webMode && - !networkstatus_get_param(NULL, "nf_pad_tor2web", 1, 0, 1)) - || (get_options()->HiddenServiceSingleHopMode && - !networkstatus_get_param(NULL, "nf_pad_single_onion", 1, 0, 1))) { + if (!get_options()->ConnectionPadding) { + /* Disable if torrc disabled */ channelpadding_disable_padding_on_channel(chan); - } - - /* Padding can be forced and/or reduced by clients, regardless of if - * the channel supports it */ - if (get_options()->ReducedConnectionPadding) { + } else if (get_options()->Tor2webMode && + !networkstatus_get_param(NULL, + CHANNELPADDING_TOR2WEB_PARAM, + CHANNELPADDING_TOR2WEB_DEFAULT, 0, 1)) { + /* Disable if we're using tor2web and the consensus disabled padding + * for tor2web */ + channelpadding_disable_padding_on_channel(chan); + } else if (rend_service_allow_non_anonymous_connection(get_options()) && + !networkstatus_get_param(NULL, + CHANNELPADDING_SOS_PARAM, + CHANNELPADDING_SOS_DEFAULT, 0, 1)) { + /* Disable if we're using RSOS and the consensus disabled padding + * for RSOS*/ + channelpadding_disable_padding_on_channel(chan); + } else if (get_options()->ReducedConnectionPadding) { + /* Padding can be forced and/or reduced by clients, regardless of if + * the channel supports it */ channelpadding_reduce_padding_on_channel(chan); } } diff --git a/src/or/channelpadding.c b/src/or/channelpadding.c index 9a2fdc4bbe..ee6d29f7c8 100644 --- a/src/or/channelpadding.c +++ b/src/or/channelpadding.c @@ -21,6 +21,7 @@ #include "router.h" #include "compat_time.h" #include <event2/event.h> +#include "rendservice.h" STATIC int channelpadding_get_netflow_inactive_timeout_ms(const channel_t *); STATIC int channelpadding_send_disable_command(channel_t *); @@ -136,10 +137,14 @@ channelpadding_new_consensus_params(networkstatus_t *ns) networkstatus_get_param(ns, "nf_pad_relays", 0, 0, 1); consensus_nf_pad_tor2web = - networkstatus_get_param(ns, "nf_pad_tor2web", 1, 0, 1); + networkstatus_get_param(ns, + CHANNELPADDING_TOR2WEB_PARAM, + CHANNELPADDING_TOR2WEB_DEFAULT, 0, 1); consensus_nf_pad_single_onion = - networkstatus_get_param(ns, "nf_pad_single_onion", 1, 0, 1); + networkstatus_get_param(ns, + CHANNELPADDING_SOS_PARAM, + CHANNELPADDING_SOS_DEFAULT, 0, 1); } /** @@ -717,11 +722,24 @@ channelpadding_decide_to_pad_channel(channel_t *chan) return CHANNELPADDING_WONTPAD; } - if (options->Tor2webMode && !consensus_nf_pad_tor2web) + if (options->Tor2webMode && !consensus_nf_pad_tor2web) { + /* If the consensus just changed values, this channel may still + * think padding is enabled. Negotiate it off. */ + if (chan->padding_enabled) + channelpadding_disable_padding_on_channel(chan); + return CHANNELPADDING_WONTPAD; + } + + if (rend_service_allow_non_anonymous_connection(options) && + !consensus_nf_pad_single_onion) { + /* If the consensus just changed values, this channel may still + * think padding is enabled. Negotiate it off. */ + if (chan->padding_enabled) + channelpadding_disable_padding_on_channel(chan); - if (options->HiddenServiceSingleHopMode && !consensus_nf_pad_single_onion) return CHANNELPADDING_WONTPAD; + } if (!chan->has_queued_writes(chan)) { int is_client_channel = 0; diff --git a/src/or/channelpadding.h b/src/or/channelpadding.h index 2708ee9739..a227e27d5b 100644 --- a/src/or/channelpadding.h +++ b/src/or/channelpadding.h @@ -13,6 +13,11 @@ #include "channelpadding_negotiation.h" +#define CHANNELPADDING_TOR2WEB_PARAM "nf_pad_tor2web" +#define CHANNELPADDING_TOR2WEB_DEFAULT 1 +#define CHANNELPADDING_SOS_PARAM "nf_pad_single_onion" +#define CHANNELPADDING_SOS_DEFAULT 1 + typedef enum { CHANNELPADDING_WONTPAD, CHANNELPADDING_PADLATER, |