mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
r12565@catbus: nickm | 2007-04-30 10:09:07 -0400
Misc cleanup and bulletproofing on r10056. svn:r10058
This commit is contained in:
parent
420df2ce15
commit
43385b9bc9
@ -535,7 +535,7 @@ $Id$
|
|||||||
3.13. ATTACHSTREAM
|
3.13. ATTACHSTREAM
|
||||||
|
|
||||||
Sent from the client to the server. The syntax is:
|
Sent from the client to the server. The syntax is:
|
||||||
"ATTACHSTREAM" SP StreamID SP CircuitID ["HOP=" HopNum] CRLF
|
"ATTACHSTREAM" SP StreamID SP CircuitID [SP "HOP=" HopNum] CRLF
|
||||||
|
|
||||||
This message informs the server that the specified stream should be
|
This message informs the server that the specified stream should be
|
||||||
associated with the specified circuit. Each stream may be associated with
|
associated with the specified circuit. Each stream may be associated with
|
||||||
@ -549,6 +549,7 @@ $Id$
|
|||||||
|
|
||||||
If HOP=HopNum is specified, Tor will choose the HopNumth hop in the
|
If HOP=HopNum is specified, Tor will choose the HopNumth hop in the
|
||||||
circuit as the exit node, rather than the last node in the circuit.
|
circuit as the exit node, rather than the last node in the circuit.
|
||||||
|
Hops are 1-indexed; generally, it is not permitted to attach to hop 1.
|
||||||
|
|
||||||
Tor responds with "250 OK" if it can attach the stream, 552 if the circuit
|
Tor responds with "250 OK" if it can attach the stream, 552 if the circuit
|
||||||
or stream didn't exist, or 551 if the stream couldn't be attached for
|
or stream didn't exist, or 551 if the stream couldn't be attached for
|
||||||
|
@ -849,7 +849,7 @@ circuit_get_cpath_len(origin_circuit_t *circ)
|
|||||||
crypt_path_t *
|
crypt_path_t *
|
||||||
circuit_get_cpath_hop(origin_circuit_t *circ, int hopnum)
|
circuit_get_cpath_hop(origin_circuit_t *circ, int hopnum)
|
||||||
{
|
{
|
||||||
if (circ && circ->cpath) {
|
if (circ && circ->cpath && hopnum > 0) {
|
||||||
crypt_path_t *cpath, *cpath_next = NULL;
|
crypt_path_t *cpath, *cpath_next = NULL;
|
||||||
for (cpath = circ->cpath; cpath_next != circ->cpath; cpath = cpath_next) {
|
for (cpath = circ->cpath; cpath_next != circ->cpath; cpath = cpath_next) {
|
||||||
cpath_next = cpath->next;
|
cpath_next = cpath->next;
|
||||||
|
@ -1096,9 +1096,23 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return true iff <b>crypt_path</b> is one of the crypt_paths for
|
||||||
|
* <b>circ</b> */
|
||||||
|
static int
|
||||||
|
cpath_is_on_circuit(origin_circuit_t *circ, crypt_path_t *crypt_path)
|
||||||
|
{
|
||||||
|
crypt_path_t *cpath, *cpath_next = NULL;
|
||||||
|
for (cpath = circ->cpath; cpath_next != circ->cpath; cpath = cpath_next) {
|
||||||
|
cpath_next = cpath->next;
|
||||||
|
if (crypt_path == cpath)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Attach the AP stream <b>apconn</b> to circ's linked list of
|
/** Attach the AP stream <b>apconn</b> to circ's linked list of
|
||||||
* p_streams. Also set apconn's cpath_layer to the last hop in
|
* p_streams. Also set apconn's cpath_layer to <b>cpath</b>, or to the last
|
||||||
* circ's cpath.
|
* hop in circ's cpath if <b>cpath</b> is NULL.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
link_apconn_to_circ(edge_connection_t *apconn, origin_circuit_t *circ,
|
link_apconn_to_circ(edge_connection_t *apconn, origin_circuit_t *circ,
|
||||||
@ -1115,6 +1129,7 @@ link_apconn_to_circ(edge_connection_t *apconn, origin_circuit_t *circ,
|
|||||||
circ->p_streams = apconn;
|
circ->p_streams = apconn;
|
||||||
|
|
||||||
if (cpath) { /* we were given one; use it */
|
if (cpath) { /* we were given one; use it */
|
||||||
|
tor_assert(cpath_is_on_circuit(circ, cpath));
|
||||||
apconn->cpath_layer = cpath;
|
apconn->cpath_layer = cpath;
|
||||||
} else { /* use the last hop in the circuit */
|
} else { /* use the last hop in the circuit */
|
||||||
tor_assert(circ->cpath);
|
tor_assert(circ->cpath);
|
||||||
@ -1172,9 +1187,11 @@ consider_recording_trackhost(edge_connection_t *conn, origin_circuit_t *circ)
|
|||||||
time(NULL) + options->TrackHostExitsExpire);
|
time(NULL) + options->TrackHostExitsExpire);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Attempt to attach the connection <b>conn</b> to <b>circ</b>, and
|
/** Attempt to attach the connection <b>conn</b> to <b>circ</b>, and send a
|
||||||
* send a begin or resolve cell as appropriate. Return values are as
|
* begin or resolve cell as appropriate. Return values are as for
|
||||||
* for connection_ap_handshake_attach_circuit. */
|
* connection_ap_handshake_attach_circuit. The stream will exit from the hop
|
||||||
|
* indicatd by <b>cpath</b>, or to the last hop in circ's cpath if
|
||||||
|
* <b>cpath</b> is NULL. */
|
||||||
int
|
int
|
||||||
connection_ap_handshake_attach_chosen_circuit(edge_connection_t *conn,
|
connection_ap_handshake_attach_chosen_circuit(edge_connection_t *conn,
|
||||||
origin_circuit_t *circ,
|
origin_circuit_t *circ,
|
||||||
|
@ -1178,6 +1178,10 @@ addressmap_get_mappings(smartlist_t *sl, time_t min_expires,
|
|||||||
* one as needed), else if it's for a rendezvous circuit, fetch a
|
* one as needed), else if it's for a rendezvous circuit, fetch a
|
||||||
* rendezvous descriptor first (or attach/launch a circuit if the
|
* rendezvous descriptor first (or attach/launch a circuit if the
|
||||||
* rendezvous descriptor is already here and fresh enough).
|
* rendezvous descriptor is already here and fresh enough).
|
||||||
|
*
|
||||||
|
* The stream will exit from the hop
|
||||||
|
* indicatd by <b>cpath</b>, or to the last hop in circ's cpath if
|
||||||
|
* <b>cpath</b> is NULL.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
|
connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn,
|
||||||
|
Loading…
Reference in New Issue
Block a user