aboutsummaryrefslogtreecommitdiff
path: root/src/lib/net
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2019-03-12 18:11:35 +0200
committerGeorge Kadianakis <desnacked@riseup.net>2019-03-12 18:11:35 +0200
commit0ce32affc2d617e487fbedaac1582358fa6fb85c (patch)
treeafcdf037639981f4c46f4d7cee6e54511a64b942 /src/lib/net
parent9c9214f2c9f4e9511a2e09238e1cc90d81ae02de (diff)
parent08ddf1f62bf62aa3dc044e0570fb368477223688 (diff)
downloadtor-0ce32affc2d617e487fbedaac1582358fa6fb85c.tar.gz
tor-0ce32affc2d617e487fbedaac1582358fa6fb85c.zip
Merge branch 'tor-github/pr/763' into maint-0.4.0
Diffstat (limited to 'src/lib/net')
-rw-r--r--src/lib/net/address.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/lib/net/address.c b/src/lib/net/address.c
index e1c9e1310f..214d8aa3eb 100644
--- a/src/lib/net/address.c
+++ b/src/lib/net/address.c
@@ -238,9 +238,18 @@ tor_addr_make_null(tor_addr_t *a, sa_family_t family)
a->family = family;
}
-/** Return true iff <b>ip</b> is an IP reserved to localhost or local networks
- * in RFC1918 or RFC4193 or RFC4291. (fec0::/10, deprecated by RFC3879, is
- * also treated as internal for now.)
+/** Return true iff <b>ip</b> is an IP reserved to localhost or local networks.
+ *
+ * If <b>ip</b> is in RFC1918 or RFC4193 or RFC4291, we will return true.
+ * (fec0::/10, deprecated by RFC3879, is also treated as internal for now
+ * and will return true.)
+ *
+ * If <b>ip</b> is 0.0.0.0 or 100.64.0.0/10 (RFC6598), we will act as:
+ * - Internal if <b>for_listening</b> is 0, as these addresses are not
+ * routable on the internet and we won't be publicly accessible to clients.
+ * - External if <b>for_listening</b> is 1, as clients could connect to us
+ * from the internet (in the case of 0.0.0.0) or a service provider's
+ * internal network (in the case of RFC6598).
*/
int
tor_addr_is_internal_(const tor_addr_t *addr, int for_listening,
@@ -288,11 +297,13 @@ tor_addr_is_internal_(const tor_addr_t *addr, int for_listening,
return 0;
} else if (v_family == AF_INET) {
- if (for_listening && !iph4) /* special case for binding to 0.0.0.0 */
+ /* special case for binding to 0.0.0.0 or 100.64/10 (RFC6598) */
+ if (for_listening && (!iph4 || ((iph4 & 0xffc00000) == 0x64400000)))
return 0;
if (((iph4 & 0xff000000) == 0x0a000000) || /* 10/8 */
((iph4 & 0xff000000) == 0x00000000) || /* 0/8 */
((iph4 & 0xff000000) == 0x7f000000) || /* 127/8 */
+ ((iph4 & 0xffc00000) == 0x64400000) || /* 100.64/10 */
((iph4 & 0xffff0000) == 0xa9fe0000) || /* 169.254/16 */
((iph4 & 0xfff00000) == 0xac100000) || /* 172.16/12 */
((iph4 & 0xffff0000) == 0xc0a80000)) /* 192.168/16 */