summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2007-05-04 08:04:27 +0000
committerRoger Dingledine <arma@torproject.org>2007-05-04 08:04:27 +0000
commitdc795203aa0b5ced09e84cb221c6988d934f51c5 (patch)
tree91b96fba5b4ced04cbabe2e64583586759d8e820 /src
parentd112e7b1ad56ca8f1280572f8bb854a1ca74c2fd (diff)
downloadtor-dc795203aa0b5ced09e84cb221c6988d934f51c5.tar.gz
tor-dc795203aa0b5ced09e84cb221c6988d934f51c5.zip
early skeletal support for running a bridge directory authority
svn:r10112
Diffstat (limited to 'src')
-rw-r--r--src/or/config.c1
-rw-r--r--src/or/directory.c3
-rw-r--r--src/or/dirserv.c25
-rw-r--r--src/or/or.h5
-rw-r--r--src/or/router.c8
5 files changed, 28 insertions, 14 deletions
diff --git a/src/or/config.c b/src/or/config.c
index a68ea5cbda..6755ebf602 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -136,6 +136,7 @@ static config_var_t _option_vars[] = {
VAR("AvoidDiskWrites", BOOL, AvoidDiskWrites, "0"),
VAR("BandwidthBurst", MEMUNIT, BandwidthBurst, "6 MB"),
VAR("BandwidthRate", MEMUNIT, BandwidthRate, "3 MB"),
+ VAR("BridgeAuthoritativeDir", BOOL, BridgeAuthoritativeDir, "0"),
VAR("CircuitBuildTimeout", INTERVAL, CircuitBuildTimeout, "1 minute"),
VAR("CircuitIdleTimeout", INTERVAL, CircuitIdleTimeout, "1 hour"),
VAR("ClientOnly", BOOL, ClientOnly, "0"),
diff --git a/src/or/directory.c b/src/or/directory.c
index 872f13edb8..1587384912 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1831,7 +1831,8 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
if (!strcmp(url,"/tor/dir-all-weaselhack") &&
(conn->_base.addr == 0x7f000001ul) &&
- authdir_mode_v2(options)) {
+ authdir_mode_v2(options) &&
+ !authdir_mode_bridge(options)) {
/* until weasel rewrites his scripts at noreply */
char *new_directory=NULL;
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 95951def4c..6addaba849 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1226,23 +1226,23 @@ dirserv_clear_old_v1_info(time_t now)
}
}
-/** Helper: If we're an authority for the right directory version (v1 if
- * <b>is_v1_object</b> if non-0, else v2), try to regenerate
+/** Helper: If we're an authority for the right directory version
+ * (based on <b>auth_type</b>), try to regenerate
* auth_src as appropriate and return it, falling back to cache_src on
- * failure. If we're a cache, return cache_src.
+ * failure. If we're a cache, simply return cache_src.
*/
static cached_dir_t *
dirserv_pick_cached_dir_obj(cached_dir_t *cache_src,
cached_dir_t *auth_src,
time_t dirty, cached_dir_t *(*regenerate)(void),
const char *name,
- int is_v1_object)
+ authority_type_t auth_type)
{
or_options_t *options = get_options();
- int authority = (authdir_mode_v1(options) && is_v1_object) ||
- (authdir_mode_v2(options) && !is_v1_object);
+ int authority = (auth_type == V1_AUTHORITY && authdir_mode_v1(options)) ||
+ (auth_type == V2_AUTHORITY && authdir_mode_v2(options));
- if (!authority) {
+ if (!authority || authdir_mode_bridge(options)) { /* XXX020 */
return cache_src;
} else {
/* We're authoritative. */
@@ -1268,7 +1268,7 @@ dirserv_pick_cached_dir_obj(cached_dir_t *cache_src,
* set; otherwise return the uncompressed version. (In either case, sets
* *<b>out</b> and returns the size of the buffer in *<b>out</b>.)
*
- * Use <b>is_v1_object</b> to help determine whether we're authoritative for
+ * Use <b>auth_type</b> to help determine whether we're authoritative for
* this kind of object.
**/
static size_t
@@ -1278,11 +1278,11 @@ dirserv_get_obj(const char **out,
cached_dir_t *auth_src,
time_t dirty, cached_dir_t *(*regenerate)(void),
const char *name,
- int is_v1_object)
+ authority_type_t auth_type)
{
cached_dir_t *d = dirserv_pick_cached_dir_obj(
cache_src, auth_src,
- dirty, regenerate, name, is_v1_object);
+ dirty, regenerate, name, auth_type);
if (!d)
return 0;
@@ -1304,7 +1304,7 @@ dirserv_get_directory(void)
return dirserv_pick_cached_dir_obj(cached_directory, the_directory,
the_directory_is_dirty,
dirserv_regenerate_directory,
- "server directory", 1);
+ "server directory", V1_AUTHORITY);
}
/** Only called by v1 auth dirservers.
@@ -1406,7 +1406,7 @@ dirserv_get_runningrouters(const char **rr, int compress)
&cached_runningrouters, &the_runningrouters,
runningrouters_is_dirty,
generate_runningrouters,
- "v1 network status list", 1);
+ "v1 network status list", V1_AUTHORITY);
}
/** For authoritative directories: the current (v2) network status. */
@@ -1418,6 +1418,7 @@ static int
should_generate_v2_networkstatus(void)
{
return authdir_mode_v2(get_options()) &&
+ !authdir_mode_bridge(get_options()) && /* XXX020 */
the_v2_networkstatus_is_dirty &&
the_v2_networkstatus_is_dirty + DIR_REGEN_SLACK_TIME < time(NULL);
}
diff --git a/src/or/or.h b/src/or/or.h
index 874174f993..a747a1f1f1 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1735,6 +1735,8 @@ typedef struct {
int VersioningAuthoritativeDir; /**< Boolean: is this an authoritative
* directory that's willing to recommend
* versions? */
+ int BridgeAuthoritativeDir; /**< Boolean: is this an authoritative directory
+ * that aggregates bridge descriptors? */
int AvoidDiskWrites; /**< Boolean: should we never cache things to disk?
* Not used yet. */
int ClientOnly; /**< Boolean: should we never evolve into a server role? */
@@ -2951,6 +2953,7 @@ int authdir_mode(or_options_t *options);
int authdir_mode_v1(or_options_t *options);
int authdir_mode_v2(or_options_t *options);
int authdir_mode_handles_descs(or_options_t *options);
+int authdir_mode_bridge(or_options_t *options);
int clique_mode(or_options_t *options);
int server_mode(or_options_t *options);
int advertised_server_mode(void);
@@ -3031,7 +3034,7 @@ routerstatus_t *router_pick_directory_server(int requireother,
int for_v2_directory,
int retry_if_no_servers);
typedef enum {
- V1_AUTHORITY, V2_AUTHORITY, HIDSERV_AUTHORITY,
+ V1_AUTHORITY, V2_AUTHORITY, HIDSERV_AUTHORITY, BRIDGE_AUTHORITY
} authority_type_t;
routerstatus_t *router_pick_trusteddirserver(authority_type_t type,
int requireother,
diff --git a/src/or/router.c b/src/or/router.c
index 188a428a0d..650360942f 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -619,6 +619,14 @@ authdir_mode_handles_descs(or_options_t *options)
{
return authdir_mode_v1(options) || authdir_mode_v2(options);
}
+/** Return true iff we believe ourselves to be a bridge authoritative
+ * directory server.
+ */
+int
+authdir_mode_bridge(or_options_t *options)
+{
+ return authdir_mode(options) && options->BridgeAuthoritativeDir != 0;
+}
/** Return true iff we try to stay connected to all ORs at once.
*/
int