aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-07-20 10:38:00 -0400
committerNick Mathewson <nickm@torproject.org>2011-07-20 14:14:21 -0400
commit6e923ed8cdbdcf45902cb64dd921d63dea310d1d (patch)
tree2f7637d581eb2633547389eb43d3a467ca588074 /src
parent9b0d3719ae3d1e9416cffcce1267fdacfcf765e9 (diff)
downloadtor-6e923ed8cdbdcf45902cb64dd921d63dea310d1d.tar
tor-6e923ed8cdbdcf45902cb64dd921d63dea310d1d.tar.gz
Add an OptimisticData option to control client-side optimistic data
Diffstat (limited to 'src')
-rw-r--r--src/or/circuituse.c17
-rw-r--r--src/or/config.c1
-rw-r--r--src/or/or.h4
3 files changed, 21 insertions, 1 deletions
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 1bc518b7d..9fbe5fed6 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -18,6 +18,7 @@
#include "connection_edge.h"
#include "control.h"
#include "nodelist.h"
+#include "networkstatus.h"
#include "policies.h"
#include "rendclient.h"
#include "rendcommon.h"
@@ -1541,6 +1542,19 @@ cpath_is_on_circuit(origin_circuit_t *circ, crypt_path_t *crypt_path)
return 0;
}
+/** Return true iff client-side optimistic data is supported. */
+static int
+optimistic_data_enabled(void)
+{
+ const or_options_t *options = get_options();
+ if (options->OptimisticData < 0) {
+ const int32_t enabled =
+ networkstatus_get_param(NULL, "UseOptimisticData", 0, 0, 1);
+ return (int)enabled;
+ }
+ return options->OptimisticData;
+}
+
/** Attach the AP stream <b>apconn</b> to circ's linked list of
* p_streams. Also set apconn's cpath_layer to <b>cpath</b>, or to the last
* hop in circ's cpath if <b>cpath</b> is NULL.
@@ -1580,7 +1594,8 @@ link_apconn_to_circ(edge_connection_t *apconn, origin_circuit_t *circ,
apconn->cpath_layer->extend_info->identity_digest)) &&
exitnode->rs) {
/* Okay; we know what exit node this is. */
- if (circ->_base.purpose == CIRCUIT_PURPOSE_C_GENERAL &&
+ if (optimistic_data_enabled() &&
+ circ->_base.purpose == CIRCUIT_PURPOSE_C_GENERAL &&
exitnode->rs->version_supports_optimistic_data)
apconn->exit_allows_optimistic_data = 1;
else
diff --git a/src/or/config.c b/src/or/config.c
index 96d50954b..088617bb4 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -337,6 +337,7 @@ static config_var_t _option_vars[] = {
V(PerConnBWRate, MEMUNIT, "0"),
V(PidFile, STRING, NULL),
V(TestingTorNetwork, BOOL, "0"),
+ V(OptimisticData, AUTOBOOL, "auto"),
V(PortForwarding, BOOL, "0"),
V(PortForwardingHelper, FILENAME, "tor-fw-helper"),
V(PreferTunneledDirConns, BOOL, "1"),
diff --git a/src/or/or.h b/src/or/or.h
index 16c792771..c518b4cd8 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3271,6 +3271,10 @@ typedef struct {
* once. */
int MaxClientCircuitsPending;
+ /** If 1, we always send optimistic data when it's supported. If 0, we
+ * never use it. If -1, we do what the consensus says. */
+ int OptimisticData;
+
} or_options_t;
/** Persistent state for an onion router, as saved to disk. */