Remove unused rendversion parameters. YAGNI.

This commit is contained in:
Karsten Loesing 2009-05-03 01:04:25 +02:00 committed by Nick Mathewson
parent 592f957169
commit 948835c680
5 changed files with 35 additions and 54 deletions

View File

@ -2569,16 +2569,13 @@ connection_get_by_type_state(int type, int state)
/** Return a connection of type <b>type</b> that has rendquery equal /** Return a connection of type <b>type</b> that has rendquery equal
* to <b>rendquery</b>, and that is not marked for close. If state * to <b>rendquery</b>, and that is not marked for close. If state
* is non-zero, conn must be of that state too. (rendversion is * is non-zero, conn must be of that state too.
* ignored.)
*/ */
connection_t * connection_t *
connection_get_by_type_state_rendquery(int type, int state, connection_get_by_type_state_rendquery(int type, int state,
const char *rendquery, const char *rendquery)
int rendversion)
{ {
smartlist_t *conns = get_connection_array(); smartlist_t *conns = get_connection_array();
(void) rendversion;
tor_assert(type == CONN_TYPE_DIR || tor_assert(type == CONN_TYPE_DIR ||
type == CONN_TYPE_AP || type == CONN_TYPE_EXIT); type == CONN_TYPE_AP || type == CONN_TYPE_EXIT);

View File

@ -1899,7 +1899,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
/* Success, or at least there's a v2 descriptor already /* Success, or at least there's a v2 descriptor already
* present. Notify pending connections about this. */ * present. Notify pending connections about this. */
conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC; conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
rend_client_desc_trynow(conn->rend_data->onion_address, -1); rend_client_desc_trynow(conn->rend_data->onion_address);
} }
break; break;
case 404: case 404:
@ -1946,7 +1946,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
log_info(LD_REND, "Successfully fetched v2 rendezvous " log_info(LD_REND, "Successfully fetched v2 rendezvous "
"descriptor."); "descriptor.");
conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC; conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
rend_client_desc_trynow(conn->rend_data->onion_address, -1); rend_client_desc_trynow(conn->rend_data->onion_address);
break; break;
} }
break; break;

View File

@ -2985,8 +2985,7 @@ connection_t *connection_get_by_type_addr_port_purpose(int type,
uint16_t port, int purpose); uint16_t port, int purpose);
connection_t *connection_get_by_type_state(int type, int state); connection_t *connection_get_by_type_state(int type, int state);
connection_t *connection_get_by_type_state_rendquery(int type, int state, connection_t *connection_get_by_type_state_rendquery(int type, int state,
const char *rendquery, const char *rendquery);
int rendversion);
#define connection_speaks_cells(conn) ((conn)->type == CONN_TYPE_OR) #define connection_speaks_cells(conn) ((conn)->type == CONN_TYPE_OR)
int connection_is_listener(connection_t *conn); int connection_is_listener(connection_t *conn);
@ -4015,7 +4014,7 @@ int rend_client_rendezvous_acked(origin_circuit_t *circ, const char *request,
size_t request_len); size_t request_len);
int rend_client_receive_rendezvous(origin_circuit_t *circ, const char *request, int rend_client_receive_rendezvous(origin_circuit_t *circ, const char *request,
size_t request_len); size_t request_len);
void rend_client_desc_trynow(const char *query, int rend_version); void rend_client_desc_trynow(const char *query);
extend_info_t *rend_client_get_random_intro(const rend_data_t *rend_query); extend_info_t *rend_client_get_random_intro(const rend_data_t *rend_query);

View File

