early skeletal support for running a bridge directory authority

svn:r10112
This commit is contained in:
Roger Dingledine 2007-05-04 08:04:27 +00:00
parent d112e7b1ad
commit dc795203aa
5 changed files with 28 additions and 14 deletions

View File

@ -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"),

View File

@ -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;

View File

@ -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);
}

View File

@ -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,

View File

@ -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