[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[or-cvs] put in the support for "router twins"
Update of /home/or/cvsroot/src/or
In directory moria.seul.org:/home/arma/work/onion/cvs/src/or
Modified Files:
circuit.c command.c connection.c connection_ap.c
connection_or.c main.c or.h
Log Message:
put in the support for 'router twins'
basically, a twin is a router which is different except it shares
the same keypair. so in cases where we want to find a "next router"
and all we really care is that it can decrypt the next onion layer,
then a twin is just as good.
we still need to decide how to mark twins in the routerinfo_t and in
the routers config file.
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- circuit.c 5 Jul 2002 06:27:23 -0000 1.4
+++ circuit.c 8 Jul 2002 08:59:15 -0000 1.5
@@ -98,7 +98,7 @@
if(test_aci == 0)
return get_unique_aci_by_addr_port(addr, port, aci_type); /* try again */
- conn = connection_get_by_addr_port(addr,port);
+ conn = connection_exact_get_by_addr_port(addr,port);
if(!conn) /* there can't be a conflict -- no connection of that sort yet */
return test_aci;
Index: command.c
===================================================================
RCS file: /home/or/cvsroot/src/or/command.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- command.c 2 Jul 2002 09:36:58 -0000 1.3
+++ command.c 8 Jul 2002 08:59:15 -0000 1.4
@@ -91,7 +91,7 @@
}
if(circ->n_addr && circ->n_port) { /* must send create cells to the next router */
- n_conn = connection_get_by_addr_port(circ->n_addr,circ->n_port);
+ n_conn = connection_twin_get_by_addr_port(circ->n_addr,circ->n_port);
if(!n_conn || n_conn->type != CONN_TYPE_OR) {
/* i've disabled making connections through OPs, but it's definitely
* possible here. I'm not sure if it would be a bug or a feature. -RD
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- connection.c 3 Jul 2002 17:30:59 -0000 1.4
+++ connection.c 8 Jul 2002 08:59:15 -0000 1.5
@@ -205,7 +205,7 @@
if(role & ROLE_OR_CONNECT_ALL) {
for (i=0;i<rarray_len;i++) {
router = router_array[i];
- if(!connection_get_by_addr_port(router->addr,router->or_port)) { /* not in the list */
+ if(!connection_exact_get_by_addr_port(router->addr,router->or_port)) { /* not in the list */
log(LOG_DEBUG,"retry_all_connections(): connecting to OR %s:%u.",router->address,ntohs(router->or_port));
connection_or_connect_as_or(router, prkey, &local);
}
Index: connection_ap.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_ap.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- connection_ap.c 5 Jul 2002 06:27:23 -0000 1.2
+++ connection_ap.c 8 Jul 2002 08:59:15 -0000 1.3
@@ -202,7 +202,7 @@
log(LOG_DEBUG,"ap_handshake_establish_circuit(): Looking for firsthop '%s:%u'",
firsthop->address,ntohs(firsthop->or_port));
- n_conn = connection_get_by_addr_port(firsthop->addr,firsthop->or_port);
+ n_conn = connection_twin_get_by_addr_port(firsthop->addr,firsthop->or_port);
if(!n_conn) { /* not currently connected */
if(global_role & ROLE_OR_CONNECT_ALL) { /* we would be connected if he were up. but he's not. */
log(LOG_DEBUG,"ap_handshake_establish_circuit(): Route's firsthop isn't connected.");
Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- connection_or.c 3 Jul 2002 17:30:59 -0000 1.4
+++ connection_or.c 8 Jul 2002 08:59:15 -0000 1.5
@@ -583,7 +583,7 @@
log(LOG_DEBUG,"or_handshake_server_process_auth() : Router identified as %s:%u.",
router->address,ntohs(router->or_port));
- if(connection_get_by_addr_port(addr,port)) {
+ if(connection_exact_get_by_addr_port(addr,port)) {
log(LOG_DEBUG,"or_handshake_server_process_auth(): That router is already connected. Dropping.");
return -1;
}
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- main.c 5 Jul 2002 06:27:23 -0000 1.5
+++ main.c 8 Jul 2002 08:59:15 -0000 1.6
@@ -111,7 +111,25 @@
return 0;
}
-connection_t *connection_get_by_addr_port(uint32_t addr, uint16_t port) {
+connection_t *connection_twin_get_by_addr_port(uint32_t addr, uint16_t port) {
+ int i;
+ connection_t *conn;
+
+ /* first check if it's there exactly */
+ conn = connection_exact_get_by_addr_port(addr,port);
+ if(conn)
+ return conn;
+
+ /* now check if any of the other open connections are a twin for this one */
+
+ /* XXX */
+
+ /* guess not */
+ return NULL;
+
+}
+
+connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port) {
int i;
connection_t *conn;
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- or.h 3 Jul 2002 17:30:59 -0000 1.5
+++ or.h 8 Jul 2002 08:59:15 -0000 1.6
@@ -486,7 +486,8 @@
int connection_remove(connection_t *conn);
void connection_set_poll_socket(connection_t *conn);
-connection_t *connection_get_by_addr_port(uint32_t addr, uint16_t port);
+connection_t *connection_twin_get_by_addr_port(uint32_t addr, uint16_t port);
+connection_t *connection_exact_get_by_addr_port(uint32_t addr, uint16_t port);
connection_t *connection_get_by_type(int type);