summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-01-22 15:10:18 +1100
committerteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-01-29 07:16:32 +1100
commit77a9de0d48e61e6762e65f6099c9a424544eb0ad (patch)
treebd79d43ad9ccb3942cd4c2d1c1699c94e86b7ef2 /src/or
parent3a00215c35b01909a2db24132ab800298d61b647 (diff)
downloadtor-77a9de0d48e61e6762e65f6099c9a424544eb0ad.tar.gz
tor-77a9de0d48e61e6762e65f6099c9a424544eb0ad.zip
Automatically use IPv6 when ClientUseIPv4 is 0
Consequential changes to log messages: * it's no longer possible to disable both IPv4 and IPv6, * refactor common string out of remaining log messages
Diffstat (limited to 'src/or')
-rw-r--r--src/or/config.c16
-rw-r--r--src/or/policies.c6
2 files changed, 12 insertions, 10 deletions
diff --git a/src/or/config.c b/src/or/config.c
index caa01d1d93..b9d9fb2d9a 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -3108,20 +3108,20 @@ options_validate(or_options_t *old_options, or_options_t *options,
/* We check if Reachable*Addresses blocks all addresses in
* parse_reachable_addresses(). */
- if (options->ClientUseIPv4 == 0 && !fascist_firewall_use_ipv6(options))
- REJECT("Tor cannot connect to the Internet if ClientUseIPv4 is 0 and "
- "ClientUseIPv6 is 0. Please set at least one of these options "
- "to 1, or configure bridges.");
+
+#define WARN_PLEASE_USE_IPV6_LOG_MSG \
+ "ClientPreferIPv6%sPort 1 is ignored unless tor is using IPv6. " \
+ "Please set ClientUseIPv6 1, ClientUseIPv4 0, or configure bridges."
if (!fascist_firewall_use_ipv6(options)
&& options->ClientPreferIPv6ORPort == 1)
- log_warn(LD_CONFIG, "ClientPreferIPv6ORPort 1 is ignored unless "
- "ClientUseIPv6 is also 1, or bridges are configured.");
+ log_warn(LD_CONFIG, WARN_PLEASE_USE_IPV6_LOG_MSG, "OR");
if (!fascist_firewall_use_ipv6(options)
&& options->ClientPreferIPv6DirPort == 1)
- log_warn(LD_CONFIG, "ClientPreferIPv6DirPort 1 is ignored unless "
- "ClientUseIPv6 is also 1, or bridges are configured.");
+ log_warn(LD_CONFIG, WARN_PLEASE_USE_IPV6_LOG_MSG, "Dir");
+
+#undef WARN_PLEASE_USE_IPV6_LOG_MSG
if (options->UseBridges &&
server_mode(options))
diff --git a/src/or/policies.c b/src/or/policies.c
index 0dc4f96c8b..734558d836 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -420,11 +420,13 @@ fascist_firewall_allows_address(const tor_addr_t *addr,
}
/** Is this client configured to use IPv6?
- * Clients use IPv6 if ClientUseIPv6 is 1, or UseBridges is 1.
*/
int fascist_firewall_use_ipv6(const or_options_t *options)
{
- return (options->ClientUseIPv6 == 1 || options->UseBridges == 1);
+ /* Clients use IPv6 if it's set, or they use bridges, or they don't use
+ * IPv4 */
+ return (options->ClientUseIPv6 == 1 || options->UseBridges == 1
+ || options->ClientUseIPv4 == 0);
}
/** Do we prefer to connect to IPv6, ignoring ClientPreferIPv6ORPort and