summaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-11-12 19:39:13 +0000
committerNick Mathewson <nickm@torproject.org>2004-11-12 19:39:13 +0000
commit5109de562604c334fee2a0778ff15ad93a4b1191 (patch)
tree82b677aa510f32609afabaa0afbe575c8caa17f9 /src/or/config.c
parentad8e779db22078ca6b18bd6194bbceee538cb632 (diff)
downloadtor-5109de562604c334fee2a0778ff15ad93a4b1191.tar.gz
tor-5109de562604c334fee2a0778ff15ad93a4b1191.zip
Rename exit_policy to addr_policy, since it gets used for SOCKS and directory connections too. Make all policies get validated in options_validate, and make SOCKS/directory policies get set in options_act.
svn:r2819
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 0e77d88e9b..dadaadbad9 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -257,7 +257,6 @@ options_act(void) {
if (set_max_file_descriptors(options->MaxConn) < 0)
return -1;
-
mark_logs_temp(); /* Close current logs once new logs are open. */
if (config_init_logs(options, 0)<0) /* Configure the log(s) */
return -1;
@@ -295,6 +294,10 @@ options_act(void) {
if(options->PidFile)
write_pidfile(options->PidFile);
+ /* Update address policies. */
+ parse_socks_policy();
+ parse_dir_policy();
+
init_cookie_authentication(options->CookieAuthentication);
/* reload keys as needed for rendezvous services. */
@@ -987,6 +990,7 @@ options_validate(or_options_t *options)
int i;
int result = 0;
struct config_line_t *cl;
+ struct addr_policy_t *addr_policy=NULL;
if (options->ORPort < 0 || options->ORPort > 65535) {
log(LOG_WARN, "ORPort option out of bounds.");
@@ -1201,6 +1205,20 @@ options_validate(or_options_t *options)
result = -1;
}
+ if (config_parse_addr_policy(options->ExitPolicy, &addr_policy)) {
+ log_fn(LOG_WARN, "Error in Exit Policy entry.");
+ result = -1;
+ }
+ if (config_parse_addr_policy(options->DirPolicy, &addr_policy)) {
+ log_fn(LOG_WARN, "Error in DirPolicy entry.");
+ result = -1;
+ }
+ if (config_parse_addr_policy(options->SocksPolicy, &addr_policy)) {
+ log_fn(LOG_WARN, "Error in SocksPolicy entry.");
+ result = -1;
+ }
+ addr_policy_free(addr_policy);
+
for (cl = options->RedirectExit; cl; cl = cl->next) {
if (parse_redirect_line(NULL, cl)<0)
result = -1;
@@ -1728,17 +1746,19 @@ normalize_log_options(or_options_t *options)
/**
* Given a linked list of config lines containing "allow" and "deny" tokens,
- * parse them and place the result in <b>dest</b>. Skip malformed lines.
+ * parse them and append the result to <b>dest</b>. Return -1 if any tokens
+ * are malformed, else return 0.
*/
-void
-config_parse_exit_policy(struct config_line_t *cfg,
- struct exit_policy_t **dest)
+int
+config_parse_addr_policy(struct config_line_t *cfg,
+ struct addr_policy_t **dest)
{
- struct exit_policy_t **nextp;
+ struct addr_policy_t **nextp;
smartlist_t *entries;
+ int r = 0;
if (!cfg)
- return;
+ return 0;
nextp = dest;
@@ -1751,23 +1771,25 @@ config_parse_exit_policy(struct config_line_t *cfg,
SMARTLIST_FOREACH(entries, const char *, ent,
{
log_fn(LOG_DEBUG,"Adding new entry '%s'",ent);
- *nextp = router_parse_exit_policy_from_string(ent);
+ *nextp = router_parse_addr_policy_from_string(ent);
if (*nextp) {
nextp = &((*nextp)->next);
} else {
- log_fn(LOG_WARN,"Malformed exit policy %s; skipping.", ent);
+ log_fn(LOG_WARN,"Malformed policy %s.", ent);
+ r = -1;
}
});
SMARTLIST_FOREACH(entries, char *, ent, tor_free(ent));
smartlist_clear(entries);
}
smartlist_free(entries);
+ return r;
}
/** Release all storage held by <b>p</b> */
void
-exit_policy_free(struct exit_policy_t *p) {
- struct exit_policy_t *e;
+addr_policy_free(struct addr_policy_t *p) {
+ struct addr_policy_t *e;
while (p) {
e = p;