aboutsummaryrefslogtreecommitdiff
path: root/src/or/routers.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-10-07 22:18:14 +0000
committerRoger Dingledine <arma@torproject.org>2003-10-07 22:18:14 +0000
commit9e30ac2870bf14c4939ec02f88540e65f553a357 (patch)
tree2f81726cbb65a0d1d6c8cf0bcc0f2d9fc877bf30 /src/or/routers.c
parent686fce453b4985e79734d1770d9931272cf7053f (diff)
downloadtor-9e30ac2870bf14c4939ec02f88540e65f553a357.tar.gz
tor-9e30ac2870bf14c4939ec02f88540e65f553a357.zip
obey exit policies for addresses too
svn:r555
Diffstat (limited to 'src/or/routers.c')
-rw-r--r--src/or/routers.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/or/routers.c b/src/or/routers.c
index 5921ce9f17..4aef1cf143 100644
--- a/src/or/routers.c
+++ b/src/or/routers.c
@@ -1038,6 +1038,7 @@ policy_read_failed:
*/
int router_compare_to_exit_policy(connection_t *conn) {
struct exit_policy_t *tmpe;
+ struct in_addr in;
assert(desc_routerinfo);
@@ -1045,10 +1046,14 @@ int router_compare_to_exit_policy(connection_t *conn) {
assert(tmpe->address);
assert(tmpe->port);
- /* Totally ignore the address field of the exit policy, for now. */
-
- if(!strcmp(tmpe->port,"*") || atoi(tmpe->port) == conn->port) {
- log_fn(LOG_INFO,"Port '%s' matches '%d'. %s.",
+ if(inet_aton(tmpe->address,&in) == 0) { /* malformed IP. reject. */
+ log_fn(LOG_WARNING,"Malformed IP %s in exit policy. Rejecting.",tmpe->address);
+ return -1;
+ }
+ if(conn->addr == ntohl(in.s_addr) &&
+ (!strcmp(tmpe->port,"*") || atoi(tmpe->port) == conn->port)) {
+ log_fn(LOG_INFO,"Address '%s' matches '%s' and port '%s' matches '%d'. %s.",
+ tmpe->address, conn->address,
tmpe->port, conn->port,
tmpe->policy_type == EXIT_POLICY_ACCEPT ? "Accepting" : "Rejecting");
if(tmpe->policy_type == EXIT_POLICY_ACCEPT)
@@ -1057,7 +1062,6 @@ int router_compare_to_exit_policy(connection_t *conn) {
return -1;
}
}
-
return 0; /* accept all by default. */
}