summaryrefslogtreecommitdiff
path: root/src/or/directory.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-11-06 05:18:11 +0000
committerRoger Dingledine <arma@torproject.org>2004-11-06 05:18:11 +0000
commit6c61ed4fb5d33a8c51ff342165a26ac70765dd26 (patch)
tree6a767b637d976bf392a275e99386798bbf094e74 /src/or/directory.c
parentf490e5cdb6a60779ddadfba3dd022ba904c00b43 (diff)
downloadtor-6c61ed4fb5d33a8c51ff342165a26ac70765dd26.tar.gz
tor-6c61ed4fb5d33a8c51ff342165a26ac70765dd26.zip
Make options no longer a global variable.
Now we can try setting an option but back out if it fails to parse, or if it's disallowed (e.g. changing RunAsDaemon from 1 to 0). Use parse_line_from_str rather than parse_line_from_file. svn:r2692
Diffstat (limited to 'src/or/directory.c')
-rw-r--r--src/or/directory.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 998e3539b8..c886abd6e4 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -46,8 +46,6 @@ static int directory_handle_command(connection_t *conn);
/********* START VARIABLES **********/
-extern or_options_t options; /* command-line and config-file options */
-
static struct exit_policy_t *dir_policy = NULL;
#if 0 /* commented out for now, since for now what clients send is
@@ -67,7 +65,7 @@ char rend_fetch_url[] = "/tor/rendezvous/";
/** A helper function for dir_policy_permits_address() below.
*
- * Parse options.DirPolicy in the same way that the exit policy
+ * Parse options->DirPolicy in the same way that the exit policy
* is parsed, and put the processed version in &dir_policy.
* Ignore port specifiers.
*/
@@ -78,7 +76,7 @@ static void parse_dir_policy(void)
exit_policy_free(dir_policy);
dir_policy = NULL;
}
- config_parse_exit_policy(options.DirPolicy, &dir_policy);
+ config_parse_exit_policy(get_options()->DirPolicy, &dir_policy);
/* ports aren't used. */
for (n=dir_policy; n; n = n->next) {
n->prt_min = 1;
@@ -92,7 +90,7 @@ static void parse_dir_policy(void)
int dir_policy_permits_address(uint32_t addr)
{
int a;
- if (options.DirPolicy && !dir_policy)
+ if (get_options()->DirPolicy && !dir_policy)
parse_dir_policy();
if(!dir_policy) /* 'no dir policy' means 'accept' */
@@ -129,10 +127,10 @@ directory_post_to_dirservers(uint8_t purpose, const char *payload,
/* Pay attention to fascistfirewall when we're uploading a
* router descriptor, but not when uploading a service
* descriptor -- those use Tor. */
- if (options.FascistFirewall && purpose == DIR_PURPOSE_UPLOAD_DIR &&
- !options.HttpProxy) {
+ if (get_options()->FascistFirewall && purpose == DIR_PURPOSE_UPLOAD_DIR &&
+ !get_options()->HttpProxy) {
tor_snprintf(buf,sizeof(buf),"%d",ds->dir_port);
- if (!smartlist_string_isin(options.FirewallPorts, buf))
+ if (!smartlist_string_isin(get_options()->FirewallPorts, buf))
continue;
}
directory_initiate_command_trusted_dir(ds, purpose, payload, payload_len);
@@ -154,13 +152,13 @@ directory_get_from_dirserver(uint8_t purpose, const char *payload,
if (purpose == DIR_PURPOSE_FETCH_DIR) {
if (advertised_server_mode()) {
/* only ask authdirservers, and don't ask myself */
- ds = router_pick_trusteddirserver(1, options.FascistFirewall);
+ ds = router_pick_trusteddirserver(1, get_options()->FascistFirewall);
} else {
/* anybody with a non-zero dirport will do */
- r = router_pick_directory_server(1, options.FascistFirewall);
+ r = router_pick_directory_server(1, get_options()->FascistFirewall);
if (!r) {
log_fn(LOG_INFO, "No router found for directory; falling back to dirserver list");
- ds = router_pick_trusteddirserver(1, options.FascistFirewall);
+ ds = router_pick_trusteddirserver(1, get_options()->FascistFirewall);
}
}
} else { // (purpose == DIR_PURPOSE_FETCH_RENDDESC)
@@ -241,9 +239,9 @@ directory_initiate_command(const char *address, uint32_t addr,
conn->addr = addr;
conn->port = dir_port;
- if(options.HttpProxy) {
- addr = options.HttpProxyAddr;
- dir_port = options.HttpProxyPort;
+ if(get_options()->HttpProxy) {
+ addr = get_options()->HttpProxyAddr;
+ dir_port = get_options()->HttpProxyPort;
}
conn->address = tor_strdup(address);
@@ -327,7 +325,7 @@ directory_send_command(connection_t *conn, const char *platform,
} else {
tor_snprintf(hoststring, sizeof(hoststring),"%s:%d",conn->address, conn->port);
}
- if(options.HttpProxy) {
+ if(get_options()->HttpProxy) {
tor_snprintf(proxystring, sizeof(proxystring),"http://%s", hoststring);
} else {
proxystring[0] = 0;
@@ -768,7 +766,7 @@ directory_handle_command_get(connection_t *conn, char *headers,
if(!strcmp(url,"/tor/running-routers")) { /* running-routers fetch */
tor_free(url);
- if(!authdir_mode()) {
+ if(!authdir_mode(get_options())) {
/* XXX008 for now, we don't cache running-routers. Reject. */
connection_write_to_buf(answer400, strlen(answer400), conn);
return 0;
@@ -793,7 +791,7 @@ directory_handle_command_get(connection_t *conn, char *headers,
const char *descp;
size_t desc_len;
- if(!authdir_mode()) {
+ if(!authdir_mode(get_options())) {
/* We don't hand out rend descs. In fact, it could be a security
* risk, since rend_cache_lookup_desc() below would provide it
* if we're gone to the site recently, and 404 if we haven't.
@@ -845,7 +843,7 @@ directory_handle_command_post(connection_t *conn, char *headers,
conn->state = DIR_CONN_STATE_SERVER_WRITING;
- if(!authdir_mode()) {
+ if(!authdir_mode(get_options())) {
/* we just provide cached directories; we don't want to
* receive anything. */
connection_write_to_buf(answer400, strlen(answer400), conn);