Use service IDs in rendmid. (rendclient and common require no changes, it seems)

svn:r1594
This commit is contained in:
Nick Mathewson 2004-04-12 18:10:28 +00:00
parent 2321d21b3b
commit fc5a766298

View File

@ -16,7 +16,7 @@ rend_mid_establish_intro(circuit_t *circ, const char *request, int request_len)
char pk_digest[DIGEST_LEN]; char pk_digest[DIGEST_LEN];
int asn1len; int asn1len;
circuit_t *c; circuit_t *c;
char hexid[9]; char serviceid[REND_SERVICE_ID_LEN+1];
log_fn(LOG_INFO, log_fn(LOG_INFO,
"Received an ESTABLISH_INTRO request on circuit %d", circ->p_circ_id); "Received an ESTABLISH_INTRO request on circuit %d", circ->p_circ_id);
@ -64,14 +64,17 @@ rend_mid_establish_intro(circuit_t *circ, const char *request, int request_len)
goto err; goto err;
} }
hex_encode(pk_digest, 4, hexid); if (base32_encode(serviceid, REND_SERVICE_ID_LEN+1,
pk_digest,10)) {
goto err;
}
/* Close any other intro circuits with the same pk. */ /* Close any other intro circuits with the same pk. */
c = NULL; c = NULL;
while ((c = circuit_get_next_by_pk_and_purpose( while ((c = circuit_get_next_by_pk_and_purpose(
c,pk_digest,CIRCUIT_PURPOSE_INTRO_POINT))) { c,pk_digest,CIRCUIT_PURPOSE_INTRO_POINT))) {
log_fn(LOG_INFO, "Replacing old circuit %d for service %s", log_fn(LOG_INFO, "Replacing old circuit %d for service %s",
c->p_circ_id, hexid); c->p_circ_id, serviceid);
circuit_mark_for_close(c); circuit_mark_for_close(c);
} }
@ -89,7 +92,7 @@ rend_mid_establish_intro(circuit_t *circ, const char *request, int request_len)
log_fn(LOG_INFO, log_fn(LOG_INFO,
"Established introduction point on circuit %d for service %s", "Established introduction point on circuit %d for service %s",
circ->p_circ_id, hexid); circ->p_circ_id, serviceid);
return 0; return 0;
truncated: truncated:
@ -108,7 +111,7 @@ int
rend_mid_introduce(circuit_t *circ, const char *request, int request_len) rend_mid_introduce(circuit_t *circ, const char *request, int request_len)
{ {
circuit_t *intro_circ; circuit_t *intro_circ;
char hexid[9]; char serviceid[REND_SERVICE_ID_LEN+1];
if (circ->purpose != CIRCUIT_PURPOSE_OR || circ->n_conn) { if (circ->purpose != CIRCUIT_PURPOSE_OR || circ->n_conn) {
log_fn(LOG_WARN, "Rejecting INTRODUCE1 on non-OR or non-edge circuit %d", log_fn(LOG_WARN, "Rejecting INTRODUCE1 on non-OR or non-edge circuit %d",
@ -124,7 +127,10 @@ rend_mid_introduce(circuit_t *circ, const char *request, int request_len)
goto err; goto err;
} }
hex_encode(request,4,hexid); if (base32_encode(serviceid, REND_SERVICE_ID_LEN+1, request,10)) {
goto err;
}
/* The first 20 bytes are all we look at: they have a hash of Bob's PK. */ /* The first 20 bytes are all we look at: they have a hash of Bob's PK. */
intro_circ = circuit_get_next_by_pk_and_purpose( intro_circ = circuit_get_next_by_pk_and_purpose(
@ -132,13 +138,13 @@ rend_mid_introduce(circuit_t *circ, const char *request, int request_len)
if (!intro_circ) { if (!intro_circ) {
log_fn(LOG_WARN, log_fn(LOG_WARN,
"No intro circ found for INTRODUCE1 cell (%s) from circuit %d; dropping", "No intro circ found for INTRODUCE1 cell (%s) from circuit %d; dropping",
hexid, circ->p_circ_id); serviceid, circ->p_circ_id);
goto err; goto err;
} }
log_fn(LOG_INFO, log_fn(LOG_INFO,
"Sending introduction request for service %s from circ %d to circ %d", "Sending introduction request for service %s from circ %d to circ %d",
hexid, circ->p_circ_id, intro_circ->p_circ_id); serviceid, circ->p_circ_id, intro_circ->p_circ_id);
/* Great. Now we just relay the cell down the circuit. */ /* Great. Now we just relay the cell down the circuit. */
if (connection_edge_send_command(NULL, intro_circ, if (connection_edge_send_command(NULL, intro_circ,
@ -188,7 +194,9 @@ rend_mid_establish_rendezvous(circuit_t *circ, const char *request, int request_
circ->purpose = CIRCUIT_PURPOSE_REND_POINT_WAITING; circ->purpose = CIRCUIT_PURPOSE_REND_POINT_WAITING;
memcpy(circ->rend_cookie, request, REND_COOKIE_LEN); memcpy(circ->rend_cookie, request, REND_COOKIE_LEN);
hex_encode(request,4,hexid); hex_encode(request,4,hexid);
log_fn(LOG_INFO, "Established rendezvous point on circuit %d for cookie %s", log_fn(LOG_INFO, "Established rendezvous point on circuit %d for cookie %s",
circ->p_circ_id, hexid); circ->p_circ_id, hexid);