mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Set correct address and port mappings on outgoing rendezvous connections
svn:r1513
This commit is contained in:
+3
-3
@@ -529,13 +529,13 @@ int crypto_pk_private_sign_digest(crypto_pk_env_t *env, const unsigned char *fro
|
||||
* The encrypted data consists of:
|
||||
*
|
||||
* The source data, padded and encrypted with the public key, if the
|
||||
* padded source data is no longer than the public key.
|
||||
* padded source data is no longer than the public key, and "force"
|
||||
* is false.
|
||||
* OR
|
||||
* The beginning of the source data prefixed with a 16-symmetric key,
|
||||
* The beginning of the source data prefixed with a 16-byte symmetric key,
|
||||
* padded and encrypted with the public key; followed by the rest of
|
||||
* the source data encrypted in AES-CTR mode with the symmetric key.
|
||||
*
|
||||
* DOCDOC force.
|
||||
*/
|
||||
int crypto_pk_public_hybrid_encrypt(crypto_pk_env_t *env,
|
||||
const unsigned char *from,
|
||||
|
||||
@@ -1134,7 +1134,7 @@ static int connection_exit_begin_conn(cell_t *cell, circuit_t *circ) {
|
||||
if(circ->purpose == CIRCUIT_PURPOSE_S_REND_JOINED) {
|
||||
n_stream->address = tor_strdup("(rendezvous)");
|
||||
strcpy(n_stream->rend_query, "yes"); /* XXX kludge */
|
||||
if(connection_exit_set_rendezvous_addr_port(n_stream) < 0) {
|
||||
if(rend_service_set_connection_addr_port(n_stream, circ) < 0) {
|
||||
log_fn(LOG_WARN,"Didn't find rendezvous service (port %d)",n_stream->port);
|
||||
connection_mark_for_close(n_stream,0 /* XXX */);
|
||||
return 0;
|
||||
@@ -1211,20 +1211,6 @@ void connection_exit_connect(connection_t *conn) {
|
||||
}
|
||||
}
|
||||
|
||||
/* This is a beginning rendezvous stream. Look up conn->port,
|
||||
* and assign the actual conn->addr and conn->port. Return -1
|
||||
* if failure, or 0 for success.
|
||||
*/
|
||||
static int
|
||||
connection_exit_set_rendezvous_addr_port(connection_t *conn) {
|
||||
|
||||
/* XXX fill me in */
|
||||
|
||||
conn->addr = 0x7F000001u; /* 127.0.0.1, host order */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int connection_edge_is_rendezvous_stream(connection_t *conn) {
|
||||
assert(conn);
|
||||
if(*conn->rend_query) /* XXX */
|
||||
|
||||
@@ -1090,6 +1090,8 @@ void rend_service_intro_is_ready(circuit_t *circuit);
|
||||
int rend_service_intro_established(circuit_t *circuit, const char *request, int request_len);
|
||||
void rend_service_rendezvous_is_ready(circuit_t *circuit);
|
||||
int rend_service_introduce(circuit_t *circuit, const char *request, int request_len);
|
||||
int rend_service_set_connection_addr_port(connection_t *conn, circuit_t *circ);
|
||||
|
||||
|
||||
/********************************* rendmid.c *******************************/
|
||||
int rend_mid_establish_intro(circuit_t *circ, const char *request, int request_len);
|
||||
|
||||
@@ -735,6 +735,41 @@ int rend_services_init(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This is a beginning rendezvous stream. Look up conn->port,
|
||||
* and assign the actual conn->addr and conn->port. Return -1
|
||||
* if failure, or 0 for success.
|
||||
*/
|
||||
int
|
||||
rend_service_set_connection_addr_port(connection_t *conn, circuit_t *circ)
|
||||
{
|
||||
rend_service_t *service;
|
||||
int i;
|
||||
rend_service_port_config_t *p;
|
||||
char hexid[9];
|
||||
|
||||
assert(circ->purpose == CIRCUIT_PURPOSE_S_REND_JOINED);
|
||||
hex_encode(circ->rend_pk_digest, 4, hexid);
|
||||
service = rend_service_get_by_pk_digest(circ->rend_pk_digest);
|
||||
if (!service) {
|
||||
log_fn(LOG_WARN, "Couldn't find any service associated with pk %s on rendezvous circuit %d; closing",
|
||||
hexid, circ->n_circ_id);
|
||||
circuit_mark_for_close(circ);
|
||||
connection_mark_for_close(conn, 0/*XXX*/);
|
||||
}
|
||||
for (i = 0; i < smartlist_len(service->ports); ++i) {
|
||||
p = smartlist_get(service->ports, i);
|
||||
if (conn->port == p->virtual_port) {
|
||||
conn->addr = p->real_address;
|
||||
conn->port = p->real_port;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
log_fn(LOG_WARN, "No virtual port mapping exists for port %d on service %s",
|
||||
conn->port, hexid);
|
||||
connection_mark_for_close(conn, 0/*XXX*/);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
mode:c
|
||||
|
||||
Reference in New Issue
Block a user