From 40c46ca64995668a4becab4021613c56903649c4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 25 Dec 2015 22:36:38 -0500 Subject: [PATCH] update dlna interface binding --- .../MediaBrowser.Common.Implementations.csproj | 4 ++++ .../Networking/BaseNetworkManager.cs | 9 +++------ MediaBrowser.Common.Implementations/packages.config | 1 + MediaBrowser.Dlna/MediaBrowser.Dlna.csproj | 4 ++++ MediaBrowser.Dlna/Ssdp/DeviceDiscovery.cs | 12 +++++------- MediaBrowser.Dlna/packages.config | 1 + 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj index 3967abe58d..a86dd45ace 100644 --- a/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj +++ b/MediaBrowser.Common.Implementations/MediaBrowser.Common.Implementations.csproj @@ -51,6 +51,9 @@ False ..\packages\CommonIO.1.0.0.5\lib\net45\CommonIO.dll + + ..\packages\morelinq.1.4.0\lib\net35\MoreLinq.dll + False ..\packages\NLog.4.2.2\lib\net45\NLog.dll @@ -69,6 +72,7 @@ + diff --git a/MediaBrowser.Common.Implementations/Networking/BaseNetworkManager.cs b/MediaBrowser.Common.Implementations/Networking/BaseNetworkManager.cs index 7cf2b38387..789cde5fcc 100644 --- a/MediaBrowser.Common.Implementations/Networking/BaseNetworkManager.cs +++ b/MediaBrowser.Common.Implementations/Networking/BaseNetworkManager.cs @@ -226,16 +226,13 @@ namespace MediaBrowser.Common.Implementations.Networking try { - Logger.Debug("Found interface: {0}. Type: {1}. Status: {2}", network.Name, network.NetworkInterfaceType, network.OperationalStatus); + Logger.Debug("Querying interface: {0}. Type: {1}. Status: {2}", network.Name, network.NetworkInterfaceType, network.OperationalStatus); var properties = network.GetIPProperties(); - var ipV4 = properties.GetIPv4Properties(); - if (null == ipV4) - return new List(); return properties.UnicastAddresses - .Where(i => i.Address.AddressFamily == AddressFamily.InterNetwork && !IPAddress.IsLoopback(i.Address)) - .Select(i => i.Address) + .Select(i => i.Address) + .Where(i => i.AddressFamily == AddressFamily.InterNetwork && !IPAddress.IsLoopback(i)) .ToList(); } catch (Exception ex) diff --git a/MediaBrowser.Common.Implementations/packages.config b/MediaBrowser.Common.Implementations/packages.config index c6c2e11052..7d594dfdbb 100644 --- a/MediaBrowser.Common.Implementations/packages.config +++ b/MediaBrowser.Common.Implementations/packages.config @@ -1,6 +1,7 @@  + diff --git a/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj b/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj index b8ac60ef65..8169e7f8b6 100644 --- a/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj +++ b/MediaBrowser.Dlna/MediaBrowser.Dlna.csproj @@ -44,6 +44,10 @@ False ..\packages\CommonIO.1.0.0.5\lib\net45\CommonIO.dll + + False + ..\packages\morelinq.1.4.0\lib\net35\MoreLinq.dll + ..\packages\Patterns.Logging.1.0.0.2\lib\portable-net45+sl4+wp71+win8+wpa81\Patterns.Logging.dll diff --git a/MediaBrowser.Dlna/Ssdp/DeviceDiscovery.cs b/MediaBrowser.Dlna/Ssdp/DeviceDiscovery.cs index 02c26e8c16..4571349138 100644 --- a/MediaBrowser.Dlna/Ssdp/DeviceDiscovery.cs +++ b/MediaBrowser.Dlna/Ssdp/DeviceDiscovery.cs @@ -11,6 +11,7 @@ using System.Net.NetworkInformation; using System.Net.Sockets; using System.Threading; using System.Threading.Tasks; +using MoreLinq; namespace MediaBrowser.Dlna.Ssdp { @@ -54,16 +55,13 @@ namespace MediaBrowser.Dlna.Ssdp try { - _logger.Debug("Found interface: {0}. Type: {1}. Status: {2}", network.Name, network.NetworkInterfaceType, network.OperationalStatus); + _logger.Debug("Querying interface: {0}. Type: {1}. Status: {2}", network.Name, network.NetworkInterfaceType, network.OperationalStatus); var properties = network.GetIPProperties(); - var ipV4 = properties.GetIPv4Properties(); - if (null == ipV4) - return new List(); return properties.UnicastAddresses - .Where(i => i.Address.AddressFamily == AddressFamily.InterNetwork && !IPAddress.IsLoopback(i.Address)) - .Select(i => i.Address) + .Select(i => i.Address) + .Where(i => i.AddressFamily == AddressFamily.InterNetwork) .ToList(); } catch (Exception ex) @@ -73,7 +71,7 @@ namespace MediaBrowser.Dlna.Ssdp } }) - .Distinct() + .DistinctBy(i => i.ToString()) .ToList(); } diff --git a/MediaBrowser.Dlna/packages.config b/MediaBrowser.Dlna/packages.config index fad6af08eb..258a097cd2 100644 --- a/MediaBrowser.Dlna/packages.config +++ b/MediaBrowser.Dlna/packages.config @@ -1,5 +1,6 @@  + \ No newline at end of file