diff options
author | Roger Dingledine <arma@torproject.org> | 2007-12-04 18:35:03 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2007-12-04 18:35:03 +0000 |
commit | d46b8a3eac7983795756297cca2d69a5aa5e3ad3 (patch) | |
tree | ba91853b7e28c2bcd70d014373f98a3126923f93 /src/or/dirserv.c | |
parent | 4a03959b10b9db3d47485e7ffb1848e1553cd601 (diff) | |
download | tor-d46b8a3eac7983795756297cca2d69a5aa5e3ad3.tar.gz tor-d46b8a3eac7983795756297cca2d69a5aa5e3ad3.zip |
Stop being so aggressive about fetching dir info if your DirPort is
on but your ORPort is off.
Add a new config option BridgeRelay that specifies you want to
be a bridge relay. Right now the only difference is that it makes
you answer begin_dir requests, and it makes you cache dir info,
even if your DirPort isn't on.
Refactor directory_caches_dir_info() into some more functions.
svn:r12668
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r-- | src/or/dirserv.c | 60 |
1 files changed, 48 insertions, 12 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 03a0c2791b..f36ac55b67 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -1089,25 +1089,50 @@ dirserv_dump_directory_to_string(char **dir_out, /********************************************************************/ /* A set of functions to answer questions about how we'd like to behave - * as a directory cache/client. */ + * as a directory mirror/client. */ -/** Return 1 if we want to keep descriptors, networkstatuses, etc around - * and serve them to others, or 0 otherwise. - * Also causes us to fetch new networkstatuses, descriptors, etc on the - * "mirror" schedule rather than the "client" schedule. +/** Return 1 if we fetch our directory material directly from the + * authorities, rather than from a mirror. */ +int +directory_fetches_from_authorities(or_options_t *options) +{ + if (options->DirPort == 0) + return 0; + /* XXX if dirport not advertised, return 0 too */ + if (!server_mode(options)) + return 0; + /* XXX if orport or dirport not reachable, return 0 too */ + return 1; +} + +/* Return 1 if we should fetch new networkstatuses, descriptors, etc + * on the "mirror" schedule rather than the "client" schedule. */ int -directory_caches_dir_info(or_options_t *options) +directory_fetches_dir_info_like_mirror(or_options_t *options) { - return options->DirPort != 0; + return directory_fetches_from_authorities(options); } -/** Return 1 if we fetch our directory material directly from the - * authorities, rather than some other cache. */ +/* Return 1 if we should fetch new networkstatuses, descriptors, etc + * on a very passive schedule -- waiting long enough for ordinary clients + * to probably have the info we want. These would include bridge users, + * and maybe others in the future e.g. if a Tor client uses another Tor + * client as a directory guard. + */ int -directory_fetches_from_authorities(or_options_t *options) +directory_fetches_dir_info_like_bridge_user(or_options_t *options) +{ + return options->UseBridges != 0; +} + +/** Return 1 if we want to keep descriptors, networkstatuses, etc around + * and we're willing to serve them to others. Else return 0. + */ +int +directory_caches_dir_info(or_options_t *options) { - return server_mode(options) && options->DirPort != 0; + return options->BridgeRelay != 0 || options->DirPort != 0; } /** Return 1 if we want to allow remote people to ask us directory @@ -1116,7 +1141,7 @@ directory_fetches_from_authorities(or_options_t *options) int directory_permits_begindir_requests(or_options_t *options) { - return options->DirPort != 0; + return options->BridgeRelay != 0 || options->DirPort != 0; } /** Return 1 if we want to allow controllers to ask us directory @@ -1128,6 +1153,17 @@ directory_permits_controller_requests(or_options_t *options) return options->DirPort != 0; } +/** Return 1 if we have no need to fetch new descriptors. This generally + * happens when we're not a dir cache and we haven't built any circuits + * lately. + */ +int +directory_too_idle_to_fetch_descriptors(or_options_t *options, time_t now) +{ + return !options->DirPort && !options->FetchUselessDescriptors && + rep_hist_circbuilding_dormant(now); +} + /********************************************************************/ /* Used only by non-v1-auth dirservers: The v1 directory and |