summaryrefslogtreecommitdiff
path: root/src/app/config
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2020-06-15 15:02:08 -0400
committerDavid Goulet <dgoulet@torproject.org>2020-06-23 09:25:36 -0400
commit47f9edde699ad687884b6222b557c10dee2592c9 (patch)
tree0c9d84200f85884e5f20ddb1f679684c2f4439c1 /src/app/config
parentd3bcbccab9d50fd0dafc682f7ee63902ea344be7 (diff)
downloadtor-47f9edde699ad687884b6222b557c10dee2592c9.tar.gz
tor-47f9edde699ad687884b6222b557c10dee2592c9.zip
config: Change Address to be a LINELIST
With prop312, we want to support IPv4 and IPv6 thus multiple Address statement (up to 2) will be accepted. For this, "Address" option becomes a LINELIST so we can properly process the IPv4 or/and IPv6. Part of #33233 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/app/config')
-rw-r--r--src/app/config/config.c4
-rw-r--r--src/app/config/or_options_st.h5
-rw-r--r--src/app/config/resolve_addr.c7
3 files changed, 10 insertions, 6 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 71f8c18ca2..286cd9304a 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -313,7 +313,7 @@ static const config_var_t option_vars_[] = {
V(AccountingMax, MEMUNIT, "0 bytes"),
VAR("AccountingRule", STRING, AccountingRule_option, "max"),
V(AccountingStart, STRING, NULL),
- V(Address, STRING, NULL),
+ V(Address, LINELIST, NULL),
OBSOLETE("AllowDotExit"),
OBSOLETE("AllowInvalidNodes"),
V(AllowNonRFC953Hostnames, BOOL, "0"),
@@ -4028,7 +4028,7 @@ options_check_transition_cb(const void *old_,
if (! CFG_EQ_INT(old, new_val, opt)) \
BAD_CHANGE_TO(opt," with Sandbox active")
- SB_NOCHANGE_STR(Address);
+ SB_NOCHANGE_LINELIST(Address);
SB_NOCHANGE_STR(ServerDNSResolvConfFile);
SB_NOCHANGE_STR(DirPortFrontPage);
SB_NOCHANGE_STR(CookieAuthFile);
diff --git a/src/app/config/or_options_st.h b/src/app/config/or_options_st.h
index bf58205f89..2f375f5d9b 100644
--- a/src/app/config/or_options_st.h
+++ b/src/app/config/or_options_st.h
@@ -71,7 +71,10 @@ struct or_options_t {
int CacheDirectoryGroupReadable; /**< Boolean: Is the CacheDirectory g+r? */
char *Nickname; /**< OR only: nickname of this onion router. */
- char *Address; /**< OR only: configured address for this onion router. */
+ /** OR only: configured address for this onion router. Up to two times this
+ * options is accepted as in IPv4 and IPv6. */
+ struct config_line_t *Address;
+
char *PidFile; /**< Where to store PID of Tor process. */
struct routerset_t *ExitNodes; /**< Structure containing nicknames, digests,
diff --git a/src/app/config/resolve_addr.c b/src/app/config/resolve_addr.c
index 9d1a8e0260..5723a00fa7 100644
--- a/src/app/config/resolve_addr.c
+++ b/src/app/config/resolve_addr.c
@@ -15,6 +15,7 @@
#include "feature/control/control_events.h"
+#include "lib/encoding/confline.h"
#include "lib/net/gethostname.h"
#include "lib/net/resolve.h"
@@ -97,7 +98,6 @@ resolve_my_address(int warn_severity, const or_options_t *options,
int explicit_hostname=1;
int from_interface=0;
char *addr_string = NULL;
- const char *address = options->Address;
int notice_severity = warn_severity <= LOG_NOTICE ?
LOG_NOTICE : warn_severity;
@@ -108,8 +108,9 @@ resolve_my_address(int warn_severity, const or_options_t *options,
* Step one: Fill in 'hostname' to be our best guess.
*/
- if (address && *address) {
- strlcpy(hostname, address, sizeof(hostname));
+ if (options->Address) {
+ /* Only 1 Address is supported even though this is a list. */
+ strlcpy(hostname, options->Address->value, sizeof(hostname));
log_debug(LD_CONFIG, "Trying configured Address '%s' as local hostname",
hostname);
} else { /* then we need to guess our address */