summaryrefslogtreecommitdiff
path: root/src/or/networkstatus.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2007-12-19 04:58:58 +0000
committerRoger Dingledine <arma@torproject.org>2007-12-19 04:58:58 +0000
commitf405f9b6140d9f001bb96364dc4c240afc222103 (patch)
tree8c16b2430bf2e4b0a19e010d640cb0291db17152 /src/or/networkstatus.c
parenta697573ce911f0b16e5cb5e8d73d4863883f82ac (diff)
downloadtor-f405f9b6140d9f001bb96364dc4c240afc222103.tar.gz
tor-f405f9b6140d9f001bb96364dc4c240afc222103.zip
Make getinfo ns/purpose/bridge actually work
Also, dump our bridge router status entries to disk every 30 minutes. svn:r12871
Diffstat (limited to 'src/or/networkstatus.c')
-rw-r--r--src/or/networkstatus.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 884bc0a3a6..e2f3d9281b 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -1685,9 +1685,8 @@ networkstatus_getinfo_helper_single(routerstatus_t *rs)
* shouldn't use this for general-purpose routers, since those
* should be listed from the consensus, not from the routers list). */
char *
-networkstatus_getinfo_by_purpose(const char *purpose_string)
+networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now)
{
- time_t now = time(NULL);
time_t cutoff = now - ROUTER_MAX_AGE_TO_PUBLISH;
char *answer;
routerlist_t *rl = router_get_routerlist();
@@ -1720,6 +1719,21 @@ networkstatus_getinfo_by_purpose(const char *purpose_string)
return answer;
}
+/** Write out router status entries for all our bridge descriptors. */
+void
+networkstatus_dump_bridge_status_to_file(time_t now)
+{
+ char *status = networkstatus_getinfo_by_purpose("bridge", now);
+ or_options_t *options = get_options();
+ size_t len = strlen(options->DataDirectory) + 32;
+ char *fname = tor_malloc(len);
+ tor_snprintf(fname, len, "%s"PATH_SEPARATOR"networkstatus-bridges",
+ options->DataDirectory);
+ write_str_to_file(fname,status,0);
+ tor_free(fname);
+ tor_free(status);
+}
+
/** If <b>question</b> is a string beginning with "ns/" in a format the
* control interface expects for a GETINFO question, set *<b>answer</b> to a
* newly-allocated string containing networkstatus lines for the appropriate
@@ -1756,7 +1770,7 @@ getinfo_helper_networkstatus(control_connection_t *conn,
} else if (!strcmpstart(question, "ns/name/")) {
status = router_get_consensus_status_by_nickname(question+8, 0);
} else if (!strcmpstart(question, "ns/purpose/")) {
- *answer = networkstatus_getinfo_by_purpose(question+11);
+ *answer = networkstatus_getinfo_by_purpose(question+11, time(NULL));
return *answer ? 0 : -1;
} else {
return -1;