aboutsummaryrefslogtreecommitdiff
path: root/src/feature/nodelist
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2021-06-29 10:55:46 -0400
committerDavid Goulet <dgoulet@torproject.org>2021-06-29 10:55:46 -0400
commite9edcea0ca9aaaa208a52149b742d048eaaff142 (patch)
tree3555c23b2146bab37455938d4bf36adddaedc09c /src/feature/nodelist
parent23451ef2fee7cecb3e08757807c90a27b9cfffc1 (diff)
parent01a5b41be0aa0d8ab2574d7075af8db2878a1cf3 (diff)
downloadtor-e9edcea0ca9aaaa208a52149b742d048eaaff142.tar.gz
tor-e9edcea0ca9aaaa208a52149b742d048eaaff142.zip
Merge branch 'tor-gitlab/mr/275'
Diffstat (limited to 'src/feature/nodelist')
-rw-r--r--src/feature/nodelist/routerlist.c24
-rw-r--r--src/feature/nodelist/routerlist.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/src/feature/nodelist/routerlist.c b/src/feature/nodelist/routerlist.c
index 565d4596d4..fbf9e026c2 100644
--- a/src/feature/nodelist/routerlist.c
+++ b/src/feature/nodelist/routerlist.c
@@ -2012,6 +2012,30 @@ routerlist_remove_old_routers(void)
router_rebuild_store(RRS_DONT_REMOVE_OLD,&routerlist->extrainfo_store);
}
+/* Drop every bridge descriptor in our routerlist. Used by the external
+ * 'bridgestrap' tool to discard bridge descriptors so that it can then
+ * do a clean reachability test. */
+void
+routerlist_drop_bridge_descriptors(void)
+{
+ routerinfo_t *router;
+ int i;
+
+ if (!routerlist)
+ return;
+
+ for (i = 0; i < smartlist_len(routerlist->routers); ++i) {
+ router = smartlist_get(routerlist->routers, i);
+ if (router->purpose == ROUTER_PURPOSE_BRIDGE) {
+ log_notice(LD_DIR,
+ "Dropping existing bridge descriptor for %s",
+ router_describe(router));
+ routerlist_remove(routerlist, router, 0, time(NULL));
+ i--;
+ }
+ }
+}
+
/** We just added a new set of descriptors. Take whatever extra steps
* we need. */
void
diff --git a/src/feature/nodelist/routerlist.h b/src/feature/nodelist/routerlist.h
index 7dc748c94b..7ba305baf6 100644
--- a/src/feature/nodelist/routerlist.h
+++ b/src/feature/nodelist/routerlist.h
@@ -145,6 +145,7 @@ was_router_added_t router_add_extrainfo_to_routerlist(
int from_cache, int from_fetch);
void routerlist_descriptors_added(smartlist_t *sl, int from_cache);
void routerlist_remove_old_routers(void);
+void routerlist_drop_bridge_descriptors(void);
int router_load_single_router(const char *s, uint8_t purpose, int cache,
const char **msg);
int router_load_routers_from_string(const char *s, const char *eos,