aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-10-26 23:43:06 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-10-26 23:43:06 -0400
commit88caeaa783d8d6a7d2d17c98955fa4bc8264d446 (patch)
tree5ee99eef6d29382704fe1f8dad5bd5483b0cea5c
parent4432b88281cbd489ac4a71a8e9635c6325ccd168 (diff)
update address detection
-rw-r--r--Emby.Server.Implementations/Networking/NetworkManager.cs14
1 files changed, 11 insertions, 3 deletions
diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs
index db2c455fb..be85db80a 100644
--- a/Emby.Server.Implementations/Networking/NetworkManager.cs
+++ b/Emby.Server.Implementations/Networking/NetworkManager.cs
@@ -113,7 +113,6 @@ namespace Emby.Server.Implementations.Networking
{
var endpointFirstPart = endpoint.Split('.')[0];
- string subnet_Match = "";
if (
endpoint.StartsWith("127.", StringComparison.OrdinalIgnoreCase) ||
endpoint.StartsWith("10.", StringComparison.OrdinalIgnoreCase) ||
@@ -122,7 +121,9 @@ namespace Emby.Server.Implementations.Networking
)
{
foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
+ {
foreach (UnicastIPAddressInformation unicastIPAddressInformation in adapter.GetIPProperties().UnicastAddresses)
+ {
if (unicastIPAddressInformation.Address.AddressFamily == AddressFamily.InterNetwork && endpointFirstPart == unicastIPAddressInformation.Address.ToString().Split('.')[0])
{
int subnet_Test = 0;
@@ -132,11 +133,18 @@ namespace Emby.Server.Implementations.Networking
subnet_Test++;
}
- subnet_Match = String.Join(".", unicastIPAddressInformation.Address.ToString().Split('.').Take(subnet_Test).ToArray());
+ var subnet_Match = String.Join(".", unicastIPAddressInformation.Address.ToString().Split('.').Take(subnet_Test).ToArray());
+
+ if (endpoint.StartsWith(subnet_Match + ".", StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
}
+ }
+ }
}
- return endpoint.StartsWith(subnet_Match + ".", StringComparison.OrdinalIgnoreCase);
+ return false;
}
private Dictionary<string, string> _subnetLookup = new Dictionary<string, string>(StringComparer.Ordinal);