[or-cvs] checkpoint commit: rend closer to working, still not there ...
Roger Dingledine
arma at seul.org
Tue Apr 6 20:25:20 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
circuit.c connection_edge.c rendclient.c rendcommon.c
Log Message:
checkpoint commit: rend closer to working, still not there yet
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.185
retrieving revision 1.186
diff -u -d -r1.185 -r1.186
--- circuit.c 6 Apr 2004 20:16:12 -0000 1.185
+++ circuit.c 6 Apr 2004 20:25:18 -0000 1.186
@@ -1534,8 +1534,8 @@
{
assert(cp->f_crypto);
assert(cp->b_crypto);
- assert(cp->addr);
- assert(cp->port);
+// assert(cp->addr); /* these are zero for rendezvous extra-hops */
+// assert(cp->port);
switch(cp->state)
{
case CPATH_STATE_CLOSED:
Index: connection_edge.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_edge.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- connection_edge.c 5 Apr 2004 22:43:01 -0000 1.142
+++ connection_edge.c 6 Apr 2004 20:25:18 -0000 1.143
@@ -11,6 +11,7 @@
static int connection_ap_handshake_process_socks(connection_t *conn);
static int connection_exit_begin_conn(cell_t *cell, circuit_t *circ);
+static int connection_exit_set_rendezvous_addr_port(connection_t *conn);
static void connection_edge_consider_sending_sendme(connection_t *conn);
static uint32_t client_dns_lookup_entry(const char *address);
@@ -144,8 +145,9 @@
payload[0] = reason;
if(reason == END_STREAM_REASON_EXITPOLICY) {
+ /* this is safe even for rend circs, because they never fail
+ * because of exitpolicy */
set_uint32(payload+1, htonl(conn->addr));
-// *(uint32_t *)(payload+1) = htonl(conn->addr);
payload_len += 4;
}
@@ -281,7 +283,8 @@
log_fn(LOG_INFO,"Got a relay-level padding cell. Dropping.");
return 0;
case RELAY_COMMAND_BEGIN:
- if(edge_type == EDGE_AP) {
+ if (edge_type == EDGE_AP &&
+ circ->purpose != CIRCUIT_PURPOSE_S_REND_JOINED) {
log_fn(LOG_WARN,"relay begin request unsupported at AP. Dropping.");
return 0;
}
@@ -479,10 +482,16 @@
if(connection_wants_to_flush(conn)) /* in case there are any queued relay cells */
connection_start_writing(conn);
/* deliver a 'connected' relay cell back through the circuit. */
- *(uint32_t*)connected_payload = htonl(conn->addr);
- if(connection_edge_send_command(conn, circuit_get_by_conn(conn),
- RELAY_COMMAND_CONNECTED, connected_payload, 4, NULL) < 0)
- return 0; /* circuit is closed, don't continue */
+ if(*conn->rend_query) { /* rendezvous stream */
+ if(connection_edge_send_command(conn, circuit_get_by_conn(conn),
+ RELAY_COMMAND_CONNECTED, NULL, 0, conn->cpath_layer) < 0)
+ return 0; /* circuit is closed, don't continue */
+ } else {
+ *(uint32_t*)connected_payload = htonl(conn->addr);
+ if(connection_edge_send_command(conn, circuit_get_by_conn(conn),
+ RELAY_COMMAND_CONNECTED, connected_payload, 4, conn->cpath_layer) < 0)
+ return 0; /* circuit is closed, don't continue */
+ }
assert(conn->package_window > 0);
return connection_edge_process_inbuf(conn); /* in case the server has written anything */
case AP_CONN_STATE_OPEN:
@@ -1108,9 +1117,7 @@
n_stream = connection_new(CONN_TYPE_EXIT);
n_stream->stream_id = rh.stream_id;
- n_stream->address = tor_strdup(cell->payload + RELAY_HEADER_SIZE);
n_stream->port = atoi(colon+1);
- n_stream->state = EXIT_CONN_STATE_RESOLVING;
/* leave n_stream->s at -1, because it's not yet valid */
n_stream->package_window = STREAMWINDOW_START;
n_stream->deliver_window = STREAMWINDOW_START;
@@ -1124,6 +1131,22 @@
n_stream->next_stream = circ->n_streams;
circ->n_streams = n_stream;
+ 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) {
+ log_fn(LOG_WARN,"Didn't find rendezvous service (port %d)",n_stream->port);
+ connection_mark_for_close(n_stream,0 /* XXX */);
+ return 0;
+ }
+ n_stream->state = EXIT_CONN_STATE_CONNECTING;
+ n_stream->cpath_layer = circ->cpath->prev; /* link it */
+ connection_exit_connect(n_stream);
+ return 0;
+ }
+ n_stream->address = tor_strdup(cell->payload + RELAY_HEADER_SIZE);
+ n_stream->state = EXIT_CONN_STATE_RESOLVING;
+
/* send it off to the gethostbyname farm */
switch(dns_resolve(n_stream)) {
case 1: /* resolve worked */
@@ -1145,7 +1168,8 @@
void connection_exit_connect(connection_t *conn) {
unsigned char connected_payload[4];
- if(router_compare_to_my_exit_policy(conn) == ADDR_POLICY_REJECTED) {
+ if (!*conn->rend_query &&
+ router_compare_to_my_exit_policy(conn) == ADDR_POLICY_REJECTED) {
log_fn(LOG_INFO,"%s:%d failed exit policy. Closing.", conn->address, conn->port);
connection_mark_for_close(conn, END_STREAM_REASON_EXITPOLICY);
return;
@@ -1176,9 +1200,29 @@
connection_watch_events(conn, POLLIN);
/* also, deliver a 'connected' cell back through the circuit. */
- *(uint32_t*)connected_payload = htonl(conn->addr);
- connection_edge_send_command(conn, circuit_get_by_conn(conn), RELAY_COMMAND_CONNECTED,
- connected_payload, 4, NULL);
+ if(*conn->rend_query) { /* rendezvous stream */
+ /* don't send an address back! */
+ connection_edge_send_command(conn, circuit_get_by_conn(conn), RELAY_COMMAND_CONNECTED,
+ NULL, 0, conn->cpath_layer);
+ } else { /* normal stream */
+ *(uint32_t*)connected_payload = htonl(conn->addr);
+ connection_edge_send_command(conn, circuit_get_by_conn(conn), RELAY_COMMAND_CONNECTED,
+ connected_payload, 4, conn->cpath_layer);
+ }
+}
+
+/* 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_ap_can_use_exit(connection_t *conn, routerinfo_t *exit)
Index: rendclient.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendclient.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- rendclient.c 6 Apr 2004 20:23:58 -0000 1.21
+++ rendclient.c 6 Apr 2004 20:25:18 -0000 1.22
@@ -148,7 +148,7 @@
connection_ap_attach_pending();
}
-/* Called when we recieve a RENDEZVOUS_ESTABLISHED cell; changes the state of
+/* Called when we receive a RENDEZVOUS_ESTABLISHED cell; changes the state of
* the circuit to C_REND_READY.
*/
int
Index: rendcommon.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendcommon.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- rendcommon.c 6 Apr 2004 03:44:36 -0000 1.19
+++ rendcommon.c 6 Apr 2004 20:25:18 -0000 1.20
@@ -4,7 +4,7 @@
#include "or.h"
-/* Free the storage held by held by 'desc'.
+/* Free the storage held by 'desc'.
*/
void rend_service_descriptor_free(rend_service_descriptor_t *desc)
{
@@ -20,8 +20,8 @@
tor_free(desc);
}
-/* Encode a service descriptor for 'desc', and sign it with 'key'. Stores
- * the descriptor in *str_out, and sets *len_out to its length.
+/* Encode a service descriptor for 'desc', and sign it with 'key'. Store
+ * the descriptor in *str_out, and set *len_out to its length.
*/
int
rend_encode_service_descriptor(rend_service_descriptor_t *desc,
@@ -146,7 +146,7 @@
typedef struct rend_cache_entry_t {
int len; /* Length of desc */
char *desc; /* Service descriptor */
- rend_service_descriptor_t *parsed; /* Parsed vvalue of 'desc' */
+ rend_service_descriptor_t *parsed; /* Parsed value of 'desc' */
} rend_cache_entry_t;
static strmap_t *rend_cache = NULL;
More information about the tor-commits
mailing list