diff options
author | Robert Ransom <rransom.8774@gmail.com> | 2011-10-05 23:52:14 -0700 |
---|---|---|
committer | Robert Ransom <rransom.8774@gmail.com> | 2011-10-30 02:17:04 -0700 |
commit | 6f035cb2b450e8779bff50d6ed83e4822a49f0fe (patch) | |
tree | a736aaf10663d4e51bd64186458b13272129f25d /src/or/rendservice.c | |
parent | 6b26999146ab5e21fbfe43fe5084005a34ba2415 (diff) | |
download | tor-6f035cb2b450e8779bff50d6ed83e4822a49f0fe.tar.gz tor-6f035cb2b450e8779bff50d6ed83e4822a49f0fe.zip |
Record the number of INTRODUCE2 cells each intro point has received
Diffstat (limited to 'src/or/rendservice.c')
-rw-r--r-- | src/or/rendservice.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c index d21fdcc4bf..a341dd672b 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -25,6 +25,7 @@ static origin_circuit_t *find_intro_circuit(rend_intro_point_t *intro, const char *pk_digest); +static rend_intro_point_t *find_intro_point(origin_circuit_t *circ); /** Represents the mapping from a virtual port of a rendezvous service to * a real port on some IP. @@ -899,6 +900,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request, char buf[RELAY_PAYLOAD_SIZE]; char keys[DIGEST_LEN+CPATH_KEY_MATERIAL_LEN]; /* Holds KH, Df, Db, Kf, Kb */ rend_service_t *service; + rend_intro_point_t *intro_point; int r, i, v3_shift = 0; size_t len, keylen; crypto_dh_env_t *dh = NULL; @@ -971,6 +973,14 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request, return -1; } + intro_point = find_intro_point(circuit); + if (intro_point == NULL) { + log_warn(LD_BUG, "Internal error: Got an INTRODUCE2 cell on an intro circ " + "(for service %s) with no corresponding rend_intro_point_t.", + escaped(serviceid)); + return -1; + } + if (!service->accepted_intros) service->accepted_intros = digestmap_new(); @@ -993,6 +1003,13 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request, digestmap_set(service->accepted_intros, pkpart_digest, access_time); } + /* Record that we've received another INTRODUCE2 cell through this + * intro point. */ + ++(intro_point->introduction_count); + if (intro_point->introduction_count == 0) { + --(intro_point->introduction_count); + } + /* Next N bytes is encrypted with service key */ note_crypto_pk_op(REND_SERVER); r = crypto_pk_private_hybrid_decrypt( @@ -1647,6 +1664,35 @@ find_intro_circuit(rend_intro_point_t *intro, const char *pk_digest) return NULL; } +/** Return a pointer to the rend_intro_point_t corresponding to the + * service-side introduction circuit <b>circ</b>. */ +static rend_intro_point_t * +find_intro_point(origin_circuit_t *circ) +{ + const char *serviceid; + rend_service_t *service = NULL; + + tor_assert(TO_CIRCUIT(circ)->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO || + TO_CIRCUIT(circ)->purpose == CIRCUIT_PURPOSE_S_INTRO); + tor_assert(circ->rend_data); + serviceid = circ->rend_data->onion_address; + + SMARTLIST_FOREACH(rend_service_list, rend_service_t *, s, + if (tor_memeq(s->service_id, serviceid, REND_SERVICE_ID_LEN_BASE32)) { + service = s; + break; + }); + + if (service == NULL) return NULL; + + SMARTLIST_FOREACH(service->intro_nodes, rend_intro_point_t *, intro_point, + if (crypto_pk_cmp_keys(intro_point->intro_key, circ->intro_key) == 0) { + return intro_point; + }); + + return NULL; +} + /** Determine the responsible hidden service directories for the * rend_encoded_v2_service_descriptor_t's in <b>descs</b> and upload them; * <b>service_id</b> and <b>seconds_valid</b> are only passed for logging |