From 541add90a16a2b7b75e5aa3a54071f3a5db00502 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 1 Jul 2004 01:16:59 +0000 Subject: 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 --- src/or/connection_or.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/or/connection_or.c') 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 router. * * If router is me, do nothing. If we're already connected to router, -- cgit v1.2.3-54-g00ecf