From fda7ff5bf2795cb03ee2a5355c8003da31bf24f9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 19 Aug 2014 18:28:35 -0400 Subject: chromecast updates --- MediaBrowser.ServerApplication/ApplicationHost.cs | 35 ++++++++++++++++++++-- .../MediaBrowser.ServerApplication.csproj | 4 +-- .../Networking/NetworkManager.cs | 7 ++++- MediaBrowser.ServerApplication/packages.config | 2 +- 4 files changed, 41 insertions(+), 7 deletions(-) (limited to 'MediaBrowser.ServerApplication') diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 39a7981b2..35ee580b5 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -554,9 +554,9 @@ namespace MediaBrowser.ServerApplication SetKernelProperties(); } - protected override INetworkManager CreateNetworkManager() + protected override INetworkManager CreateNetworkManager(ILogger logger) { - return new NetworkManager(); + return new NetworkManager(logger); } protected override IFileSystem CreateFileSystemManager() @@ -958,10 +958,39 @@ namespace MediaBrowser.ServerApplication SupportsAutoRunAtStartup = SupportsAutoRunAtStartup, TranscodingTempPath = ApplicationPaths.TranscodingTempPath, IsRunningAsService = IsRunningAsService, - ServerName = FriendlyName + ServerName = FriendlyName, + LocalAddress = GetLocalIpAddress() }; } + /// + /// Gets the local ip address. + /// + /// System.String. + private string GetLocalIpAddress() + { + var localAddresses = NetworkManager.GetLocalIpAddresses().ToList(); + + // Cross-check the local ip addresses with addresses that have been received on with the http server + var matchedAddress = HttpServer.LocalEndPoints + .ToList() + .Select(i => i.Split(':').FirstOrDefault()) + .Where(i => !string.IsNullOrEmpty(i)) + .FirstOrDefault(i => localAddresses.Contains(i, StringComparer.OrdinalIgnoreCase)); + + // Return the first matched address, if found, or the first known local address + var address = matchedAddress ?? localAddresses.FirstOrDefault(); + + if (!string.IsNullOrWhiteSpace(address)) + { + address = string.Format("http://{0}:{1}", + address, + ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(CultureInfo.InvariantCulture)); + } + + return address; + } + public string FriendlyName { get diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index 0e4d95c31..ce17f9e8e 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -61,14 +61,14 @@ - ..\packages\MediaBrowser.IsoMounting.3.0.68\lib\net45\MediaBrowser.IsoMounter.dll + ..\packages\MediaBrowser.IsoMounting.3.0.69\lib\net45\MediaBrowser.IsoMounter.dll False ..\packages\NLog.3.1.0.0\lib\net45\NLog.dll - ..\packages\MediaBrowser.IsoMounting.3.0.68\lib\net45\pfmclrapi.dll + ..\packages\MediaBrowser.IsoMounting.3.0.69\lib\net45\pfmclrapi.dll ..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll diff --git a/MediaBrowser.ServerApplication/Networking/NetworkManager.cs b/MediaBrowser.ServerApplication/Networking/NetworkManager.cs index 4d4d5a451..fc4d26363 100644 --- a/MediaBrowser.ServerApplication/Networking/NetworkManager.cs +++ b/MediaBrowser.ServerApplication/Networking/NetworkManager.cs @@ -1,13 +1,13 @@ using MediaBrowser.Common.Implementations.Networking; using MediaBrowser.Common.Net; using MediaBrowser.Model.IO; +using MediaBrowser.Model.Logging; using MediaBrowser.Model.Net; using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; -using System.Net; using System.Runtime.InteropServices; namespace MediaBrowser.ServerApplication.Networking @@ -17,6 +17,11 @@ namespace MediaBrowser.ServerApplication.Networking /// public class NetworkManager : BaseNetworkManager, INetworkManager { + public NetworkManager(ILogger logger) + : base(logger) + { + } + /// /// Gets the network shares. /// diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config index 267084c52..8de487fb5 100644 --- a/MediaBrowser.ServerApplication/packages.config +++ b/MediaBrowser.ServerApplication/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file -- cgit v1.2.3