aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2002-07-08 08:59:15 +0000
committerRoger Dingledine <arma@torproject.org>2002-07-08 08:59:15 +0000
commit0a3da3ae37dc048f6079d0e4cffd057d07e13216 (patch)
tree0ca339c217d47f049742c83bac592ebf30dd6b5b
parentb86fecbf47c51b9d1fd4fca0f828d84420d111fb (diff)
downloadtor-0a3da3ae37dc048f6079d0e4cffd057d07e13216.tar
tor-0a3da3ae37dc048f6079d0e4cffd057d07e13216.tar.gz
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. svn:r30
-rw-r--r--src/or/circuit.c2
-rw-r--r--src/or/command.c2
-rw-r--r--src/or/connection.c2
-rw-r--r--src/or/connection_ap.c2
-rw-r--r--src/or/connection_or.c2
-rw-r--r--src/or/main.c20
-rw-r--r--src/or/or.h3
7 files changed, 26 insertions, 7 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c
index 6de76a633..20d6e254f 100644
--- a/src/or/circuit.c
+++ b/src/or/circuit.c
@@ -98,7 +98,7 @@ aci_t get_unique_aci_by_addr_port(uint32_t addr, uint16_t port, int aci_type) {
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;
diff --git a/src/or/command.c b/src/or/command.c
index 621809677..dfe8edbaa 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -91,7 +91,7 @@ void command_process_create_cell(cell_t *cell, connection_t *conn) {
}
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
diff --git a/src/or/connection.c b/src/or/connection.c
index 099936e5d..0b80db796 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -205,7 +205,7 @@ int retry_all_connections(int role, routerinfo_t **router_array, int rarray_len,
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);
}
diff --git a/src/or/connection_ap.c b/src/or/connection_ap.c
index 666dd16cb..0cb1d5314 100644
--- a/src/or/connection_ap.c
+++ b/src/or/connection_ap.c
@@ -202,7 +202,7 @@ int ap_handshake_establish_circuit(connection_t *conn, unsigned int *route, int
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.");
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index a2fb1a796..7badd19c9 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -583,7 +583,7 @@ int or_handshake_server_process_auth(connection_t *conn) {
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;
}
diff --git a/src/or/main.c b/src/or/main.c
index 13ea9184b..b81ca2a46 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -111,7 +111,25 @@ int connection_remove(connection_t *conn) {
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;
diff --git a/src/or/or.h b/src/or/or.h
index 7e8d323b3..75111d80e 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -486,7 +486,8 @@ int connection_add(connection_t *conn);
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);