diff options
author | Nick Mathewson <nickm@torproject.org> | 2003-05-09 01:24:44 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2003-05-09 01:24:44 +0000 |
commit | c2e7b5ec3fd019cb1321829c45b6ccbc689609a0 (patch) | |
tree | a5d41701fc730515f4347b1416877cc9bc3a5100 /src | |
parent | 52604afd6229e8134fff61685ad36094408a5ed5 (diff) | |
download | tor-c2e7b5ec3fd019cb1321829c45b6ccbc689609a0.tar tor-c2e7b5ec3fd019cb1321829c45b6ccbc689609a0.tar.gz |
We cant recognize ourself until we resolve all the routers.
svn:r282
Diffstat (limited to 'src')
-rw-r--r-- | src/or/routers.c | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/or/routers.c b/src/or/routers.c index ab9c8b882..499ed6a43 100644 --- a/src/or/routers.c +++ b/src/or/routers.c @@ -117,6 +117,7 @@ void router_get_directory(directory_t **pdirectory) { */ int router_is_me(uint32_t addr, uint16_t port) { + /* XXXX Should this check the key too? */ struct sockaddr_in me; /* my router identity */ if(!options.ORPort) { @@ -667,22 +668,8 @@ static int router_get_list_from_string_tok(char **s, directory_t **dest, log(LOG_ERR, "Error reading router"); return -1; } - switch(router_is_me(router->addr, router->or_port)) { - case 0: /* it's not me */ - router->next = routerlist; - routerlist = router; - break; - case 1: /* it is me */ - if(!my_routerinfo) /* save it, so we can use it for directories */ - my_routerinfo = router; - else - routerlist_free(router); - break; - default: - log(LOG_ERR,"router_get_list_from_string(): router_is_me returned error."); - routerlist_free(routerlist); - return -1; - } + router->next = routerlist; + routerlist = router; } new_router_array = make_rarray(routerlist, &new_rarray_len); @@ -717,20 +704,28 @@ router_resolve(routerinfo_t *router) int router_resolve_directory(directory_t *dir) { - int i, max; + int i, max, remove; if (!dir) dir = directory; max = dir->n_routers; for (i = 0; i < max; ++i) { + remove = 0; if (router_resolve(dir->routers[i])) { log(LOG_INFO, "Couldn\'t resolve router %s; removing", dir->routers[i]->address); + remove = 1; dir->routers[i]->next = NULL; routerlist_free(dir->routers[i]); + } else if (router_is_me(dir->routers[i]->addr, dir->routers[i]->or_port)) { + my_routerinfo = dir->routers[i]; + remove = 1; + } + if (remove) { dir->routers[i] = dir->routers[--max]; dir->routers[max] = NULL; --dir->n_routers; + --i; } } /* This is quick-and-dirty, but it keeps stuff consistant. */ |