aboutsummaryrefslogtreecommitdiff
path: root/src/or/rendservice.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-04-06 22:05:49 +0000
committerNick Mathewson <nickm@torproject.org>2004-04-06 22:05:49 +0000
commitf24519e4b9aeb39cbed50283936b86220c199e81 (patch)
tree4bc790ec74dc9ed9bd93efc24977468494d7113f /src/or/rendservice.c
parent95f0e36f0818ba703731cf6e026fc4f9a4eaa9f7 (diff)
downloadtor-f24519e4b9aeb39cbed50283936b86220c199e81.tar
tor-f24519e4b9aeb39cbed50283936b86220c199e81.tar.gz
Set correct address and port mappings on outgoing rendezvous connections
svn:r1513
Diffstat (limited to 'src/or/rendservice.c')
-rw-r--r--src/or/rendservice.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 40a15aa6c..be7ddcb1e 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -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