|
@@ -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
|