Add WanAddress to SystemInfo

This commit is contained in:
Luke Pulverenti
2013-12-08 14:39:39 -05:00
parent 803de20bb9
commit f856e166ff
6 changed files with 86 additions and 2 deletions

View File

@@ -28,7 +28,6 @@ using MediaBrowser.Controller.Session;
using MediaBrowser.Controller.Sorting;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.System;
using MediaBrowser.Model.Updates;
using MediaBrowser.Providers;
@@ -49,6 +48,7 @@ using MediaBrowser.Server.Implementations.Providers;
using MediaBrowser.Server.Implementations.ServerManager;
using MediaBrowser.Server.Implementations.Session;
using MediaBrowser.Server.Implementations.WebSocket;
using MediaBrowser.ServerApplication.EntryPoints;
using MediaBrowser.ServerApplication.FFMpeg;
using MediaBrowser.ServerApplication.IO;
using MediaBrowser.ServerApplication.Native;
@@ -616,7 +616,8 @@ namespace MediaBrowser.ServerApplication
HttpServerPortNumber = ServerConfigurationManager.Configuration.HttpServerPortNumber,
OperatingSystem = Environment.OSVersion.ToString(),
CanSelfRestart = CanSelfRestart,
CanSelfUpdate = CanSelfUpdate
CanSelfUpdate = CanSelfUpdate,
WanAddress = WanAddressEntryPoint.WanAddress
};
}

View File

@@ -0,0 +1,56 @@
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 (Exception ex)
{
var b = true;
}
}
public void Dispose()
{
if (_timer != null)
{
_timer.Dispose();
_timer = null;
}
}
}
}

View File

@@ -162,6 +162,7 @@
</Compile>
<Compile Include="EntryPoints\ResourceEntryPoint.cs" />
<Compile Include="EntryPoints\StartupWizard.cs" />
<Compile Include="EntryPoints\WanAddressEntryPoint.cs" />
<Compile Include="FFMpeg\FFMpegDownloadInfo.cs" />
<Compile Include="FFMpeg\FFMpegInfo.cs" />
<Compile Include="IO\FileSystemFactory.cs" />