diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-05-14 00:13:17 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-05-14 00:13:17 +0000 |
commit | 00f2a09380d650f673f6d9c13107e67b31a71b64 (patch) | |
tree | 97c20d6adec6a8c6a291b1ffcf7ccec6085a45e9 /src/or/test.c | |
parent | fbb69d7ca1a9e6815fa301c920f0542a9a337b3f (diff) | |
download | tor-00f2a09380d650f673f6d9c13107e67b31a71b64.tar.gz tor-00f2a09380d650f673f6d9c13107e67b31a71b64.zip |
Append default exit policy before checking for implicit internal addresses: fix bug 129.
svn:r4201
Diffstat (limited to 'src/or/test.c')
-rw-r--r-- | src/or/test.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/or/test.c b/src/or/test.c index e4b000b965..d9dea858cd 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -1316,6 +1316,40 @@ test_dir_format(void) } static void +test_exit_policies(void) +{ + addr_policy_t *policy; + + policy = router_parse_addr_policy_from_string("reject 192.168.0.0/16:*"); + test_eq(NULL, policy->next); + test_eq(ADDR_POLICY_REJECT, policy->policy_type); + test_eq(0xc0a80000u, policy->addr); + test_eq(0xffff0000u, policy->msk); + test_eq(1, policy->prt_min); + test_eq(65535, policy->prt_max); + test_streq("reject 192.168.0.0/16:*", policy->string); + + test_assert(exit_policy_implicitly_allows_local_networks(policy, 0)); + test_eq(ADDR_POLICY_ACCEPTED, + router_compare_addr_to_addr_policy(0x01020304u, 2, policy)); + test_eq(ADDR_POLICY_PROBABLY_ACCEPTED, + router_compare_addr_to_addr_policy(0, 2, policy)); + test_eq(ADDR_POLICY_REJECTED, + router_compare_addr_to_addr_policy(0xc0a80102, 2, policy)); + + addr_policy_free(policy); + + /* Copied from router.c */ + policy = NULL; + config_append_default_exit_policy(&policy); + test_assert(policy); + test_assert(!exit_policy_implicitly_allows_local_networks(policy, 1)); + + addr_policy_free(policy); + +} + +static void test_rend_fns(void) { char address1[] = "fooaddress.onion"; @@ -1386,6 +1420,8 @@ main(int c, char**v) { test_onion_handshake(); puts("\n========================= Directory Formats ==============="); test_dir_format(); + puts("\n========================= Exit policies ==================="); + test_exit_policies(); puts("\n========================= Rendezvous functionality ========"); test_rend_fns(); puts(""); |