commit 8467c01e9e88523fcdef22fed8efadbd07484966
Author: Peter Gerber <pe...@arbitrary.ch>
Date:   Mon Sep 21 15:53:24 2020 +0000

    Consider more IPs to be local
---
 common/util/util.go      | 6 +++++-
 common/util/util_test.go | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/common/util/util.go b/common/util/util.go
index ac254fa..b317e0b 100644
--- a/common/util/util.go
+++ b/common/util/util.go
@@ -56,7 +56,11 @@ func IsLocal(ip net.IP) bool {
                // Local IPv4 addresses are defined in 
https://tools.ietf.org/html/rfc1918
                return ip4[0] == 10 ||
                        (ip4[0] == 172 && ip4[1]&0xf0 == 16) ||
-                       (ip4[0] == 192 && ip4[1] == 168)
+                       (ip4[0] == 192 && ip4[1] == 168) ||
+                       // Carrier-Grade NAT as per 
https://tools.ietf.org/htm/rfc6598
+                       (ip4[0] == 100 && ip4[1]&0xc0 == 64) ||
+                       // Dynamic Configuration as per 
https://tools.ietf.org/htm/rfc3927
+                       (ip4[0] == 169 && ip4[1] == 254)
        }
        // Local IPv6 addresses are defined in 
https://tools.ietf.org/html/rfc4193
        return len(ip) == net.IPv6len && ip[0]&0xfe == 0xfc
diff --git a/common/util/util_test.go b/common/util/util_test.go
index 271619a..9d52f62 100644
--- a/common/util/util_test.go
+++ b/common/util/util_test.go
@@ -14,6 +14,8 @@ func TestUtil(t *testing.T) {
 
                offer := offerStart + goodCandidate +
                        "a=candidate:3769337065 1 udp 2122260223 192.168.0.100 
56688 typ host generation 0 network-id 1 network-cost 50\r\n" + // IsLocal IPv4
+                       "a=candidate:3769337065 1 udp 2122260223 100.127.50.5 
56688 typ host generation 0 network-id 1 network-cost 50\r\n" + // IsLocal IPv4
+                       "a=candidate:3769337065 1 udp 2122260223 169.254.250.88 
56688 typ host generation 0 network-id 1 network-cost 50\r\n" + // IsLocal IPv4
                        "a=candidate:3769337065 1 udp 2122260223 
fdf8:f53b:82e4::53 56688 typ host generation 0 network-id 1 network-cost 
50\r\n" + // IsLocal IPv6
                        "a=candidate:3769337065 1 udp 2122260223 0.0.0.0 56688 
typ host generation 0 network-id 1 network-cost 50\r\n" + // IsUnspecified IPv4
                        "a=candidate:3769337065 1 udp 2122260223 :: 56688 typ 
host generation 0 network-id 1 network-cost 50\r\n" + // IsUnspecified IPv6

_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to