aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2005-12-09 02:45:33 +0000
committerRoger Dingledine <arma@torproject.org>2005-12-09 02:45:33 +0000
commitc0a6e2232cb7ca4a2c14ca8153f184f5a43cdc15 (patch)
tree249a22ad4e763b2a978b7168f00ffe7d334fb790 /src
parentd57029ffe8ebd6e4aa830c58b568c4fda0bad56c (diff)
downloadtor-c0a6e2232cb7ca4a2c14ca8153f184f5a43cdc15.tar
tor-c0a6e2232cb7ca4a2c14ca8153f184f5a43cdc15.tar.gz
let is_internal_IP() know whether you're asking about an IP
address for connecting or an IP address for binding, because in the latter, 0.0.0.0 is a special case. svn:r5543
Diffstat (limited to 'src')
-rw-r--r--src/common/util.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/common/util.c b/src/common/util.c
index 96155e68c..ea7ef0c6e 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1304,8 +1304,10 @@ tor_listdir(const char *dirname)
* or reserved for local networks by RFC 1918.
*/
int
-is_internal_IP(uint32_t ip)
+is_internal_IP(uint32_t ip, int for_listening)
{
+ if (for_listening && !ip) /* special case for binding to 0.0.0.0 */
+ return 0;
if (((ip & 0xff000000) == 0x0a000000) || /* 10/8 */
((ip & 0xff000000) == 0x00000000) || /* 0/8 */
((ip & 0xff000000) == 0x7f000000) || /* 127/8 */
@@ -1324,7 +1326,7 @@ is_internal_IP(uint32_t ip)
int
is_local_IP(uint32_t ip)
{
- return is_internal_IP(ip);
+ return is_internal_IP(ip, 0);
}
/** Parse a string of the form "host[:port]" from <b>addrport</b>. If