|
@@ -611,6 +611,10 @@ relay_send_command_from_edge_,(streamid_t stream_id, circuit_t *circ,
|
|
|
tor_free(commands);
|
|
|
smartlist_free(commands_list);
|
|
|
}
|
|
|
+
|
|
|
+ /* Let's assume we're well-behaved: Anything that we decide to send is
|
|
|
+ * valid, delivered data. */
|
|
|
+ circuit_sent_valid_data(origin_circ, rh.length);
|
|
|
}
|
|
|
|
|
|
if (circuit_package_relay_cell(&cell, circ, cell_direction, cpath_layer,
|
|
@@ -740,6 +744,9 @@ connection_ap_process_end_not_open(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /* This end cell is now valid. */
|
|
|
+ circuit_read_valid_data(circ, rh->length);
|
|
|
+
|
|
|
if (rh->length == 0) {
|
|
|
reason = END_STREAM_REASON_MISC;
|
|
|
}
|
|
@@ -1230,6 +1237,12 @@ connection_edge_process_resolved_cell(edge_connection_t *conn,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /* This is valid data at this point. Count it */
|
|
|
+ if (conn->on_circuit && CIRCUIT_IS_ORIGIN(conn->on_circuit)) {
|
|
|
+ circuit_read_valid_data(TO_ORIGIN_CIRCUIT(conn->on_circuit),
|
|
|
+ rh->length);
|
|
|
+ }
|
|
|
+
|
|
|
connection_ap_handshake_socks_got_resolved_cell(entry_conn,
|
|
|
errcode,
|
|
|
resolved_addresses);
|
|
@@ -1326,6 +1339,9 @@ connection_edge_process_relay_cell_not_open(
|
|
|
entry_conn->chosen_exit_name, ttl);
|
|
|
|
|
|
remap_event_helper(entry_conn, &addr);
|
|
|
+
|
|
|
+ /* This is valid data at this point. Count it */
|
|
|
+ circuit_read_valid_data(TO_ORIGIN_CIRCUIT(circ), rh->length);
|
|
|
}
|
|
|
circuit_log_path(LOG_INFO,LD_APP,TO_ORIGIN_CIRCUIT(circ));
|
|
|
/* don't send a socks reply to transparent conns */
|
|
@@ -1496,7 +1512,6 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
|
|
|
circ->dirreq_id = ++next_id;
|
|
|
TO_OR_CIRCUIT(circ)->p_chan->dirreq_id = circ->dirreq_id;
|
|
|
}
|
|
|
-
|
|
|
return connection_exit_begin_conn(cell, circ);
|
|
|
case RELAY_COMMAND_DATA:
|
|
|
++stats_n_data_cells_received;
|
|
@@ -1532,6 +1547,10 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
|
|
|
"(relay data) conn deliver_window below 0. Killing.");
|
|
|
return -END_CIRC_REASON_TORPROTOCOL;
|
|
|
}
|
|
|
+ /* Total all valid application bytes delivered */
|
|
|
+ if (CIRCUIT_IS_ORIGIN(circ)) {
|
|
|
+ circuit_read_valid_data(TO_ORIGIN_CIRCUIT(circ), rh.length);
|
|
|
+ }
|
|
|
|
|
|
stats_n_data_bytes_received += rh.length;
|
|
|
connection_buf_add((char*)(cell->payload + RELAY_HEADER_SIZE),
|
|
@@ -1584,6 +1603,11 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
|
|
|
/* only mark it if not already marked. it's possible to
|
|
|
* get the 'end' right around when the client hangs up on us. */
|
|
|
connection_mark_and_flush(TO_CONN(conn));
|
|
|
+
|
|
|
+ /* Total all valid application bytes delivered */
|
|
|
+ if (CIRCUIT_IS_ORIGIN(circ)) {
|
|
|
+ circuit_read_valid_data(TO_ORIGIN_CIRCUIT(circ), rh.length);
|
|
|
+ }
|
|
|
}
|
|
|
return 0;
|
|
|
case RELAY_COMMAND_EXTEND:
|
|
@@ -1649,6 +1673,10 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
|
|
|
log_info(domain,"circuit_send_next_onion_skin() failed.");
|
|
|
return reason;
|
|
|
}
|
|
|
+ /* Total all valid bytes delivered. */
|
|
|
+ if (CIRCUIT_IS_ORIGIN(circ)) {
|
|
|
+ circuit_read_valid_data(TO_ORIGIN_CIRCUIT(circ), rh.length);
|
|
|
+ }
|
|
|
return 0;
|
|
|
case RELAY_COMMAND_TRUNCATE:
|
|
|
if (layer_hint) {
|
|
@@ -1714,6 +1742,16 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
|
|
|
log_debug(LD_APP,"circ-level sendme at origin, packagewindow %d.",
|
|
|
layer_hint->package_window);
|
|
|
circuit_resume_edge_reading(circ, layer_hint);
|
|
|
+
|
|
|
+ /* We count circuit-level sendme's as valid delivered data because
|
|
|
+ * they are rate limited. Note that we cannot count stream
|
|
|
+ * sendme's because the other end could send as many as they like.
|
|
|
+ */
|
|
|
+ if (CIRCUIT_IS_ORIGIN(circ)) {
|
|
|
+ circuit_read_valid_data(TO_ORIGIN_CIRCUIT(circ),
|
|
|
+ rh.length);
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
if (circ->package_window + CIRCWINDOW_INCREMENT >
|
|
|
CIRCWINDOW_START_MAX) {
|