filter ip addresses
This commit is contained in:
parent
2f40910c90
commit
0911bebf22
|
@ -231,6 +231,7 @@ namespace MediaBrowser.Common.Implementations.Networking
|
||||||
var properties = network.GetIPProperties();
|
var properties = network.GetIPProperties();
|
||||||
|
|
||||||
return properties.UnicastAddresses
|
return properties.UnicastAddresses
|
||||||
|
.Where(i => i.IsDnsEligible)
|
||||||
.Select(i => i.Address)
|
.Select(i => i.Address)
|
||||||
.Where(i => i.AddressFamily == AddressFamily.InterNetwork)
|
.Where(i => i.AddressFamily == AddressFamily.InterNetwork)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
|
@ -11,6 +11,7 @@ using System.Net.NetworkInformation;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
using MoreLinq;
|
using MoreLinq;
|
||||||
|
|
||||||
namespace MediaBrowser.Dlna.Ssdp
|
namespace MediaBrowser.Dlna.Ssdp
|
||||||
|
@ -27,52 +28,21 @@ namespace MediaBrowser.Dlna.Ssdp
|
||||||
|
|
||||||
public event EventHandler<SsdpMessageEventArgs> DeviceDiscovered;
|
public event EventHandler<SsdpMessageEventArgs> DeviceDiscovered;
|
||||||
public event EventHandler<SsdpMessageEventArgs> DeviceLeft;
|
public event EventHandler<SsdpMessageEventArgs> DeviceLeft;
|
||||||
|
private readonly INetworkManager _networkManager;
|
||||||
|
|
||||||
public DeviceDiscovery(ILogger logger, IServerConfigurationManager config, IServerApplicationHost appHost)
|
public DeviceDiscovery(ILogger logger, IServerConfigurationManager config, IServerApplicationHost appHost, INetworkManager networkManager)
|
||||||
{
|
{
|
||||||
_tokenSource = new CancellationTokenSource();
|
_tokenSource = new CancellationTokenSource();
|
||||||
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_config = config;
|
_config = config;
|
||||||
_appHost = appHost;
|
_appHost = appHost;
|
||||||
|
_networkManager = networkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<IPAddress> GetLocalIpAddresses()
|
private List<IPAddress> GetLocalIpAddresses()
|
||||||
{
|
{
|
||||||
NetworkInterface[] interfaces;
|
return _networkManager.GetLocalIpAddresses().ToList();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
interfaces = NetworkInterface.GetAllNetworkInterfaces();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error in GetAllNetworkInterfaces", ex);
|
|
||||||
return new List<IPAddress>();
|
|
||||||
}
|
|
||||||
|
|
||||||
return interfaces.SelectMany(network => {
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_logger.Debug("Querying interface: {0}. Type: {1}. Status: {2}", network.Name, network.NetworkInterfaceType, network.OperationalStatus);
|
|
||||||
|
|
||||||
var properties = network.GetIPProperties();
|
|
||||||
|
|
||||||
return properties.UnicastAddresses
|
|
||||||
.Select(i => i.Address)
|
|
||||||
.Where(i => i.AddressFamily == AddressFamily.InterNetwork)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error querying network interface", ex);
|
|
||||||
return new List<IPAddress>();
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
.DistinctBy(i => i.ToString())
|
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Start(SsdpHandler ssdpHandler)
|
public void Start(SsdpHandler ssdpHandler)
|
||||||
|
|
|
@ -522,7 +522,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, LibraryManager, MediaSourceManager);
|
SubtitleManager = new SubtitleManager(LogManager.GetLogger("SubtitleManager"), FileSystemManager, LibraryMonitor, LibraryManager, MediaSourceManager);
|
||||||
RegisterSingleInstance(SubtitleManager);
|
RegisterSingleInstance(SubtitleManager);
|
||||||
|
|
||||||
RegisterSingleInstance<IDeviceDiscovery>(new DeviceDiscovery(LogManager.GetLogger("IDeviceDiscovery"), ServerConfigurationManager, this));
|
RegisterSingleInstance<IDeviceDiscovery>(new DeviceDiscovery(LogManager.GetLogger("IDeviceDiscovery"), ServerConfigurationManager, this, NetworkManager));
|
||||||
|
|
||||||
ChapterManager = new ChapterManager(LibraryManager, LogManager.GetLogger("ChapterManager"), ServerConfigurationManager, ItemRepository);
|
ChapterManager = new ChapterManager(LibraryManager, LogManager.GetLogger("ChapterManager"), ServerConfigurationManager, ItemRepository);
|
||||||
RegisterSingleInstance(ChapterManager);
|
RegisterSingleInstance(ChapterManager);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user