aboutsummaryrefslogtreecommitdiff
path: root/Emby.Common.Implementations/Networking/NetworkManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Common.Implementations/Networking/NetworkManager.cs')
-rw-r--r--Emby.Common.Implementations/Networking/NetworkManager.cs23
1 files changed, 21 insertions, 2 deletions
diff --git a/Emby.Common.Implementations/Networking/NetworkManager.cs b/Emby.Common.Implementations/Networking/NetworkManager.cs
index b9100f9db..a4e6d47d4 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<NetworkInterfaceType> _validNetworkInterfaceTypes = new List<NetworkInterfaceType>
+ {
+ NetworkInterfaceType.Ethernet,
+ NetworkInterfaceType.Wireless80211
+ };
+
private List<IPAddress> 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<IPAddress>();
+ }
+
+ //if (!_validNetworkInterfaceTypes.Contains(network.NetworkInterfaceType))
+ //{
+ // return new List<IPAddress>();
+ //}
- return properties.UnicastAddresses
+ return ipProperties.UnicastAddresses
.Where(i => i.IsDnsEligible)
.Select(i => i.Address)
.Where(i => i.AddressFamily == AddressFamily.InterNetwork)