[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r12871: Make getinfo ns/purpose/bridge actually work Also, dump our (in tor/trunk: . doc src/or)
Author: arma
Date: 2007-12-18 23:58:58 -0500 (Tue, 18 Dec 2007)
New Revision: 12871
Modified:
tor/trunk/ChangeLog
tor/trunk/doc/tor.1.in
tor/trunk/src/or/config.c
tor/trunk/src/or/control.c
tor/trunk/src/or/main.c
tor/trunk/src/or/networkstatus.c
tor/trunk/src/or/or.h
tor/trunk/src/or/rephist.c
Log:
Make getinfo ns/purpose/bridge actually work
Also, dump our bridge router status entries to disk every 30 minutes.
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2007-12-19 04:24:05 UTC (rev 12870)
+++ tor/trunk/ChangeLog 2007-12-19 04:58:58 UTC (rev 12871)
@@ -36,13 +36,17 @@
AlternateBridgeAuthority, and AlternateHSAuthority) that let the
user selectively replace the default directory authorities, rather
than the all-or-nothing replacement that DirServer offers.
- - Tor can now be configured to read a GeoIP file from disk in one of two
- formats. This can be used by controllers to map IPs to countries.
- Eventually, it may support exit-by-country.
- - When possible, bridges remember which countries users are coming
- from, and report aggregate information in their extra-info
- documents, so that the bridge authorities can learn where Tor is
- blocked.
+ - Tor can now be configured to read a GeoIP file from disk in one
+ of two formats. This can be used by controllers to map IP addresses
+ to countries. Eventually, it may support exit-by-country.
+ - When possible, bridge relays remember which countries users
+ are coming from, and report aggregate information in their
+ extra-info documents, so that the bridge authorities can learn
+ where Tor is blocked.
+ - Bridge directory authorities now do reachability testing on the
+ bridges they know. They provide router status summaries to the
+ controller on "getinfo ns/purpose/bridge", and also dump summaries
+ to a file periodically.
o Minor bugfixes:
- The fix in 0.2.0.12-alpha cleared the "hsdir" flag in v3 network
Modified: tor/trunk/doc/tor.1.in
===================================================================
--- tor/trunk/doc/tor.1.in 2007-12-19 04:24:05 UTC (rev 12870)
+++ tor/trunk/doc/tor.1.in 2007-12-19 04:58:58 UTC (rev 12871)
@@ -721,7 +721,7 @@
.LP
.TP
\fBFallbackNetworkstatusFile\fP \fIFILENAME\fP
-If Tor doesn't have a cached networkstatus file, it starts out uses
+If Tor doesn't have a cached networkstatus file, it starts out using
this one instead. Even if this file is out of date, Tor can still use
it to learn about directory mirrors, so it doesn't need to put load on
the authorities. (Default: None).
Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c 2007-12-19 04:24:05 UTC (rev 12870)
+++ tor/trunk/src/or/config.c 2007-12-19 04:58:58 UTC (rev 12871)
@@ -83,6 +83,7 @@
{ "ResolvConf", "ServerDNSResolvConfFile", 0, 1},
{ "SearchDomains", "ServerDNSSearchDomains", 0, 1},
{ "PreferTunnelledDirConns", "PreferTunneledDirConns", 0, 0},
+ { "BridgeAuthoritativeDirectory", "BridgeAuthoritativeDir", 0, 0},
{ NULL, NULL, 0, 0},
};
/* A list of state-file abbreviations, for compatibility. */
Modified: tor/trunk/src/or/control.c
===================================================================
--- tor/trunk/src/or/control.c 2007-12-19 04:24:05 UTC (rev 12870)
+++ tor/trunk/src/or/control.c 2007-12-19 04:58:58 UTC (rev 12871)
@@ -1745,6 +1745,8 @@
"Brief summary of router status by ID (v2 directory format)."),
PREFIX("ns/name/", networkstatus,
"Brief summary of router status by nickname (v2 directory format)."),
+ PREFIX("ns/purpose/", networkstatus,
+ "Brief summary of router status by purpose (v2 directory format)."),
PREFIX("unregistered-servers-", dirserv_unregistered, NULL),
ITEM("network-status", dir,
Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c 2007-12-19 04:24:05 UTC (rev 12870)
+++ tor/trunk/src/or/main.c 2007-12-19 04:58:58 UTC (rev 12871)
@@ -119,8 +119,6 @@
/** How long do we let OR connections handshake before we decide that
* they are obsolete? */
#define TLS_HANDSHAKE_TIMEOUT (60)
-/** How often do we write hidden service usage statistics to disk? */
-#define WRITE_HSUSAGE_INTERVAL (900)
/********* END VARIABLES ************/
@@ -830,7 +828,10 @@
static time_t time_to_try_getting_descriptors = 0;
static time_t time_to_reset_descriptor_failures = 0;
static time_t time_to_add_entropy = 0;
+#define WRITE_HSUSAGE_INTERVAL (30*60)
static time_t time_to_write_hs_statistics = 0;
+#define BRIDGE_STATUSFILE_INTERVAL (30*60)
+ static time_t time_to_write_bridge_status_file = 0;
static time_t time_to_downrate_stability = 0;
#define SAVE_STABILITY_INTERVAL (30*60)
static time_t time_to_save_stability = 0;
@@ -1111,6 +1112,12 @@
hs_usage_write_statistics_to_file(now);
time_to_write_hs_statistics = now+WRITE_HSUSAGE_INTERVAL;
}
+ /** 10b. write bridge networkstatus file to disk */
+ if (options->BridgeAuthoritativeDir &&
+ time_to_write_bridge_status_file < now) {
+ hs_usage_write_statistics_to_file(now);
+ time_to_write_bridge_status_file = now+BRIDGE_STATUSFILE_INTERVAL;
+ }
}
/** Libevent timer: used to invoke second_elapsed_callback() once per
Modified: tor/trunk/src/or/networkstatus.c
===================================================================
--- tor/trunk/src/or/networkstatus.c 2007-12-19 04:24:05 UTC (rev 12870)
+++ tor/trunk/src/or/networkstatus.c 2007-12-19 04:58:58 UTC (rev 12871)
@@ -1685,9 +1685,8 @@
* 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 @@
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 @@
} 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;
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2007-12-19 04:24:05 UTC (rev 12870)
+++ tor/trunk/src/or/or.h 2007-12-19 04:58:58 UTC (rev 12871)
@@ -3361,7 +3361,7 @@
smartlist_t *descs);
char *networkstatus_getinfo_helper_single(routerstatus_t *rs);
-char *networkstatus_getinfo_by_purpose(const char *purpose_string);
+char *networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now);
int getinfo_helper_networkstatus(control_connection_t *conn,
const char *question, char **answer);
void networkstatus_free_all(void);
Modified: tor/trunk/src/or/rephist.c
===================================================================
--- tor/trunk/src/or/rephist.c 2007-12-19 04:24:05 UTC (rev 12870)
+++ tor/trunk/src/or/rephist.c 2007-12-19 04:58:58 UTC (rev 12871)
@@ -2153,21 +2153,21 @@
return buf;
}
-/** Writes current statistics to file. */
+/** Write current statistics about hidden service usage to file. */
void
hs_usage_write_statistics_to_file(time_t now)
{
char *buf;
size_t len;
char *fname;
- or_options_t *options;
+ or_options_t *options = get_options();
/* check if we are up-to-date */
hs_usage_check_if_current_period_is_up_to_date(now);
buf = hs_usage_format_statistics();
- options = get_options();
len = strlen(options->DataDirectory) + 16;
fname = tor_malloc(len);
- tor_snprintf(fname,len, "%s"PATH_SEPARATOR"hsusage", options->DataDirectory);
+ tor_snprintf(fname, len, "%s"PATH_SEPARATOR"hsusage",
+ options->DataDirectory);
write_str_to_file(fname,buf,0);
tor_free(buf);
tor_free(fname);