diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-04-07 21:36:03 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-04-07 21:36:03 +0000 |
commit | 8169da5c30cbea7c73f5d0f56d1a507703aa48cc (patch) | |
tree | 585eb5c25e87798ee35f2ece02bc52bd86d3fadf /src/or | |
parent | 7c7301fe926a9ca0f48ed645f3c4a92466477ce1 (diff) | |
download | tor-8169da5c30cbea7c73f5d0f56d1a507703aa48cc.tar.gz tor-8169da5c30cbea7c73f5d0f56d1a507703aa48cc.zip |
Don't use Tor version 0.0.5 for intro/rendezvous points. (We don't need
to worry about 0.0.4 or earlier, because nobody is running them any more.)
svn:r1533
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/onion.c | 11 | ||||
-rw-r--r-- | src/or/or.h | 4 | ||||
-rw-r--r-- | src/or/rendservice.c | 15 | ||||
-rw-r--r-- | src/or/router.c | 10 | ||||
-rw-r--r-- | src/or/routerlist.c | 26 |
5 files changed, 59 insertions, 7 deletions
diff --git a/src/or/onion.c b/src/or/onion.c index d97c397973..8bc9c0a23c 100644 --- a/src/or/onion.c +++ b/src/or/onion.c @@ -337,7 +337,16 @@ static routerinfo_t *choose_good_exit_server(uint8_t purpose, routerlist_t *dir) { if(purpose == CIRCUIT_PURPOSE_C_GENERAL) return choose_good_exit_server_general(dir); - else + else if (purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND || + purpose == CIRCUIT_PURPOSE_C_REND_JOINED) { + smartlist_t *obsolete_routers; + routerinfo_t *r; + obsolete_routers = smartlist_create(); + router_add_nonrendezvous_to_list(obsolete_routers); + r = router_choose_random_node(dir, options.RendNodes, options.RendExcludeNodes, NULL); + smartlist_free(obsolete_routers); + return r; + } else return router_choose_random_node(dir, options.RendNodes, options.RendExcludeNodes, NULL); } diff --git a/src/or/or.h b/src/or/or.h index 0a0b08591f..ed1f3b494b 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -461,6 +461,8 @@ typedef struct { int is_running; + char *platform; + /* link info */ uint32_t bandwidthrate; uint32_t bandwidthburst; @@ -996,6 +998,8 @@ routerinfo_t *router_get_by_link_pk(crypto_pk_env_t *pk); routerinfo_t *router_get_by_nickname(char *nickname); void router_get_routerlist(routerlist_t **prouterlist); void routerinfo_free(routerinfo_t *router); +int router_version_supports_rendezvous(routerinfo_t *router); +void router_add_nonrendezvous_to_list(smartlist_t *sl); void router_mark_as_down(char *nickname); int router_set_routerlist_from_file(char *routerfile); int router_set_routerlist_from_string(const char *s); diff --git a/src/or/rendservice.c b/src/or/rendservice.c index be7ddcb1ee..2042b6bb4e 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -657,10 +657,14 @@ int rend_services_init(void) { rend_service_t *service; char *desc, *intro; int changed, prev_intro_nodes, desc_len; - smartlist_t *intro_routers; + smartlist_t *intro_routers, *exclude_routers; + int n_old_routers; router_get_routerlist(&rl); intro_routers = smartlist_create(); + exclude_routers = smartlist_create(); + router_add_nonrendezvous_to_list(exclude_routers); + n_old_routers = smartlist_len(exclude_routers); for (i=0; i< smartlist_len(rend_service_list); ++i) { smartlist_clear(intro_routers); @@ -688,12 +692,13 @@ int rend_services_init(void) { /* Remember how many introduction circuits we started with. */ prev_intro_nodes = smartlist_len(service->intro_nodes); + smartlist_add_all(exclude_routers, intro_routers); /* The directory is now here. Pick three ORs as intro points. */ for (j=prev_intro_nodes; j < NUM_INTRO_POINTS; ++j) { router = router_choose_random_node(rl, service->intro_prefer_nodes, service->intro_exclude_nodes, - intro_routers); + exclude_routers); if (!router) { log_fn(LOG_WARN, "Can't establish more than %d introduction points", smartlist_len(service->intro_nodes)); @@ -701,9 +706,14 @@ int rend_services_init(void) { } changed = 1; smartlist_add(intro_routers, router); + smartlist_add(exclude_routers, router); smartlist_add(service->intro_nodes, tor_strdup(router->nickname)); } + /* Reset exclude_routers to include obsolete routers only for the next + * time around the loop. */ + smartlist_truncate(exclude_routers, n_old_routers); + /* If there's no need to republish, stop here. */ if (!changed) continue; @@ -731,6 +741,7 @@ int rend_services_init(void) { } } smartlist_free(intro_routers); + smartlist_free(exclude_routers); return 0; } diff --git a/src/or/router.c b/src/or/router.c index ead4162f58..467f1dd2c6 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -6,6 +6,8 @@ extern or_options_t options; /* command-line and config-file options */ +static void get_platform_str(char *platform, int len); + /************************************************************/ /* private keys */ @@ -353,6 +355,7 @@ const char *router_get_my_descriptor(void) { int router_rebuild_descriptor(void) { routerinfo_t *ri; struct in_addr addr; + char platform[256]; if (!tor_inet_aton(options.Address, &addr)) { log_fn(LOG_ERR, "options.Address didn't hold an IP."); return -1; @@ -369,6 +372,8 @@ int router_rebuild_descriptor(void) { ri->onion_pkey = crypto_pk_dup_key(get_onion_key()); ri->link_pkey = crypto_pk_dup_key(get_link_key()); ri->identity_pkey = crypto_pk_dup_key(get_identity_key()); + get_platform_str(platform, sizeof(platform)); + ri->platform = tor_strdup(platform); ri->bandwidthrate = options.BandwidthRate; ri->bandwidthburst = options.BandwidthBurst; ri->exit_policy = NULL; /* zero it out first */ @@ -401,7 +406,6 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router, char *link_pkey; char *identity_pkey; struct in_addr in; - char platform[256]; char digest[20]; char signature[128]; char published[32]; @@ -415,8 +419,6 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router, routerinfo_t *ri_tmp; #endif - get_platform_str(platform, sizeof(platform)); - if (crypto_pk_cmp_keys(ident_key, router->identity_pkey)) { log_fn(LOG_WARN,"Tried to sign a router with a private key that didn't match router's public key!"); return -1; @@ -455,7 +457,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router, router->dir_port, (int) router->bandwidthrate, /* XXXBC also write bandwidthburst */ - platform, + router->platform, published, onion_pkey, link_pkey, identity_pkey); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index d37e5542b3..088ad3c921 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -236,6 +236,24 @@ void router_add_running_routers_to_smartlist(smartlist_t *sl) { } } +/* Return 0 if router is running a version of Tor too old to be a + * rendezvous/introduction point. Return 1 otherwise. + */ +int router_version_supports_rendezvous(routerinfo_t *router) +{ + return (router->platform && 0==strncasecmp(router->platform,"Tor 0.0.5",9)); +} + +/* Add every router running a version of Tor too old for rend/intro + points to sl. + */ +void router_add_nonrendezvous_to_list(smartlist_t *sl) +{ + SMARTLIST_FOREACH(routerlist->routers, routerinfo_t *, r, + if (!router_version_supports_rendezvous(r)) + smartlist_add(sl,r)); +} + /* Pick a random node from preferred if possible, else from all of dir. * Never pick a node in excluded. * If excludedsmartlist is defined, never pick a node in it either. @@ -333,6 +351,7 @@ void routerinfo_free(routerinfo_t *router) tor_free(router->address); tor_free(router->nickname); + tor_free(router->platform); if (router->onion_pkey) crypto_free_pk_env(router->onion_pkey); if (router->link_pkey) @@ -988,6 +1007,10 @@ routerinfo_t *router_get_entry_from_string(const char *s, router->identity_pkey = tok->key; tok->key = NULL; /* Prevent free */ + if ((tok = find_first_by_keyword(tokens, K_PLATFORM))) { + router->platform = tor_strdup(tok->args[0]); + } + exit_policy_tokens = find_all_exitpolicy(tokens); SMARTLIST_FOREACH(exit_policy_tokens, directory_token_t *, t, if (router_add_exit_policy(router,t)<0) { @@ -1023,6 +1046,9 @@ routerinfo_t *router_get_entry_from_string(const char *s, log_fn(LOG_WARN,"bandwidthrate unreadable or 0. Failing."); goto err; } + if (!router->platform) { + router->platform = tor_strdup("<unknown>"); + } #if XXXBC router->bandwidthburst = atoi(ARGS[6]); |