@ -498,8 +498,8 @@ rend_client_refetch_v2_renddesc(const rend_data_t *rend_query)
log_info(LD_REND, "Could not pick one of the responsible hidden " log_info(LD_REND, "Could not pick one of the responsible hidden "
"service directories to fetch descriptors, because " "service directories to fetch descriptors, because "
"we already tried them all unsuccessfully."); "we already tried them all unsuccessfully.");
/* Close pending connections (unless a v0 request is still going on). */ /* Close pending connections. */
rend_client_desc_trynow(rend_query->onion_address, 2); rend_client_desc_trynow(rend_query->onion_address);
return; return;
} }
@ -549,7 +549,7 @@ rend_client_remove_intro_point(extend_info_t *failed_intro,
/* move all pending streams back to renddesc_wait */ /* move all pending streams back to renddesc_wait */
while ((conn = connection_get_by_type_state_rendquery(CONN_TYPE_AP, while ((conn = connection_get_by_type_state_rendquery(CONN_TYPE_AP,
AP_CONN_STATE_CIRCUIT_WAIT, AP_CONN_STATE_CIRCUIT_WAIT,
rend_query->onion_address, -1))) { rend_query->onion_address))) {
conn->state = AP_CONN_STATE_RENDDESC_WAIT; conn->state = AP_CONN_STATE_RENDDESC_WAIT;
} }
@ -658,22 +658,16 @@ rend_client_receive_rendezvous(origin_circuit_t *circ, const char *request,
return -1; return -1;
} }
/** Find all the apconns in state AP_CONN_STATE_RENDDESC_WAIT that /** Find all the apconns in state AP_CONN_STATE_RENDDESC_WAIT that are
* are waiting on query. If there's a working cache entry here * waiting on <b>query</b>. If there's a working cache entry here with at
* with at least one intro point, move them to the next state. * least one intro point, move them to the next state. */
* (<b>rend_version</b> was used to keep the connection open when
* there were still descriptor fetch requests in progress for other
* descriptor versions than <b>rend_version</b>, but this is obsolete
* now that we support only version 2.)
*/
void void
rend_client_desc_trynow(const char *query, int rend_version) rend_client_desc_trynow(const char *query)
{ {
edge_connection_t *conn; edge_connection_t *conn;
rend_cache_entry_t *entry; rend_cache_entry_t *entry;
time_t now = time(NULL); time_t now = time(NULL);
smartlist_t *conns = get_connection_array(); smartlist_t *conns = get_connection_array();
(void) rend_version;
SMARTLIST_FOREACH(conns, connection_t *, _conn, SMARTLIST_FOREACH(conns, connection_t *, _conn,
{ {

View File

@ -10,8 +10,7 @@
#include "or.h" #include "or.h"
static origin_circuit_t *find_intro_circuit(rend_intro_point_t *intro, static origin_circuit_t *find_intro_circuit(rend_intro_point_t *intro,
const char *pk_digest, const char *pk_digest);
int desc_version);
/** Represents the mapping from a virtual port of a rendezvous service to /** Represents the mapping from a virtual port of a rendezvous service to
* a real port on some IP. * a real port on some IP.
@ -56,7 +55,7 @@ typedef struct rend_service_t {
* or are trying to establish. */ * or are trying to establish. */
time_t intro_period_started; /**< Start of the current period to build time_t intro_period_started; /**< Start of the current period to build
* introduction points. */ * introduction points. */
int n_intro_circuits_launched; /**< count of intro circuits we have int n_intro_circuits_launched; /**< Count of intro circuits we have
* established in this period. */ * established in this period. */
rend_service_descriptor_t *desc; /**< Current hidden service descriptor. */ rend_service_descriptor_t *desc; /**< Current hidden service descriptor. */
time_t desc_is_dirty; /**< Time at which changes to the hidden service time_t desc_is_dirty; /**< Time at which changes to the hidden service
@ -497,7 +496,7 @@ rend_service_update_descriptor(rend_service_t *service)
for (i = 0; i < smartlist_len(service->intro_nodes); ++i) { for (i = 0; i < smartlist_len(service->intro_nodes); ++i) {
rend_intro_point_t *intro_svc = smartlist_get(service->intro_nodes, i); rend_intro_point_t *intro_svc = smartlist_get(service->intro_nodes, i);
rend_intro_point_t *intro_desc; rend_intro_point_t *intro_desc;
circ = find_intro_circuit(intro_svc, service->pk_digest, d->version); circ = find_intro_circuit(intro_svc, service->pk_digest);
if (!circ || circ->_base.purpose != CIRCUIT_PURPOSE_S_INTRO) if (!circ || circ->_base.purpose != CIRCUIT_PURPOSE_S_INTRO)
continue; continue;
@ -738,16 +737,12 @@ rend_service_load_keys(void)
return r; return r;
} }
/** Return the service whose public key has a digest of <b>digest</b> and /** Return the service whose public key has a digest of <b>digest</b>, or
* which publishes the given descriptor <b>version</b>. (There is no other * NULL if no such service exists.
* version than 2, so version is ignored.) Return NULL if no such service
* exists.
*/ */
static rend_service_t * static rend_service_t *
rend_service_get_by_pk_digest_and_version(const char* digest, rend_service_get_by_pk_digest(const char* digest)
uint8_t version)
{ {
(void) version;
SMARTLIST_FOREACH(rend_service_list, rend_service_t*, s, SMARTLIST_FOREACH(rend_service_list, rend_service_t*, s,
if (!memcmp(s->pk_digest,digest,DIGEST_LEN)) if (!memcmp(s->pk_digest,digest,DIGEST_LEN))
return s); return s);
@ -887,8 +882,8 @@ rend_service_introduce(origin_circuit_t *circuit, const char *request,
} }
/* look up service depending on circuit. */ /* look up service depending on circuit. */
service = rend_service_get_by_pk_digest_and_version( service = rend_service_get_by_pk_digest(
circuit->rend_data->rend_pk_digest, -1); circuit->rend_data->rend_pk_digest);
if (!service) { if (!service) {
log_warn(LD_REND, "Got an INTRODUCE2 cell for an unrecognized service %s.", log_warn(LD_REND, "Got an INTRODUCE2 cell for an unrecognized service %s.",
escaped(serviceid)); escaped(serviceid));
@ -1267,14 +1262,12 @@ rend_service_launch_establish_intro(rend_service_t *service,
} }
/** Return the number of introduction points that are or have been /** Return the number of introduction points that are or have been
* established for the given service address in <b>query</b>. * established for the given service address in <b>query</b>. */
* (<b>rend_version</b> is ignored.) */
static int static int
count_established_intro_points(const char *query, int rend_version) count_established_intro_points(const char *query)
{ {
int num_ipos = 0; int num_ipos = 0;
circuit_t *circ; circuit_t *circ;
(void) rend_version;
for (circ = _circuit_get_global_list(); circ; circ = circ->next) { for (circ = _circuit_get_global_list(); circ; circ = circ->next) {
if (!circ->marked_for_close && if (!circ->marked_for_close &&
circ->state == CIRCUIT_STATE_OPEN && circ->state == CIRCUIT_STATE_OPEN &&
@ -1311,8 +1304,8 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
base32_encode(serviceid, REND_SERVICE_ID_LEN_BASE32+1, base32_encode(serviceid, REND_SERVICE_ID_LEN_BASE32+1,
circuit->rend_data->rend_pk_digest, REND_SERVICE_ID_LEN); circuit->rend_data->rend_pk_digest, REND_SERVICE_ID_LEN);
service = rend_service_get_by_pk_digest_and_version( service = rend_service_get_by_pk_digest(
circuit->rend_data->rend_pk_digest, -1); circuit->rend_data->rend_pk_digest);
if (!service) { if (!service) {
log_warn(LD_REND, "Unrecognized service ID %s on introduction circuit %d.", log_warn(LD_REND, "Unrecognized service ID %s on introduction circuit %d.",
serviceid, circuit->_base.n_circ_id); serviceid, circuit->_base.n_circ_id);
@ -1322,7 +1315,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
/* If we already have enough introduction circuits for this service, /* If we already have enough introduction circuits for this service,
* redefine this one as a general circuit. */ * redefine this one as a general circuit. */
if (count_established_intro_points(serviceid, -1) > NUM_INTRO_POINTS) { if (count_established_intro_points(serviceid) > NUM_INTRO_POINTS) {
log_info(LD_CIRC|LD_REND, "We have just finished an introduction " log_info(LD_CIRC|LD_REND, "We have just finished an introduction "
"circuit, but we already have enough. Redefining purpose to " "circuit, but we already have enough. Redefining purpose to "
"general."); "general.");
@ -1395,8 +1388,8 @@ rend_service_intro_established(origin_circuit_t *circuit, const char *request,
goto err; goto err;
} }
tor_assert(circuit->rend_data); tor_assert(circuit->rend_data);
service = rend_service_get_by_pk_digest_and_version( service = rend_service_get_by_pk_digest(
circuit->rend_data->rend_pk_digest, -1); circuit->rend_data->rend_pk_digest);
if (!service) { if (!service) {
log_warn(LD_REND, "Unknown service on introduction circuit %d.", log_warn(LD_REND, "Unknown service on introduction circuit %d.",
circuit->_base.n_circ_id); circuit->_base.n_circ_id);
@ -1446,8 +1439,8 @@ rend_service_rendezvous_has_opened(origin_circuit_t *circuit)
"cookie %s for service %s", "cookie %s for service %s",
circuit->_base.n_circ_id, hexcookie, serviceid); circuit->_base.n_circ_id, hexcookie, serviceid);
service = rend_service_get_by_pk_digest_and_version( service = rend_service_get_by_pk_digest(
circuit->rend_data->rend_pk_digest, -1); circuit->rend_data->rend_pk_digest);
if (!service) { if (!service) {
log_warn(LD_GENERAL, "Internal error: unrecognized service ID on " log_warn(LD_GENERAL, "Internal error: unrecognized service ID on "
"introduction circuit."); "introduction circuit.");
@ -1508,11 +1501,9 @@ rend_service_rendezvous_has_opened(origin_circuit_t *circuit)
* found. * found.
*/ */
static origin_circuit_t * static origin_circuit_t *
find_intro_circuit(rend_intro_point_t *intro, const char *pk_digest, find_intro_circuit(rend_intro_point_t *intro, const char *pk_digest)
int desc_version)
{ {
origin_circuit_t *circ = NULL; origin_circuit_t *circ = NULL;
(void) desc_version;
tor_assert(intro); tor_assert(intro);
while ((circ = circuit_get_next_by_pk_and_purpose(circ,pk_digest, while ((circ = circuit_get_next_by_pk_and_purpose(circ,pk_digest,
@ -1774,7 +1765,7 @@ rend_services_introduce(void)
for (j=0; j < smartlist_len(service->intro_nodes); ++j) { for (j=0; j < smartlist_len(service->intro_nodes); ++j) {
intro = smartlist_get(service->intro_nodes, j); intro = smartlist_get(service->intro_nodes, j);
router = router_get_by_digest(intro->extend_info->identity_digest); router = router_get_by_digest(intro->extend_info->identity_digest);
if (!router || !find_intro_circuit(intro, service->pk_digest, -1)) { if (!router || !find_intro_circuit(intro, service->pk_digest)) {
log_info(LD_REND,"Giving up on %s as intro point for %s.", log_info(LD_REND,"Giving up on %s as intro point for %s.",
intro->extend_info->nickname, service->service_id); intro->extend_info->nickname, service->service_id);
if (service->desc) { if (service->desc) {
@ -1960,7 +1951,7 @@ rend_service_dump_stats(int severity)
intro = smartlist_get(service->intro_nodes, j); intro = smartlist_get(service->intro_nodes, j);
safe_name = safe_str(intro->extend_info->nickname); safe_name = safe_str(intro->extend_info->nickname);
circ = find_intro_circuit(intro, service->pk_digest, -1); circ = find_intro_circuit(intro, service->pk_digest);
if (!circ) { if (!circ) {
log(severity, LD_GENERAL, " Intro point %d at %s: no circuit", log(severity, LD_GENERAL, " Intro point %d at %s: no circuit",
j, safe_name); j, safe_name);
@ -1991,8 +1982,8 @@ rend_service_set_connection_addr_port(edge_connection_t *conn,
log_debug(LD_REND,"beginning to hunt for addr/port"); log_debug(LD_REND,"beginning to hunt for addr/port");
base32_encode(serviceid, REND_SERVICE_ID_LEN_BASE32+1, base32_encode(serviceid, REND_SERVICE_ID_LEN_BASE32+1,
circ->rend_data->rend_pk_digest, REND_SERVICE_ID_LEN); circ->rend_data->rend_pk_digest, REND_SERVICE_ID_LEN);
service = rend_service_get_by_pk_digest_and_version( service = rend_service_get_by_pk_digest(
circ->rend_data->rend_pk_digest, -1); circ->rend_data->rend_pk_digest);
if (!service) { if (!service) {
log_warn(LD_REND, "Couldn't find any service associated with pk %s on " log_warn(LD_REND, "Couldn't find any service associated with pk %s on "
"rendezvous circuit %d; closing.", "rendezvous circuit %d; closing.",