diff options
author | rl1987 <rl1987@sdf.lonestar.org> | 2013-11-16 18:29:54 +0200 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-02-03 14:20:17 -0500 |
commit | 3a4b24c3aba56475822ad94d268b48fd58b74645 (patch) | |
tree | 42eeca5141f199b241dd1358431ab04d364adf9b /src/or/directory.c | |
parent | 5991f9a15646d53b838562fd1424b6a8fd9ef614 (diff) | |
download | tor-3a4b24c3aba56475822ad94d268b48fd58b74645.tar.gz tor-3a4b24c3aba56475822ad94d268b48fd58b74645.zip |
Removing is_internal_IP() function. Resolves ticket 4645.
Diffstat (limited to 'src/or/directory.c')
-rw-r--r-- | src/or/directory.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index 0cacf06617..7f26affa20 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -1415,12 +1415,23 @@ http_set_address_origin(const char *headers, connection_t *conn) fwd = http_get_header(headers, "X-Forwarded-For: "); if (fwd) { struct in_addr in; - if (!tor_inet_aton(fwd, &in) || is_internal_IP(ntohl(in.s_addr), 0)) { - log_debug(LD_DIR, "Ignoring unrecognized or internal IP %s", + if (!tor_inet_aton(fwd, &in)) { + log_debug(LD_DIR, "Ignoring unrecognized IP %s", escaped(fwd)); tor_free(fwd); return; } + + tor_addr_t toraddr; + toraddr.family = AF_INET; + toraddr.addr.in_addr = in; + + if (tor_addr_is_internal(&toraddr,0)) { + log_debug(LD_DIR, "Ignoring local IP %s", escaped(fwd)); + tor_free(fwd); + return; + } + tor_free(conn->address); conn->address = tor_strdup(fwd); tor_free(fwd); |