static int the_directory_is_dirty = 1;
static int list_running_servers(char **nicknames_out);
+static void directory_remove_unrecognized(void);
/************** Fingerprint handling code ************/
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 */
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];
{
tor_free(desc->descriptor);
tor_free(desc->nickname);
+ routerinfo_free(desc->router);
free(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()
{