[or-cvs] Set correct address and port mappings on outgoing rendezvou...
Nick Mathewson
nickm at seul.org
Tue Apr 6 22:05:55 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv4313/or
Modified Files:
connection_edge.c or.h rendservice.c
Log Message:
Set correct address and port mappings on outgoing rendezvous connections
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.144
retrieving revision 1.145
diff -u -d -r1.144 -r1.145
--- connection_edge.c 6 Apr 2004 21:52:01 -0000 1.144
+++ connection_edge.c 6 Apr 2004 22:05:49 -0000 1.145
@@ -1134,7 +1134,7 @@
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 @@
}
}
-/* 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 */
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.301
retrieving revision 1.302
diff -u -d -r1.301 -r1.302
--- or.h 6 Apr 2004 21:52:01 -0000 1.301
+++ or.h 6 Apr 2004 22:05:49 -0000 1.302
@@ -1090,6 +1090,8 @@
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);
Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- rendservice.c 6 Apr 2004 21:25:11 -0000 1.34
+++ rendservice.c 6 Apr 2004 22:05:49 -0000 1.35
@@ -735,6 +735,41 @@
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
More information about the tor-commits
mailing list