From 036b402e9f630f57488acad3696adb619f6fcacc Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 18 Jul 2020 08:08:57 -0400 Subject: [PATCH] update ip IsInternal() to account for missed ranges (#827) * update ip IsInternal() to account for missed ranges * update with `::` --- src/Icons/Services/IconFetchingService.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Icons/Services/IconFetchingService.cs b/src/Icons/Services/IconFetchingService.cs index f7e789fd1..d2acfe106 100644 --- a/src/Icons/Services/IconFetchingService.cs +++ b/src/Icons/Services/IconFetchingService.cs @@ -419,15 +419,28 @@ namespace Bit.Icons.Services { return true; } - else if (ip.ToString() == "::1") + + var ipString = ip.ToString(); + if (ipString == "::1" || ipString == "::") { - return false; + return true; } + // IPv6 + if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6) + { + return ipString.StartsWith("fc") || ipString.StartsWith("fd") || + ipString.StartsWith("fe") || ipString.StartsWith("ff"); + } + + // IPv4 var bytes = ip.GetAddressBytes(); return (bytes[0]) switch { + 0 => true, 10 => true, + 127 => true, + 169 => bytes[1] == 254, // Cloud environments, such as AWS 172 => bytes[1] < 32 && bytes[1] >= 16, 192 => bytes[1] == 168, _ => false,