aboutsummaryrefslogtreecommitdiff
path: root/src/or/policies.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-10-24 23:05:44 -0400
committerNick Mathewson <nickm@torproject.org>2012-11-14 23:16:22 -0500
commitb35a0d113233fa29439500555201b85c1dec64b1 (patch)
treefe1771a94b373f41c7e28411925fdc21e5012f24 /src/or/policies.c
parent04ea55014182776871841279f6917d1a03c4e905 (diff)
downloadtor-b35a0d113233fa29439500555201b85c1dec64b1.tar.gz
tor-b35a0d113233fa29439500555201b85c1dec64b1.zip
Add IPv6 support to compare_to_addr_to_node_policy
Diffstat (limited to 'src/or/policies.c')
-rw-r--r--src/or/policies.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/or/policies.c b/src/or/policies.c
index 8367446ff2..16b3e4fa7a 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -1616,16 +1616,29 @@ compare_tor_addr_to_node_policy(const tor_addr_t *addr, uint16_t port,
if (node->rejects_all)
return ADDR_POLICY_REJECTED;
- if (node->ri)
+ if (addr && tor_addr_family(addr) == AF_INET6) {
+ const short_policy_t *p = NULL;
+ if (node->ri)
+ p = node->ri->ipv6_exit_policy;
+ else if (node->md)
+ p = node->md->ipv6_exit_policy;
+ if (p)
+ return compare_tor_addr_to_short_policy(addr, port, p);
+ else
+ return ADDR_POLICY_REJECTED;
+ }
+
+ if (node->ri) {
return compare_tor_addr_to_addr_policy(addr, port, node->ri->exit_policy);
- else if (node->md) {
+ } else if (node->md) {
if (node->md->exit_policy == NULL)
return ADDR_POLICY_REJECTED;
else
return compare_tor_addr_to_short_policy(addr, port,
node->md->exit_policy);
- } else
+ } else {
return ADDR_POLICY_PROBABLY_REJECTED;
+ }
}
/** Implementation for GETINFO control command: knows the answer for questions