diff options
| author | Michalis Adamidis <gsnerf@gsnerf.de> | 2014-08-24 19:53:53 +0200 |
|---|---|---|
| committer | Michalis Adamidis <gsnerf@gsnerf.de> | 2014-08-24 19:53:53 +0200 |
| commit | 5740a4c22d676d0050e875b0bd5455f5a303f5bd (patch) | |
| tree | 8cbdc9a742be677fd96b1be32bb74a294d8722c4 /MediaBrowser.ServerApplication | |
| parent | 7b8050ed382e1e39399c6d1b06637cd07ac6b8d5 (diff) | |
| parent | 58a38d0d1ddb89439b763e7bc50e8b84105f68fe (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Conflicts:
MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
Diffstat (limited to 'MediaBrowser.ServerApplication')
5 files changed, 43 insertions, 67 deletions
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 39a7981b24..dc4baf298c 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -1,5 +1,4 @@ -using System.Net; -using MediaBrowser.Api; +using MediaBrowser.Api; using MediaBrowser.Common; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Events; @@ -78,7 +77,6 @@ using MediaBrowser.Server.Implementations.ServerManager; using MediaBrowser.Server.Implementations.Session; using MediaBrowser.Server.Implementations.Sync; using MediaBrowser.Server.Implementations.Themes; -using MediaBrowser.ServerApplication.EntryPoints; using MediaBrowser.ServerApplication.FFMpeg; using MediaBrowser.ServerApplication.IO; using MediaBrowser.ServerApplication.Native; @@ -535,7 +533,7 @@ namespace MediaBrowser.ServerApplication RegisterSingleInstance<ISessionContext>(new SessionContext(UserManager, authContext, SessionManager)); RegisterSingleInstance<IAuthService>(new AuthService(UserManager, SessionManager, authContext, ServerConfigurationManager)); - RegisterSingleInstance<ISubtitleEncoder>(new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder)); + RegisterSingleInstance<ISubtitleEncoder>(new SubtitleEncoder(LibraryManager, LogManager.GetLogger("SubtitleEncoder"), ApplicationPaths, FileSystemManager, MediaEncoder, JsonSerializer)); var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false)); var itemsTask = Task.Run(async () => await ConfigureItemRepositories().ConfigureAwait(false)); @@ -554,9 +552,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 +956,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 diff --git a/MediaBrowser.ServerApplication/EntryPoints/WanAddressEntryPoint.cs b/MediaBrowser.ServerApplication/EntryPoints/WanAddressEntryPoint.cs deleted file mode 100644 index 7b2a1314e0..0000000000 --- a/MediaBrowser.ServerApplication/EntryPoints/WanAddressEntryPoint.cs +++ /dev/null @@ -1,55 +0,0 @@ -using MediaBrowser.Common.Net; -using MediaBrowser.Controller.Plugins; -using System; -using System.IO; -using System.Threading; - -namespace MediaBrowser.ServerApplication.EntryPoints -{ - public class WanAddressEntryPoint : IServerEntryPoint - { - public static string WanAddress; - private Timer _timer; - private readonly IHttpClient _httpClient; - - public WanAddressEntryPoint(IHttpClient httpClient) - { - _httpClient = httpClient; - } - - public void Run() - { - _timer = new Timer(TimerCallback, null, TimeSpan.FromMinutes(1), TimeSpan.FromHours(24)); - } - - private async void TimerCallback(object state) - { - try - { - using (var stream = await _httpClient.Get(new HttpRequestOptions - { - Url = "http://bot.whatismyipaddress.com/" - - }).ConfigureAwait(false)) - { - using (var reader = new StreamReader(stream)) - { - WanAddress = await reader.ReadToEndAsync().ConfigureAwait(false); - } - } - } - catch - { - } - } - - public void Dispose() - { - if (_timer != null) - { - _timer.Dispose(); - _timer = null; - } - } - } -} diff --git a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj index 0e4d95c310..2e33ee2d5f 100644 --- a/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj +++ b/MediaBrowser.ServerApplication/MediaBrowser.ServerApplication.csproj @@ -61,14 +61,14 @@ </PropertyGroup> <ItemGroup> <Reference Include="MediaBrowser.IsoMounter"> - <HintPath>..\packages\MediaBrowser.IsoMounting.3.0.68\lib\net45\MediaBrowser.IsoMounter.dll</HintPath> + <HintPath>..\packages\MediaBrowser.IsoMounting.3.0.69\lib\net45\MediaBrowser.IsoMounter.dll</HintPath> </Reference> <Reference Include="NLog, Version=3.1.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\packages\NLog.3.1.0.0\lib\net45\NLog.dll</HintPath> </Reference> <Reference Include="pfmclrapi"> - <HintPath>..\packages\MediaBrowser.IsoMounting.3.0.68\lib\net45\pfmclrapi.dll</HintPath> + <HintPath>..\packages\MediaBrowser.IsoMounting.3.0.69\lib\net45\pfmclrapi.dll</HintPath> </Reference> <Reference Include="ServiceStack.Interfaces"> <HintPath>..\ThirdParty\ServiceStack\ServiceStack.Interfaces.dll</HintPath> @@ -100,7 +100,6 @@ <Compile Include="EntryPoints\KeepServerAwake.cs" /> <Compile Include="EntryPoints\ResourceEntryPoint.cs" /> <Compile Include="EntryPoints\StartupWizard.cs" /> - <Compile Include="EntryPoints\WanAddressEntryPoint.cs" /> <Compile Include="FFMpeg\FFMpegDownloader.cs" /> <Compile Include="FFMpeg\FFMpegDownloadInfo.cs" /> <Compile Include="FFMpeg\FFMpegInfo.cs" /> diff --git a/MediaBrowser.ServerApplication/Networking/NetworkManager.cs b/MediaBrowser.ServerApplication/Networking/NetworkManager.cs index 4d4d5a4514..fc4d263636 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 /// </summary> public class NetworkManager : BaseNetworkManager, INetworkManager { + public NetworkManager(ILogger logger) + : base(logger) + { + } + /// <summary> /// Gets the network shares. /// </summary> diff --git a/MediaBrowser.ServerApplication/packages.config b/MediaBrowser.ServerApplication/packages.config index 267084c528..8de487fb50 100644 --- a/MediaBrowser.ServerApplication/packages.config +++ b/MediaBrowser.ServerApplication/packages.config @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> <packages> - <package id="MediaBrowser.IsoMounting" version="3.0.68" targetFramework="net45" /> + <package id="MediaBrowser.IsoMounting" version="3.0.69" targetFramework="net45" /> <package id="NLog" version="3.1.0.0" targetFramework="net45" /> </packages>
\ No newline at end of file |
