From 6fe933fde4b030cfd58732f36daa8873ea661d55 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 12 Dec 2016 16:33:37 -0500 Subject: [PATCH] improve network address detection --- .../Networking/NetworkManager.cs | 23 ++++++++++++++++-- src/Emby.Server/Emby.Server.xproj | 5 ++++ src/Emby.Server/project.json | 24 ++++++++++++++++--- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/Emby.Common.Implementations/Networking/NetworkManager.cs b/Emby.Common.Implementations/Networking/NetworkManager.cs index b9100f9db3..a4e6d47d40 100644 --- a/Emby.Common.Implementations/Networking/NetworkManager.cs +++ b/Emby.Common.Implementations/Networking/NetworkManager.cs @@ -198,6 +198,12 @@ namespace Emby.Common.Implementations.Networking return Dns.GetHostAddressesAsync(hostName); } + private readonly List _validNetworkInterfaceTypes = new List + { + NetworkInterfaceType.Ethernet, + NetworkInterfaceType.Wireless80211 + }; + private List GetIPsDefault() { NetworkInterface[] interfaces; @@ -223,9 +229,22 @@ namespace Emby.Common.Implementations.Networking { Logger.Debug("Querying interface: {0}. Type: {1}. Status: {2}", network.Name, network.NetworkInterfaceType, network.OperationalStatus); - var properties = network.GetIPProperties(); + var ipProperties = network.GetIPProperties(); + + // Try to exclude virtual adapters + // http://stackoverflow.com/questions/8089685/c-sharp-finding-my-machines-local-ip-address-and-not-the-vms + var addr = ipProperties.GatewayAddresses.FirstOrDefault(); + if (addr == null|| string.Equals(addr.Address.ToString(), "0.0.0.0", StringComparison.OrdinalIgnoreCase)) + { + return new List(); + } + + //if (!_validNetworkInterfaceTypes.Contains(network.NetworkInterfaceType)) + //{ + // return new List(); + //} - return properties.UnicastAddresses + return ipProperties.UnicastAddresses .Where(i => i.IsDnsEligible) .Select(i => i.Address) .Where(i => i.AddressFamily == AddressFamily.InterNetwork) diff --git a/src/Emby.Server/Emby.Server.xproj b/src/Emby.Server/Emby.Server.xproj index 6a23809ced..2462c5179f 100644 --- a/src/Emby.Server/Emby.Server.xproj +++ b/src/Emby.Server/Emby.Server.xproj @@ -37,5 +37,10 @@ + + + Properties\SharedVersion.cs + + \ No newline at end of file diff --git a/src/Emby.Server/project.json b/src/Emby.Server/project.json index 5b64beae61..852c7d519d 100644 --- a/src/Emby.Server/project.json +++ b/src/Emby.Server/project.json @@ -1,5 +1,5 @@ { - "version": "1.0.0-*", + "version": "3.1.0-*", "buildOptions": { "emitEntryPoint": true }, @@ -33,8 +33,26 @@ "win10-arm64": {}, "osx.10.10-x64": {}, "osx.10.11-x64": {}, - "osx.10.12-x64": {}, - "ubuntu.14.04-x64": {} + "osx.10.12-x64": , + "rhel.7.0-x64": {}, + "rhel.7.1-x64": {}, + "rhel.7.2-x64": {}, + "ubuntu.14.04-x64": {}, + "ubuntu.14.10-x64": {}, + "ubuntu.15.04-x64": {}, + "ubuntu.15.10-x64": {}, + "ubuntu.16.04-x64": {}, + "ubuntu.16.10-x64": {}, + "centos.7-x64": {}, + "debian.8-x64": {}, + "fedora.23-x64": {}, + "fedora.24-x64": {}, + "opensuse.13.2-x64": {}, + "opensuse.42.1-x64": {}, + "ol.7-x64": {}, + "ol.7.0-x64": {}, + "ol.7.1-x64": {}, + "ol.7.2-x64": {} }, "frameworks": {