mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 13:38:13 -05:00
update ip IsInternal() to account for missed ranges (#827)
* update ip IsInternal() to account for missed ranges * update with `::`
This commit is contained in:
parent
3b9f625bc1
commit
036b402e9f
@ -419,15 +419,28 @@ namespace Bit.Icons.Services
|
|||||||
{
|
{
|
||||||
return true;
|
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();
|
var bytes = ip.GetAddressBytes();
|
||||||
return (bytes[0]) switch
|
return (bytes[0]) switch
|
||||||
{
|
{
|
||||||
|
0 => true,
|
||||||
10 => true,
|
10 => true,
|
||||||
|
127 => true,
|
||||||
|
169 => bytes[1] == 254, // Cloud environments, such as AWS
|
||||||
172 => bytes[1] < 32 && bytes[1] >= 16,
|
172 => bytes[1] < 32 && bytes[1] >= 16,
|
||||||
192 => bytes[1] == 168,
|
192 => bytes[1] == 168,
|
||||||
_ => false,
|
_ => false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user