summaryrefslogtreecommitdiff
path: root/src/or/rendservice.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-04-03 04:55:22 +0000
committerNick Mathewson <nickm@torproject.org>2004-04-03 04:55:22 +0000
commita9813f0210bbf723e19b24c73fb93ecc436efcfb (patch)
tree9a8860ce762a8d66a12eaf0fc7bdb4a23ddb1033 /src/or/rendservice.c
parent3af1191023a0e81dd727afd48396cf9cf7dd5672 (diff)
downloadtor-a9813f0210bbf723e19b24c73fb93ecc436efcfb.tar.gz
tor-a9813f0210bbf723e19b24c73fb93ecc436efcfb.zip
Implement acks
svn:r1470
Diffstat (limited to 'src/or/rendservice.c')
-rw-r--r--src/or/rendservice.c69
1 files changed, 48 insertions, 21 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index e05998c71b..31f0c8c5dc 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -320,7 +320,7 @@ rend_service_introduce(circuit_t *circuit, const char *request, int request_len)
log_fn(LOG_INFO, "Received INTRODUCE2 cell for service %s on circ %d",
hexid, circuit->n_circ_id);
- if (circuit->purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO) {
+ if (circuit->purpose != CIRCUIT_PURPOSE_S_INTRO) {
log_fn(LOG_WARN, "Got an INTRODUCE2 over a non-introduction circuit %d",
circuit->n_circ_id);
return -1;
@@ -504,6 +504,22 @@ rend_service_intro_is_ready(circuit_t *circuit)
circuit_mark_for_close(circuit);
}
+/* Handle an intro_established cell. */
+int
+rend_service_intro_established(circuit_t *circuit, const char *request, int request_len)
+{
+ if (circuit->purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO) {
+ log_fn(LOG_WARN, "received INTRO_ESTABLISHED cell on non-intro circuit");
+ goto err;
+ }
+ circuit->purpose = CIRCUIT_PURPOSE_S_INTRO;
+
+ return 0;
+ err:
+ circuit_mark_for_close(circuit);
+ return -1;
+}
+
/* Called once a circuit to a rendezvous point is ready: sends a
* RELAY_COMMAND_RENDEZVOUS1 cell.
*/
@@ -569,6 +585,33 @@ rend_service_rendezvous_is_ready(circuit_t *circuit)
* Manage introduction points
******/
+static circuit_t *
+find_intro_circuit(routerinfo_t *router, const char *pk_digest)
+{
+ circuit_t *circ = NULL;
+
+ while ((circ = circuit_get_next_by_pk_and_purpose(circ,pk_digest,
+ CIRCUIT_PURPOSE_S_INTRO))) {
+ assert(circ->cpath);
+ if (circ->cpath->prev->addr == router->addr &&
+ circ->cpath->prev->port == router->or_port) {
+ return circ;
+ }
+ }
+
+ circ = NULL;
+ while ((circ = circuit_get_next_by_pk_and_purpose(circ,pk_digest,
+ CIRCUIT_PURPOSE_S_ESTABLISH_INTRO))) {
+ assert(circ->cpath);
+ if (circ->cpath->prev->addr == router->addr &&
+ circ->cpath->prev->port == router->or_port) {
+ return circ;
+ }
+ }
+ return NULL;
+}
+
+
/* For every service, check how many intro points it currently has, and:
* - Pick new intro points as necessary.
* - Launch circuits to any new intro points.
@@ -579,9 +622,8 @@ int rend_services_init(void) {
routerinfo_t *router;
routerlist_t *rl;
rend_service_t *service;
- circuit_t *circ;
char *desc, *intro;
- int changed, found, prev_intro_nodes, desc_len;
+ int changed, prev_intro_nodes, desc_len;
router_get_routerlist(&rl);
@@ -593,26 +635,11 @@ int rend_services_init(void) {
/* Find out which introduction points we really have for this service. */
for (j=0;j< smartlist_len(service->intro_nodes); ++j) {
-
router = router_get_by_nickname(smartlist_get(service->intro_nodes,j));
- if (!router)
- goto remove_point;
- circ = NULL;
- found = 1;
- while ((circ = circuit_get_next_by_pk_and_purpose(
- circ,service->pk_digest,
- CIRCUIT_PURPOSE_S_ESTABLISH_INTRO))) {
- assert(circ->cpath);
- if (circ->cpath->prev->addr == router->addr &&
- circ->cpath->prev->port == router->or_port) {
- found = 1; break;
- }
+ if (!router || !find_intro_circuit(router,service->pk_digest)) {
+ smartlist_del(service->intro_nodes,j--);
+ changed = 1;
}
- if (found) continue;
-
- remove_point:
- smartlist_del(service->intro_nodes,j--);
- changed = 1;
}
/* We have enough intro points, and the intro points we thought we had were