aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Networking/NetworkManager.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-11-10 16:22:38 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-11-10 16:22:38 -0500
commit711f58808447765b51367cb4a60581f8b8bb65ff (patch)
tree6ee8563d163fbc48d6c242a03e37d50819f56176 /Emby.Server.Implementations/Networking/NetworkManager.cs
parent901d7b509c712ababc489166e05bdfea1908fa0f (diff)
3.2.36.7
Diffstat (limited to 'Emby.Server.Implementations/Networking/NetworkManager.cs')
-rw-r--r--Emby.Server.Implementations/Networking/NetworkManager.cs18
1 files changed, 12 insertions, 6 deletions
diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs
index f8f7da78a..fbdb5c128 100644
--- a/Emby.Server.Implementations/Networking/NetworkManager.cs
+++ b/Emby.Server.Implementations/Networking/NetworkManager.cs
@@ -59,7 +59,13 @@ namespace Emby.Server.Implementations.Networking
list.AddRange(GetLocalIpAddressesFallback().Result);
}
- return list.Where(FilterIpAddress).DistinctBy(i => i.ToString());
+ var listClone = list.ToList();
+
+ return list
+ .OrderBy(i => i.AddressFamily == AddressFamily.InterNetwork ? 0 : 1)
+ .ThenBy(i => listClone.IndexOf(i))
+ .Where(FilterIpAddress)
+ .DistinctBy(i => i.ToString());
}
private bool FilterIpAddress(IPAddress address)
@@ -112,10 +118,10 @@ namespace Emby.Server.Implementations.Networking
public bool IsInPrivateAddressSpaceAndLocalSubnet(string endpoint)
{
- var endpointFirstPart = endpoint.Split('.')[0];
-
if (endpoint.StartsWith("10.", StringComparison.OrdinalIgnoreCase))
{
+ var endpointFirstPart = endpoint.Split('.')[0];
+
var subnets = GetSubnets(endpointFirstPart);
foreach (var subnet_Match in subnets)
@@ -217,7 +223,7 @@ namespace Emby.Server.Implementations.Networking
}
else if (address.AddressFamily == AddressFamily.InterNetworkV6)
{
- lengthMatch = 10;
+ lengthMatch = 9;
if (IsInPrivateAddressSpace(endpoint))
{
return true;
@@ -317,7 +323,7 @@ namespace Emby.Server.Implementations.Networking
return ipProperties.UnicastAddresses
//.Where(i => i.IsDnsEligible)
.Select(i => i.Address)
- .Where(i => i.AddressFamily == AddressFamily.InterNetwork)
+ .Where(i => i.AddressFamily == AddressFamily.InterNetwork || i.AddressFamily == AddressFamily.InterNetworkV6)
.ToList();
}
catch (Exception ex)
@@ -337,7 +343,7 @@ namespace Emby.Server.Implementations.Networking
// Reverse them because the last one is usually the correct one
// It's not fool-proof so ultimately the consumer will have to examine them and decide
return host.AddressList
- .Where(i => i.AddressFamily == AddressFamily.InterNetwork)
+ .Where(i => i.AddressFamily == AddressFamily.InterNetwork || i.AddressFamily == AddressFamily.InterNetworkV6)
.Reverse();
}