Merge pull request #7549 from cvium/fix_isinlocalnetwork

(cherry picked from commit bdb85aeecf)
Signed-off-by: crobibero <cody@robibe.ro>
This commit is contained in:
Cody Robibero
2022-04-03 16:38:04 -06:00
committed by crobibero
parent 04cac23a11
commit 94a69c8a8b
2 changed files with 15 additions and 57 deletions

View File

@@ -463,6 +463,18 @@ namespace Jellyfin.Networking.Manager
/// <inheritdoc/>
public bool IsInLocalNetwork(IPObject address)
{
return IsInLocalNetwork(address.Address);
}
/// <inheritdoc/>
public bool IsInLocalNetwork(string address)
{
return IPHost.TryParse(address, out IPHost ipHost) && IsInLocalNetwork(ipHost);
}
/// <inheritdoc/>
public bool IsInLocalNetwork(IPAddress address)
{
if (address == null)
{
@@ -481,36 +493,7 @@ namespace Jellyfin.Networking.Manager
}
// As private addresses can be redefined by Configuration.LocalNetworkAddresses
return address.IsLoopback() || (_lanSubnets.ContainsAddress(address) && !_excludedSubnets.ContainsAddress(address));
}
/// <inheritdoc/>
public bool IsInLocalNetwork(string address)
{
if (IPHost.TryParse(address, out IPHost ep))
{
return _lanSubnets.ContainsAddress(ep) && !_excludedSubnets.ContainsAddress(ep);
}
return false;
}
/// <inheritdoc/>
public bool IsInLocalNetwork(IPAddress address)
{
if (address == null)
{
throw new ArgumentNullException(nameof(address));
}
// See conversation at https://github.com/jellyfin/jellyfin/pull/3515.
if (TrustAllIP6Interfaces && address.AddressFamily == AddressFamily.InterNetworkV6)
{
return true;
}
// As private addresses can be redefined by Configuration.LocalNetworkAddresses
return _lanSubnets.ContainsAddress(address) && !_excludedSubnets.ContainsAddress(address);
return IPAddress.IsLoopback(address) || (_lanSubnets.ContainsAddress(address) && !_excludedSubnets.ContainsAddress(address));
}
/// <inheritdoc/>