diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-07-01 01:16:59 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-07-01 01:16:59 +0000 |
commit | 541add90a16a2b7b75e5aa3a54071f3a5db00502 (patch) | |
tree | e6fbde49f0a12931e102a5211651fd014d06f9b9 /src/or/connection_or.c | |
parent | f42f04c859a68dab45d021dd4197da816ec72b07 (diff) | |
download | tor-541add90a16a2b7b75e5aa3a54071f3a5db00502.tar.gz tor-541add90a16a2b7b75e5aa3a54071f3a5db00502.zip |
Track routers by hash of identity key; use hex hash of identity key in place of nickname; accept (and use) hash of identity key in EXTEND cells.
svn:r1994
Diffstat (limited to 'src/or/connection_or.c')
-rw-r--r-- | src/or/connection_or.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 028a806bf0..abd8476f75 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -107,11 +107,34 @@ connection_or_init_conn_from_router(connection_t *conn, routerinfo_t *router) { conn->port = router->or_port; conn->receiver_bucket = conn->bandwidth = router->bandwidthburst; conn->identity_pkey = crypto_pk_dup_key(router->identity_pkey); + crypto_pk_get_digest(conn->identity_pkey, conn->identity_digest); conn->nickname = tor_strdup(router->nickname); tor_free(conn->address); conn->address = tor_strdup(router->address); } +static void +connection_or_init_conn_from_address(connection_t *conn, + uint32_t addr, uint16_t port, + const char *id_digest) +{ + routerinfo_t *r; + r = router_get_by_digest(id_digest); + if (r) { + connection_or_init_conn_from_router(conn,r); + return; + } + conn->addr = addr; + conn->port = port; + /* This next part isn't really right, but it's good enough for now. */ + conn->receiver_bucket = conn->bandwidth = options.BandwidthBurst; + memcpy(conn->identity_digest, id_digest, DIGEST_LEN); + conn->nickname = tor_malloc(HEX_DIGEST_LEN+1); + base16_encode(conn->nickname, HEX_DIGEST_LEN+1, + conn->identity_digest, DIGEST_LEN); + /* Do something about address? Or is it already set? XXXX NMNM */ +} + /** Launch a new OR connection to <b>router</b>. * * If <b>router</b> is me, do nothing. If we're already connected to <b>router</b>, |