Loading src/or/circuit.c +5 −1 Changes for src/or/circuit.c: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -249,8 +249,10 @@ circuit_t *circuit_get_by_conn(connection_t *conn) { * If !conn, return newest. * * If must_be_open, ignore circs not in CIRCUIT_STATE_OPEN. * If must_be_clean, ignore circs that have been used before. */ circuit_t *circuit_get_newest(connection_t *conn, int must_be_open) { circuit_t *circuit_get_newest(connection_t *conn, int must_be_open, int must_be_clean) { circuit_t *circ, *newest=NULL, *leastdirty=NULL; routerinfo_t *exitrouter; Loading @@ -261,6 +263,8 @@ circuit_t *circuit_get_newest(connection_t *conn, int must_be_open) { continue; /* ignore non-open circs */ if (circ->marked_for_close) continue; if (must_be_clean && circ->timestamp_dirty) continue; /* ignore dirty circs */ if(conn) { if(circ->state == CIRCUIT_STATE_OPEN && circ->n_conn) /* open */ exitrouter = router_get_by_addr_port(circ->cpath->prev->addr, circ->cpath->prev->port); Loading src/or/connection_edge.c +23 −12 Changes for src/or/connection_edge.c: 23 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -9,8 +9,10 @@ extern or_options_t options; /* command-line and config-file options */ extern char *conn_state_to_string[][_CONN_TYPE_MAX+1]; static int connection_ap_handshake_process_socks(connection_t *conn); static int connection_ap_handshake_attach_circuit(connection_t *conn); static int connection_ap_handshake_attach_circuit_helper(connection_t *conn); static int connection_ap_handshake_attach_circuit(connection_t *conn, int must_be_clean); static int connection_ap_handshake_attach_circuit_helper(connection_t *conn, int must_be_clean); static void connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t *circ); static int connection_exit_begin_conn(cell_t *cell, circuit_t *circ); Loading Loading @@ -367,7 +369,8 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, addr = ntohl(addr); client_dns_set_entry(conn->socks_request->address, addr); conn->state = AP_CONN_STATE_CIRCUIT_WAIT; if(connection_ap_handshake_attach_circuit(conn) >= 0) /* attaching to a dirty circuit is fine */ if(connection_ap_handshake_attach_circuit(conn, 0) >= 0) return 0; /* else, conn will get closed below */ } Loading Loading @@ -635,7 +638,8 @@ void connection_ap_expire_beginning(void) { circ->timestamp_dirty -= options.NewCircuitPeriod; /* give our stream another 15 seconds to try */ conn->timestamp_lastread += 15; if(connection_ap_handshake_attach_circuit(conn)<0) { /* attaching to a dirty circuit is fine */ if(connection_ap_handshake_attach_circuit(conn,0)<0) { /* it will never work */ /* Don't need to send end -- we're not connected */ connection_mark_for_close(conn, 0); Loading @@ -658,7 +662,8 @@ void connection_ap_attach_pending(void) if (conn->type != CONN_TYPE_AP || conn->state != AP_CONN_STATE_CIRCUIT_WAIT) continue; if(connection_ap_handshake_attach_circuit(conn) < 0) { /* attaching to a dirty circuit is fine */ if(connection_ap_handshake_attach_circuit(conn,0) < 0) { /* -1 means it will never work */ /* Don't send end; there is no 'other side' yet */ connection_mark_for_close(conn,0); Loading Loading @@ -720,18 +725,22 @@ static int connection_ap_handshake_process_socks(connection_t *conn) { } /* else socks handshake is done, continue processing */ conn->state = AP_CONN_STATE_CIRCUIT_WAIT; return connection_ap_handshake_attach_circuit(conn); /* attaching to a dirty circuit is fine */ return connection_ap_handshake_attach_circuit(conn,0); } static int connection_ap_handshake_attach_circuit(connection_t *conn) { static int connection_ap_handshake_attach_circuit(connection_t *conn, int must_be_clean) { /* try attaching. launch new circuit if needed. * return -1 if conn needs to die, else 0. */ switch(connection_ap_handshake_attach_circuit_helper(conn)) { switch(connection_ap_handshake_attach_circuit_helper(conn, must_be_clean)) { case -1: /* it will never work */ return -1; case 0: /* no useful circuits available */ if(!circuit_get_newest(conn, 0)) /* is one already on the way? */ if(!circuit_get_newest(conn, 0, must_be_clean)) { /* is one already on the way? */ circuit_launch_new(); } return 0; default: /* case 1, it succeeded, great */ return 0; Loading @@ -744,7 +753,8 @@ static int connection_ap_handshake_attach_circuit(connection_t *conn) { * Otherwise, associate conn with a safe live circuit, start * sending a BEGIN cell down the circuit, and return 1. */ static int connection_ap_handshake_attach_circuit_helper(connection_t *conn) { static int connection_ap_handshake_attach_circuit_helper(connection_t *conn, int must_be_clean) { circuit_t *circ; uint32_t addr; Loading @@ -754,7 +764,7 @@ static int connection_ap_handshake_attach_circuit_helper(connection_t *conn) { assert(conn->socks_request); /* find the circuit that we should use, if there is one. */ circ = circuit_get_newest(conn, 1); circ = circuit_get_newest(conn, 1, must_be_clean); if(!circ) { log_fn(LOG_INFO,"No safe circuit ready for edge connection; delaying."); Loading Loading @@ -903,7 +913,8 @@ int connection_ap_make_bridge(char *address, uint16_t port) { conn->state = AP_CONN_STATE_CIRCUIT_WAIT; connection_start_reading(conn); if (connection_ap_handshake_attach_circuit(conn) < 0) { /* attaching to a dirty circuit is fine */ if (connection_ap_handshake_attach_circuit(conn, 0) < 0) { connection_mark_for_close(conn, 0); close(fd[1]); return -1; Loading src/or/main.c +1 −1 Changes for src/or/main.c: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -381,7 +381,7 @@ static void run_scheduled_events(time_t now) { /* Build a new test circuit every 5 minutes */ #define TESTING_CIRCUIT_INTERVAL 300 circ = circuit_get_newest(NULL, 1); circ = circuit_get_newest(NULL, 1, 0); if(time_to_new_circuit < now) { client_dns_clean(); circuit_expire_unused_circuits(); Loading src/or/or.h +2 −1 Changes for src/or/or.h: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -658,7 +658,8 @@ int _circuit_mark_for_close(circuit_t *circ); circuit_t *circuit_get_by_circ_id_conn(uint16_t circ_id, connection_t *conn); circuit_t *circuit_get_by_conn(connection_t *conn); circuit_t *circuit_get_newest(connection_t *conn, int must_be_open); circuit_t *circuit_get_newest(connection_t *conn, int must_be_open, int must_be_clean); circuit_t *circuit_get_by_service_and_purpose(const char *servid, int purpose); void circuit_expire_building(void); Loading Loading
src/or/circuit.c +5 −1 Changes for src/or/circuit.c: 5 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -249,8 +249,10 @@ circuit_t *circuit_get_by_conn(connection_t *conn) { * If !conn, return newest. * * If must_be_open, ignore circs not in CIRCUIT_STATE_OPEN. * If must_be_clean, ignore circs that have been used before. */ circuit_t *circuit_get_newest(connection_t *conn, int must_be_open) { circuit_t *circuit_get_newest(connection_t *conn, int must_be_open, int must_be_clean) { circuit_t *circ, *newest=NULL, *leastdirty=NULL; routerinfo_t *exitrouter; Loading @@ -261,6 +263,8 @@ circuit_t *circuit_get_newest(connection_t *conn, int must_be_open) { continue; /* ignore non-open circs */ if (circ->marked_for_close) continue; if (must_be_clean && circ->timestamp_dirty) continue; /* ignore dirty circs */ if(conn) { if(circ->state == CIRCUIT_STATE_OPEN && circ->n_conn) /* open */ exitrouter = router_get_by_addr_port(circ->cpath->prev->addr, circ->cpath->prev->port); Loading
src/or/connection_edge.c +23 −12 Changes for src/or/connection_edge.c: 23 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -9,8 +9,10 @@ extern or_options_t options; /* command-line and config-file options */ extern char *conn_state_to_string[][_CONN_TYPE_MAX+1]; static int connection_ap_handshake_process_socks(connection_t *conn); static int connection_ap_handshake_attach_circuit(connection_t *conn); static int connection_ap_handshake_attach_circuit_helper(connection_t *conn); static int connection_ap_handshake_attach_circuit(connection_t *conn, int must_be_clean); static int connection_ap_handshake_attach_circuit_helper(connection_t *conn, int must_be_clean); static void connection_ap_handshake_send_begin(connection_t *ap_conn, circuit_t *circ); static int connection_exit_begin_conn(cell_t *cell, circuit_t *circ); Loading Loading @@ -367,7 +369,8 @@ int connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, addr = ntohl(addr); client_dns_set_entry(conn->socks_request->address, addr); conn->state = AP_CONN_STATE_CIRCUIT_WAIT; if(connection_ap_handshake_attach_circuit(conn) >= 0) /* attaching to a dirty circuit is fine */ if(connection_ap_handshake_attach_circuit(conn, 0) >= 0) return 0; /* else, conn will get closed below */ } Loading Loading @@ -635,7 +638,8 @@ void connection_ap_expire_beginning(void) { circ->timestamp_dirty -= options.NewCircuitPeriod; /* give our stream another 15 seconds to try */ conn->timestamp_lastread += 15; if(connection_ap_handshake_attach_circuit(conn)<0) { /* attaching to a dirty circuit is fine */ if(connection_ap_handshake_attach_circuit(conn,0)<0) { /* it will never work */ /* Don't need to send end -- we're not connected */ connection_mark_for_close(conn, 0); Loading @@ -658,7 +662,8 @@ void connection_ap_attach_pending(void) if (conn->type != CONN_TYPE_AP || conn->state != AP_CONN_STATE_CIRCUIT_WAIT) continue; if(connection_ap_handshake_attach_circuit(conn) < 0) { /* attaching to a dirty circuit is fine */ if(connection_ap_handshake_attach_circuit(conn,0) < 0) { /* -1 means it will never work */ /* Don't send end; there is no 'other side' yet */ connection_mark_for_close(conn,0); Loading Loading @@ -720,18 +725,22 @@ static int connection_ap_handshake_process_socks(connection_t *conn) { } /* else socks handshake is done, continue processing */ conn->state = AP_CONN_STATE_CIRCUIT_WAIT; return connection_ap_handshake_attach_circuit(conn); /* attaching to a dirty circuit is fine */ return connection_ap_handshake_attach_circuit(conn,0); } static int connection_ap_handshake_attach_circuit(connection_t *conn) { static int connection_ap_handshake_attach_circuit(connection_t *conn, int must_be_clean) { /* try attaching. launch new circuit if needed. * return -1 if conn needs to die, else 0. */ switch(connection_ap_handshake_attach_circuit_helper(conn)) { switch(connection_ap_handshake_attach_circuit_helper(conn, must_be_clean)) { case -1: /* it will never work */ return -1; case 0: /* no useful circuits available */ if(!circuit_get_newest(conn, 0)) /* is one already on the way? */ if(!circuit_get_newest(conn, 0, must_be_clean)) { /* is one already on the way? */ circuit_launch_new(); } return 0; default: /* case 1, it succeeded, great */ return 0; Loading @@ -744,7 +753,8 @@ static int connection_ap_handshake_attach_circuit(connection_t *conn) { * Otherwise, associate conn with a safe live circuit, start * sending a BEGIN cell down the circuit, and return 1. */ static int connection_ap_handshake_attach_circuit_helper(connection_t *conn) { static int connection_ap_handshake_attach_circuit_helper(connection_t *conn, int must_be_clean) { circuit_t *circ; uint32_t addr; Loading @@ -754,7 +764,7 @@ static int connection_ap_handshake_attach_circuit_helper(connection_t *conn) { assert(conn->socks_request); /* find the circuit that we should use, if there is one. */ circ = circuit_get_newest(conn, 1); circ = circuit_get_newest(conn, 1, must_be_clean); if(!circ) { log_fn(LOG_INFO,"No safe circuit ready for edge connection; delaying."); Loading Loading @@ -903,7 +913,8 @@ int connection_ap_make_bridge(char *address, uint16_t port) { conn->state = AP_CONN_STATE_CIRCUIT_WAIT; connection_start_reading(conn); if (connection_ap_handshake_attach_circuit(conn) < 0) { /* attaching to a dirty circuit is fine */ if (connection_ap_handshake_attach_circuit(conn, 0) < 0) { connection_mark_for_close(conn, 0); close(fd[1]); return -1; Loading
src/or/main.c +1 −1 Changes for src/or/main.c: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -381,7 +381,7 @@ static void run_scheduled_events(time_t now) { /* Build a new test circuit every 5 minutes */ #define TESTING_CIRCUIT_INTERVAL 300 circ = circuit_get_newest(NULL, 1); circ = circuit_get_newest(NULL, 1, 0); if(time_to_new_circuit < now) { client_dns_clean(); circuit_expire_unused_circuits(); Loading
src/or/or.h +2 −1 Changes for src/or/or.h: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -658,7 +658,8 @@ int _circuit_mark_for_close(circuit_t *circ); circuit_t *circuit_get_by_circ_id_conn(uint16_t circ_id, connection_t *conn); circuit_t *circuit_get_by_conn(connection_t *conn); circuit_t *circuit_get_newest(connection_t *conn, int must_be_open); circuit_t *circuit_get_newest(connection_t *conn, int must_be_open, int must_be_clean); circuit_t *circuit_get_by_service_and_purpose(const char *servid, int purpose); void circuit_expire_building(void); Loading