From b48cdc9d4035217b2d4d160778092e104fcd91f9 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Thu, 22 Jul 2004 06:03:53 +0000 Subject: [PATCH] populate router_get_my_routerinfo()->is_verified svn:r2097 --- src/or/connection_or.c | 14 +++++++++++++- src/or/router.c | 10 ++++++---- src/or/routerlist.c | 6 +++++- src/or/routerparse.c | 13 ++++++++++--- 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/src/or/connection_or.c b/src/or/connection_or.c index 4c07f1bec0..1648b02ebe 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -207,8 +207,20 @@ connection_t *connection_or_connect(uint32_t addr, uint16_t port, * Return -1 if conn is broken, else return 0. */ int connection_tls_start_handshake(connection_t *conn, int receiving) { + int use_no_cert=0; conn->state = OR_CONN_STATE_HANDSHAKING; - conn->tls = tor_tls_new(conn->s, receiving); + if(receiving) { /* check if he's 0.0.7 and I'm unverified */ + routerinfo_t *him, *me; + him = router_get_by_digest(conn->identity_digest); + me = router_get_my_routerinfo(); + + if(him && !strncmp(him->platform, "Tor 0.0.7", 9) && + (!me || !me->is_verified)) { + log_fn(LOG_INFO,"He's running 0.0.7, and I'm unverified. Acting like OP."); + use_no_cert = 1; + } + } + conn->tls = tor_tls_new(conn->s, receiving, use_no_cert); if(!conn->tls) { log_fn(LOG_WARN,"tor_tls_new failed. Closing."); return -1; diff --git a/src/or/router.c b/src/or/router.c index 5e295bfbc1..571b5a694b 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -126,14 +126,12 @@ void rotate_onion_key(void) /** The last calculated bandwidth usage for our node. */ static int advertised_bw = 0; - /** Tuck bw away so we can produce it when somebody * calls router_get_advertised_bandwidth() below. */ void router_set_advertised_bandwidth(int bw) { advertised_bw = bw; } - /** Return the value we tucked away above, or zero by default. */ int router_get_advertised_bandwidth(void) { return advertised_bw; @@ -142,8 +140,9 @@ int router_get_advertised_bandwidth(void) { /* Read an RSA secret key key from a file that was once named fname_old, * but is now named fname_new. Rename the file from old to new as needed. */ -crypto_pk_env_t *init_key_from_file_name_changed(const char *fname_old, - const char *fname_new) +static crypto_pk_env_t * +init_key_from_file_name_changed(const char *fname_old, + const char *fname_new) { int fs; @@ -532,6 +531,9 @@ int router_rebuild_descriptor(void) { ri->exit_policy = NULL; /* zero it out first */ router_add_exit_policy_from_config(ri); ri->is_trusted_dir = authdir_mode(); + if(desc_routerinfo) /* inherit values */ + ri->is_verified = desc_routerinfo->is_verified; + if (desc_routerinfo) routerinfo_free(desc_routerinfo); desc_routerinfo = ri; diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 7f8e466416..bb64504930 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -794,7 +794,7 @@ void routerlist_update_from_runningrouters(routerlist_t *list, running_routers_t *rr) { int n_routers, i; - routerinfo_t *router; + routerinfo_t *router, *me = router_get_my_routerinfo(); if (!list) return; if (list->published_on >= rr->published_on) @@ -802,6 +802,10 @@ void routerlist_update_from_runningrouters(routerlist_t *list, if (list->running_routers_updated_on >= rr->published_on) return; + if(me) /* learn if the dirservers think I'm verified */ + router_update_status_from_smartlist(me, + rr->published_on, + rr->running_routers); n_routers = smartlist_len(list->routers); for (i=0; irouters, i); diff --git a/src/or/routerparse.c b/src/or/routerparse.c index d25f2d17cd..96cf1c3dee 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -313,8 +313,8 @@ int check_software_version_against_directory(const char *directory, */ int /* Should be static; exposed for unit tests */ router_parse_routerlist_from_directory(const char *str, - routerlist_t **dest, - crypto_pk_env_t *pkey) + routerlist_t **dest, + crypto_pk_env_t *pkey) { directory_token_t *tok; char digest[DIGEST_LEN]; @@ -389,11 +389,18 @@ router_parse_routerlist_from_directory(const char *str, } tok->n_args = 0; /* Don't free the strings in good_nickname_lst yet. */ + /* Determine if my routerinfo is considered verified. */ + { + routerinfo_t *me = router_get_my_routerinfo(); + if(me) + router_update_status_from_smartlist(me, time(NULL), good_nickname_list); + } + /* Read the router list from s, advancing s up past the end of the last * router. */ str = end; if (router_parse_list_from_string(&str, &new_dir, - good_nickname_list)) { + good_nickname_list)) { log_fn(LOG_WARN, "Error reading routers from directory"); goto err; }