Merge branch 'ticket17857_squashed' into maint-0.3.1

This commit is contained in:
Nick Mathewson
2017-09-12 10:29:00 -04:00
5 changed files with 246 additions and 25 deletions
+20 -5
View File
@@ -65,6 +65,8 @@
#include "routerlist.h"
#include "scheduler.h"
#include "compat_time.h"
#include "networkstatus.h"
#include "rendservice.h"
/* Global lists of channels */
@@ -2712,12 +2714,25 @@ 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) {
/* 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);
}
}
+34
View File
@@ -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 *);
@@ -46,6 +47,10 @@ static int consensus_nf_conntimeout_clients;
static int consensus_nf_pad_before_usage;
/** Should we pad relay-to-relay connections? */
static int consensus_nf_pad_relays;
/** Should we pad tor2web connections? */
static int consensus_nf_pad_tor2web;
/** Should we pad rosos connections? */
static int consensus_nf_pad_single_onion;
#define TOR_MSEC_PER_SEC 1000
#define TOR_USEC_PER_MSEC 1000
@@ -130,6 +135,16 @@ channelpadding_new_consensus_params(networkstatus_t *ns)
consensus_nf_pad_relays =
networkstatus_get_param(ns, "nf_pad_relays", 0, 0, 1);
consensus_nf_pad_tor2web =
networkstatus_get_param(ns,
CHANNELPADDING_TOR2WEB_PARAM,
CHANNELPADDING_TOR2WEB_DEFAULT, 0, 1);
consensus_nf_pad_single_onion =
networkstatus_get_param(ns,
CHANNELPADDING_SOS_PARAM,
CHANNELPADDING_SOS_DEFAULT, 0, 1);
}
/**
@@ -717,6 +732,25 @@ channelpadding_decide_to_pad_channel(channel_t *chan)
return CHANNELPADDING_WONTPAD;
}
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);
return CHANNELPADDING_WONTPAD;
}
if (!chan->has_queued_writes(chan)) {
int is_client_channel = 0;
+5
View File
@@ -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,