|
@@ -274,28 +274,22 @@ parse_reachable_addresses(void)
|
|
|
|
|
|
|
|
|
|
if (!server_mode(options)) {
|
|
if (!server_mode(options)) {
|
|
- if ((reachable_or_addr_policy
|
|
+ if (policy_is_reject_star(reachable_or_addr_policy, AF_UNSPEC, 0)
|
|
- && policy_is_reject_star(reachable_or_addr_policy, AF_UNSPEC))
|
|
+ || policy_is_reject_star(reachable_dir_addr_policy, AF_UNSPEC,0)) {
|
|
- || (reachable_dir_addr_policy
|
|
|
|
- && policy_is_reject_star(reachable_dir_addr_policy, AF_UNSPEC))) {
|
|
|
|
log_warn(LD_CONFIG, "Tor cannot connect to the Internet if "
|
|
log_warn(LD_CONFIG, "Tor cannot connect to the Internet if "
|
|
"ReachableAddresses, ReachableORAddresses, or "
|
|
"ReachableAddresses, ReachableORAddresses, or "
|
|
"ReachableDirAddresses reject all addresses. Please accept "
|
|
"ReachableDirAddresses reject all addresses. Please accept "
|
|
"some addresses in these options.");
|
|
"some addresses in these options.");
|
|
} else if (options->ClientUseIPv4 == 1
|
|
} else if (options->ClientUseIPv4 == 1
|
|
- && ((reachable_or_addr_policy
|
|
+ && (policy_is_reject_star(reachable_or_addr_policy, AF_INET, 0)
|
|
- && policy_is_reject_star(reachable_or_addr_policy, AF_INET))
|
|
+ || policy_is_reject_star(reachable_dir_addr_policy, AF_INET, 0))) {
|
|
- || (reachable_dir_addr_policy
|
|
|
|
- && policy_is_reject_star(reachable_dir_addr_policy, AF_INET)))) {
|
|
|
|
log_warn(LD_CONFIG, "You have set ClientUseIPv4 1, but "
|
|
log_warn(LD_CONFIG, "You have set ClientUseIPv4 1, but "
|
|
"ReachableAddresses, ReachableORAddresses, or "
|
|
"ReachableAddresses, ReachableORAddresses, or "
|
|
"ReachableDirAddresses reject all IPv4 addresses. "
|
|
"ReachableDirAddresses reject all IPv4 addresses. "
|
|
"Tor will not connect using IPv4.");
|
|
"Tor will not connect using IPv4.");
|
|
} else if (fascist_firewall_use_ipv6(options)
|
|
} else if (fascist_firewall_use_ipv6(options)
|
|
- && ((reachable_or_addr_policy
|
|
+ && (policy_is_reject_star(reachable_or_addr_policy, AF_INET6, 0)
|
|
- && policy_is_reject_star(reachable_or_addr_policy, AF_INET6))
|
|
+ || policy_is_reject_star(reachable_dir_addr_policy, AF_INET6, 0))) {
|
|
- || (reachable_dir_addr_policy
|
|
|
|
- && policy_is_reject_star(reachable_dir_addr_policy, AF_INET6)))) {
|
|
|
|
log_warn(LD_CONFIG, "You have configured tor to use IPv6 "
|
|
log_warn(LD_CONFIG, "You have configured tor to use IPv6 "
|
|
"(ClientUseIPv6 1 or UseBridges 1), but "
|
|
"(ClientUseIPv6 1 or UseBridges 1), but "
|
|
"ReachableAddresses, ReachableORAddresses, or "
|
|
"ReachableAddresses, ReachableORAddresses, or "
|
|
@@ -1084,8 +1078,8 @@ validate_addr_policies(const or_options_t *options, char **msg)
|
|
|
|
|
|
const int exitrelay_setting_is_auto = options->ExitRelay == -1;
|
|
const int exitrelay_setting_is_auto = options->ExitRelay == -1;
|
|
const int policy_accepts_something =
|
|
const int policy_accepts_something =
|
|
- ! (policy_is_reject_star(addr_policy, AF_INET) &&
|
|
+ ! (policy_is_reject_star(addr_policy, AF_INET, 1) &&
|
|
- policy_is_reject_star(addr_policy, AF_INET6));
|
|
+ policy_is_reject_star(addr_policy, AF_INET6, 1));
|
|
|
|
|
|
if (server_mode(options) &&
|
|
if (server_mode(options) &&
|
|
! warned_about_exitrelay &&
|
|
! warned_about_exitrelay &&
|
|
@@ -2156,13 +2150,16 @@ exit_policy_is_general_exit(smartlist_t *policy)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- * otherwise if we are certain it rejects everything, return true. */
|
|
+ * otherwise if we are certain it rejects everything, return true. If no
|
|
|
|
+ * part of <b>policy</b> matches, return <b>default_reject</b>.
|
|
|
|
+ * NULL policies are allowed, and treated as empty. */
|
|
int
|
|
int
|
|
-policy_is_reject_star(const smartlist_t *policy, sa_family_t family)
|
|
+policy_is_reject_star(const smartlist_t *policy, sa_family_t family,
|
|
|
|
+ int default_reject)
|
|
{
|
|
{
|
|
- if (!policy)
|
|
+ if (!policy)
|
|
- return 1;
|
|
+ return default_reject;
|
|
- SMARTLIST_FOREACH_BEGIN(policy, addr_policy_t *, p) {
|
|
+ SMARTLIST_FOREACH_BEGIN(policy, const addr_policy_t *, p) {
|
|
if (p->policy_type == ADDR_POLICY_ACCEPT &&
|
|
if (p->policy_type == ADDR_POLICY_ACCEPT &&
|
|
(tor_addr_family(&p->addr) == family ||
|
|
(tor_addr_family(&p->addr) == family ||
|
|
tor_addr_family(&p->addr) == AF_UNSPEC)) {
|
|
tor_addr_family(&p->addr) == AF_UNSPEC)) {
|
|
@@ -2175,7 +2172,7 @@ policy_is_reject_star(const smartlist_t *policy, sa_family_t family)
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
} SMARTLIST_FOREACH_END(p);
|
|
} SMARTLIST_FOREACH_END(p);
|
|
- return 1;
|
|
+ return default_reject;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|