[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Don"t use Tor version 0.0.5 for intro/rendezvous points. (...
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv4745/src/or
Modified Files:
onion.c or.h rendservice.c router.c routerlist.c
Log Message:
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.)
Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -d -r1.149 -r1.150
--- onion.c 7 Apr 2004 21:12:54 -0000 1.149
+++ onion.c 7 Apr 2004 21:36:03 -0000 1.150
@@ -337,7 +337,16 @@
{
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);
}
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.303
retrieving revision 1.304
diff -u -d -r1.303 -r1.304
--- or.h 7 Apr 2004 19:46:27 -0000 1.303
+++ or.h 7 Apr 2004 21:36:03 -0000 1.304
@@ -461,6 +461,8 @@
int is_running;
+ char *platform;
+
/* link info */
uint32_t bandwidthrate;
uint32_t bandwidthburst;
@@ -996,6 +998,8 @@
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);
Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- rendservice.c 6 Apr 2004 22:05:49 -0000 1.35
+++ rendservice.c 7 Apr 2004 21:36:03 -0000 1.36
@@ -657,10 +657,14 @@
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 @@
/* 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 @@
}
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 @@
}
}
smartlist_free(intro_routers);
+ smartlist_free(exclude_routers);
return 0;
}
Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- router.c 7 Apr 2004 19:46:27 -0000 1.24
+++ router.c 7 Apr 2004 21:36:03 -0000 1.25
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
router->dir_port,
(int) router->bandwidthrate,
/* XXXBC also write bandwidthburst */
- platform,
+ router->platform,
published,
onion_pkey, link_pkey, identity_pkey);
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- routerlist.c 7 Apr 2004 19:57:39 -0000 1.56
+++ routerlist.c 7 Apr 2004 21:36:03 -0000 1.57
@@ -236,6 +236,24 @@
}
}
+/* 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 @@
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 @@
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 @@
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]);