mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Add "pass" target for RedirectExit, to make it easier to break out of a sequence of rules
svn:r2566
This commit is contained in:
+9
-4
@@ -1106,10 +1106,15 @@ static int parse_redirect_line(or_options_t *options,
|
||||
log_fn(LOG_WARN, "Error parsing source address in RedirectExit line");
|
||||
goto err;
|
||||
}
|
||||
if (parse_addr_port(smartlist_get(elements,1),NULL,&r->addr_dest,
|
||||
&r->port_dest)) {
|
||||
log_fn(LOG_WARN, "Error parseing dest address in RedirectExit line");
|
||||
goto err;
|
||||
if (0==strcasecmp(smartlist_get(elements,1), "pass")) {
|
||||
r->is_redirect = 0;
|
||||
} else {
|
||||
if (parse_addr_port(smartlist_get(elements,1),NULL,&r->addr_dest,
|
||||
&r->port_dest)) {
|
||||
log_fn(LOG_WARN, "Error parseing dest address in RedirectExit line");
|
||||
goto err;
|
||||
}
|
||||
r->is_redirect = 1;
|
||||
}
|
||||
|
||||
goto done;
|
||||
|
||||
@@ -901,11 +901,13 @@ void connection_exit_connect(connection_t *conn) {
|
||||
if ((addr&r->mask)==(r->addr&r->mask) &&
|
||||
(r->port_min <= port) && (port <= r->port_max)) {
|
||||
struct in_addr in;
|
||||
addr = r->addr_dest;
|
||||
port = r->port_dest;
|
||||
in.s_addr = htonl(addr);
|
||||
log_fn(LOG_DEBUG, "Redirecting connection from %s:%d to %s:%d",
|
||||
conn->address, conn->port, inet_ntoa(in), port);
|
||||
if (r->is_redirect) {
|
||||
addr = r->addr_dest;
|
||||
port = r->port_dest;
|
||||
in.s_addr = htonl(addr);
|
||||
log_fn(LOG_DEBUG, "Redirecting connection from %s:%d to %s:%d",
|
||||
conn->address, conn->port, inet_ntoa(in), port);
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -824,6 +824,7 @@ typedef struct exit_redirect_t {
|
||||
uint16_t port_min;
|
||||
uint16_t port_max;
|
||||
|
||||
int is_redirect;
|
||||
uint32_t addr_dest;
|
||||
uint16_t port_dest;
|
||||
} exit_redirect_t;
|
||||
|
||||
Reference in New Issue
Block a user