diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-08-19 18:28:35 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-08-19 18:28:35 -0400 |
| commit | fda7ff5bf2795cb03ee2a5355c8003da31bf24f9 (patch) | |
| tree | 52e7989d001e42b2c14fd50532b9c964f91242af /MediaBrowser.ServerApplication/ApplicationHost.cs | |
| parent | b48d15296c1708545f358dc0ccbc48fea9b2cf00 (diff) | |
chromecast updates
Diffstat (limited to 'MediaBrowser.ServerApplication/ApplicationHost.cs')
| -rw-r--r-- | MediaBrowser.ServerApplication/ApplicationHost.cs | 35 |
1 files changed, 32 insertions, 3 deletions
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() }; } + /// <summary> + /// Gets the local ip address. + /// </summary> + /// <returns>System.String.</returns> + 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 |
