diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-04-13 20:06:08 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-04-13 20:06:08 +0000 |
commit | 5514ad715bd4a730fe5cff36ae99d9f8c39969f0 (patch) | |
tree | f016490fac99e2af7d37944ba1ccf835b28e1bf6 /src/or | |
parent | baaf58fe1d52e8aa8dd4081b38de9a16ee9d006e (diff) | |
download | tor-5514ad715bd4a730fe5cff36ae99d9f8c39969f0.tar tor-5514ad715bd4a730fe5cff36ae99d9f8c39969f0.tar.gz |
Scan list of servers in directory after reloading fingerprint list; remove any servers that are no longer recognized.
svn:r1613
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/dirserv.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 6c2a0ee77..7ce578c4f 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -15,6 +15,7 @@ extern or_options_t options; /* command-line and config-file options */ static int the_directory_is_dirty = 1; static int list_running_servers(char **nicknames_out); +static void directory_remove_unrecognized(void); /************** Fingerprint handling code ************/ @@ -98,6 +99,8 @@ dirserv_parse_fingerprint_file(const char *fname) memcpy(fingerprint_list, fingerprint_list_tmp, sizeof(fingerprint_entry_t)*n_fingerprints_tmp); n_fingerprints = n_fingerprints_tmp; + /* Delete any routers whose fingerprints we no longer recognize */ + directory_remove_unrecognized(); return 0; } /* error */ @@ -163,6 +166,7 @@ typedef struct descriptor_entry_t { time_t published; size_t desc_len; char *descriptor; + routerinfo_t *router; } descriptor_entry_t; static descriptor_entry_t *descriptor_list[MAX_ROUTERS_IN_DIR]; @@ -172,6 +176,7 @@ static void free_descriptor_entry(descriptor_entry_t *desc) { tor_free(desc->descriptor); tor_free(desc->nickname); + routerinfo_free(desc->router); free(desc); } @@ -293,13 +298,27 @@ dirserv_add_descriptor(const char **desc) (*desc_ent_ptr)->descriptor = tor_malloc(desc_len+1); strncpy((*desc_ent_ptr)->descriptor, start, desc_len); (*desc_ent_ptr)->descriptor[desc_len] = '\0'; + (*desc_ent_ptr)->router = ri; *desc = end; directory_set_dirty(); - routerinfo_free(ri); return 1; } +static void +directory_remove_unrecognized(void) +{ + int i; + for (i = 0; i < n_descriptors; ++i) { + if (dirserv_router_fingerprint_is_known(descriptor_list[i]->router)<=0) { + log(LOG_INFO, "Router %s is no longer recognized", + descriptor_list[i]->nickname); + free_descriptor_entry(descriptor_list[i]); + descriptor_list[i--] = descriptor_list[--n_descriptors]; + } + } +} + void directory_set_dirty() { |