|
@@ -25,7 +25,7 @@ typedef enum config_type_t {
|
|
|
CONFIG_TYPE_MEMUNIT,
|
|
|
CONFIG_TYPE_DOUBLE,
|
|
|
CONFIG_TYPE_BOOL,
|
|
|
- CONFIG_TYPE_ISOTIME,
|
|
|
+ CONFIG_TYPE_ISOTIME,
|
|
|
CONFIG_TYPE_CSV,
|
|
|
* optional whitespace. */
|
|
|
CONFIG_TYPE_LINELIST,
|
|
@@ -449,7 +449,7 @@ static config_var_description_t options_description[] = {
|
|
|
"host:port (or host:80 if port is not set)." },
|
|
|
{ "HTTPProxyAuthenticator", "A username:password pair to be used with "
|
|
|
"HTTPProxy." },
|
|
|
- { "HTTPSProxy", "Force Tor to make all TLS (SSL) connectinos through this "
|
|
|
+ { "HTTPSProxy", "Force Tor to make all TLS (SSL) connections through this "
|
|
|
"host:port (or host:80 if port is not set)." },
|
|
|
{ "HTTPSProxyAuthenticator", "A username:password pair to be used with "
|
|
|
"HTTPSProxy." },
|
|
@@ -693,6 +693,9 @@ static int or_state_validate(or_state_t *old_options, or_state_t *options,
|
|
|
static int or_state_load(void);
|
|
|
static int options_init_logs(or_options_t *options, int validate_only);
|
|
|
|
|
|
+static int is_listening_on_low_port(uint16_t port_option,
|
|
|
+ const config_line_t *listen_options);
|
|
|
+
|
|
|
static uint64_t config_parse_memunit(const char *s, int *ok);
|
|
|
static int config_parse_interval(const char *s, int *ok);
|
|
|
static void init_libevent(void);
|
|
@@ -1285,7 +1288,7 @@ options_act(or_options_t *old_options)
|
|
|
finish_daemon(options->DataDirectory);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
* will log a warning */
|
|
|
if (running_tor && options->PidFile)
|
|
|
write_pidfile(options->PidFile);
|
|
@@ -1331,7 +1334,7 @@ options_act(or_options_t *old_options)
|
|
|
|
|
|
if (! bool_eq(options->BridgeRelay, old_options->BridgeRelay)) {
|
|
|
log_info(LD_GENERAL, "Bridge status changed. Forgetting GeoIP stats.");
|
|
|
- geoip_remove_old_clients(time(NULL)+3600);
|
|
|
+ geoip_remove_old_clients(time(NULL)+(2*60*60));
|
|
|
}
|
|
|
|
|
|
if (options_transition_affects_workers(old_options, options)) {
|
|
@@ -1407,7 +1410,7 @@ options_act(or_options_t *old_options)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
our DirPort. */
|
|
|
tor_free(global_dirfrontpagecontents);
|
|
|
if (options->DirPortFrontPage) {
|
|
@@ -1440,7 +1443,7 @@ expand_abbrev(config_format_t *fmt, const char *option, int command_line,
|
|
|
if (! fmt->abbrevs)
|
|
|
return option;
|
|
|
for (i=0; fmt->abbrevs[i].abbreviated; ++i) {
|
|
|
-
|
|
|
+
|
|
|
if (!strcasecmp(option,fmt->abbrevs[i].abbreviated) &&
|
|
|
(command_line || !fmt->abbrevs[i].commandline_only)) {
|
|
|
if (warn_obsolete && fmt->abbrevs[i].warn) {
|
|
@@ -1501,7 +1504,7 @@ config_get_commandlines(int argc, char **argv, config_line_t **result)
|
|
|
(*new)->key = tor_strdup(expand_abbrev(&options_format, s, 1, 1));
|
|
|
(*new)->value = tor_strdup(argv[i+1]);
|
|
|
(*new)->next = NULL;
|
|
|
- log(LOG_DEBUG, LD_CONFIG, "Commandline: parsed keyword '%s', value '%s'",
|
|
|
+ log(LOG_DEBUG, LD_CONFIG, "command line: parsed keyword '%s', value '%s'",
|
|
|
(*new)->key, (*new)->value);
|
|
|
|
|
|
new = &((*new)->next);
|
|
@@ -1610,7 +1613,7 @@ config_find_option(config_format_t *fmt, const char *key)
|
|
|
int i;
|
|
|
size_t keylen = strlen(key);
|
|
|
if (!keylen)
|
|
|
- return NULL;
|
|
|
+ return NULL;
|
|
|
|
|
|
for (i=0; fmt->vars[i].name; ++i) {
|
|
|
if (!strcasecmp(key, fmt->vars[i].name)) {
|
|
@@ -1815,7 +1818,7 @@ config_assign_line(config_format_t *fmt, or_options_t *options,
|
|
|
if (!clear_first) {
|
|
|
if (var->type == CONFIG_TYPE_LINELIST ||
|
|
|
var->type == CONFIG_TYPE_LINELIST_S) {
|
|
|
-
|
|
|
+
|
|
|
As a special case, call this an error. Warn and ignore. */
|
|
|
log_warn(LD_CONFIG,
|
|
|
"Linelist option '%s' has no value. Skipping.", c->key);
|
|
@@ -1865,7 +1868,7 @@ option_get_canonical_name(const char *key)
|
|
|
return var ? var->name : NULL;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
*/
|
|
|
config_line_t *
|
|
|
option_get_assignment(or_options_t *options, const char *key)
|
|
@@ -2617,6 +2620,35 @@ options_init(or_options_t *options)
|
|
|
config_init(&options_format, options);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * the specified port in <b>listen_options</b> will result in Tor actually
|
|
|
+ * opening a low port (meaning a port lower than 1024). Return 1 if
|
|
|
+ * it is, or 0 if it isn't or the concept of a low port isn't applicable for
|
|
|
+ * the platform we're on. */
|
|
|
+static int
|
|
|
+is_listening_on_low_port(uint16_t port_option,
|
|
|
+ const config_line_t *listen_options)
|
|
|
+{
|
|
|
+#ifdef MS_WINDOWS
|
|
|
+ return 0;
|
|
|
+#else
|
|
|
+ const config_line_t *l;
|
|
|
+ uint16_t p;
|
|
|
+ if (port_option == 0)
|
|
|
+ return 0;
|
|
|
+ if (listen_options == NULL)
|
|
|
+ return (port_option < 1024);
|
|
|
+
|
|
|
+ for (l = listen_options; l; l = l->next) {
|
|
|
+ parse_addr_port(LOG_WARN, l->value, NULL, NULL, &p);
|
|
|
+ if (p<1024) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
* values. */
|
|
|
static void
|
|
@@ -3018,17 +3050,18 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|
|
REJECT("TransPort and TransListenAddress are disabled in this build.");
|
|
|
#endif
|
|
|
|
|
|
-#ifndef MS_WINDOWS
|
|
|
- if (options->AccountingMax &&
|
|
|
- (options->DirPort < 1024 || options->ORPort < 1024))
|
|
|
- log(LOG_WARN, LD_CONFIG,
|
|
|
+ if (options->AccountingMax &&
|
|
|
+ (is_listening_on_low_port(options->ORPort, options->ORListenAddress) ||
|
|
|
+ is_listening_on_low_port(options->DirPort, options->DirListenAddress)))
|
|
|
+ {
|
|
|
+ log(LOG_WARN, LD_CONFIG,
|
|
|
"You have set AccountingMax to use hibernation. You have also "
|
|
|
"chosen a low DirPort or OrPort. This combination can make Tor stop "
|
|
|
"working when it tries to re-attach the port after a period of "
|
|
|
"hibernation. Please choose a different port or turn off "
|
|
|
"hibernation unless you know this combination will work on your "
|
|
|
"platform.");
|
|
|
-#endif
|
|
|
+ }
|
|
|
|
|
|
if (options->ExcludeExitNodes || options->ExcludeNodes) {
|
|
|
options->_ExcludeExitNodesUnion = routerset_new();
|
|
@@ -3059,7 +3092,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|
|
if (!options->ContactInfo && !options->TestingTorNetwork)
|
|
|
REJECT("Authoritative directory servers must set ContactInfo");
|
|
|
if (options->V1AuthoritativeDir && !options->RecommendedVersions)
|
|
|
- REJECT("V1 auth dir servers must set RecommendedVersions.");
|
|
|
+ REJECT("V1 authoritative dir servers must set RecommendedVersions.");
|
|
|
if (!options->RecommendedClientVersions)
|
|
|
options->RecommendedClientVersions =
|
|
|
config_lines_dup(options->RecommendedVersions);
|
|
@@ -3069,7 +3102,8 @@ options_validate(or_options_t *old_options, or_options_t *options,
|
|
|
if (options->VersioningAuthoritativeDir &&
|
|
|
(!options->RecommendedClientVersions ||
|
|
|
!options->RecommendedServerVersions))
|
|
|
- REJECT("Versioning auth dir servers must set Recommended*Versions.");
|
|
|
+ REJECT("Versioning authoritative dir servers must set "
|
|
|
+ "Recommended*Versions.");
|
|
|
if (options->UseEntryGuards) {
|
|
|
log_info(LD_CONFIG, "Authoritative directory servers can't set "
|
|
|
"UseEntryGuards. Disabling.");
|
|
@@ -3675,7 +3709,7 @@ options_transition_allowed(or_options_t *old, or_options_t *new_val,
|
|
|
}
|
|
|
|
|
|
|
|
|
- * will require us to rotate the cpu and dns workers; else return 0. */
|
|
|
+ * will require us to rotate the CPU and DNS workers; else return 0. */
|
|
|
static int
|
|
|
options_transition_affects_workers(or_options_t *old_options,
|
|
|
or_options_t *new_options)
|
|
@@ -3932,7 +3966,7 @@ options_init_from_torrc(int argc, char **argv)
|
|
|
char *command_arg = NULL;
|
|
|
char *errmsg=NULL;
|
|
|
|
|
|
- if (argv) {
|
|
|
+ if (argv) {
|
|
|
backup_argv = argv;
|
|
|
backup_argc = argc;
|
|
|
} else {
|
|
@@ -4141,7 +4175,7 @@ get_torrc_fname(void)
|
|
|
return get_default_conf_file();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
* configuration <b>options</b>
|
|
|
*/
|
|
|
static void
|