aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/ApplicationHost.cs
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2018-12-30 01:04:27 -0500
committerGitHub <noreply@github.com>2018-12-30 01:04:27 -0500
commit76b647e0a8eddd65dc9c4de7b887a3faf6e12bcc (patch)
treea0fcc6a59c597f7c288dd3619c7e72bf97d2e0ea /Emby.Server.Implementations/ApplicationHost.cs
parenta86b71899ec52c44ddc6c3018e8cc5e9d7ff4d62 (diff)
parentd10d632c489b94566bbcf1b7e9c2bb86c31c97b1 (diff)
Merge pull request #325 from jellyfin/devv3.5.2-5
Master 3.5.2-5
Diffstat (limited to 'Emby.Server.Implementations/ApplicationHost.cs')
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs37
1 files changed, 31 insertions, 6 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs
index c6cfe7214..ad15b015d 100644
--- a/Emby.Server.Implementations/ApplicationHost.cs
+++ b/Emby.Server.Implementations/ApplicationHost.cs
@@ -728,7 +728,7 @@ namespace Emby.Server.Implementations
Logger.Info("ServerId: {0}", SystemId);
- var entryPoints = GetExports<IServerEntryPoint>().ToList();
+ var entryPoints = GetExports<IServerEntryPoint>();
RunEntryPoints(entryPoints, true);
Logger.Info("Core startup complete");
@@ -1962,6 +1962,7 @@ namespace Emby.Server.Implementations
public async Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken)
{
var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
+ var wanAddress = await GetWanApiUrl(cancellationToken).ConfigureAwait(false);
return new SystemInfo
{
@@ -1984,8 +1985,7 @@ namespace Emby.Server.Implementations
CanSelfRestart = CanSelfRestart,
CanSelfUpdate = CanSelfUpdate,
CanLaunchWebBrowser = CanLaunchWebBrowser,
- // TODO - remove WanAddress
- WanAddress = "0.0.0.0",
+ WanAddress = wanAddress,
HasUpdateAvailable = HasUpdateAvailable,
SupportsAutoRunAtStartup = SupportsAutoRunAtStartup,
TranscodingTempPath = ApplicationPaths.TranscodingTempPath,
@@ -2012,14 +2012,13 @@ namespace Emby.Server.Implementations
public async Task<PublicSystemInfo> GetPublicSystemInfo(CancellationToken cancellationToken)
{
var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
-
+ var wanAddress = await GetWanApiUrl(cancellationToken).ConfigureAwait(false);
return new PublicSystemInfo
{
Version = ApplicationVersion.ToString(),
Id = SystemId,
OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(),
- // TODO - remove WanAddress
- WanAddress = "0.0.0.0",
+ WanAddress = wanAddress,
ServerName = FriendlyName,
LocalAddress = localAddress
};
@@ -2060,6 +2059,32 @@ namespace Emby.Server.Implementations
return null;
}
+ public async Task<string> GetWanApiUrl(CancellationToken cancellationToken)
+ {
+ var url = "http://ipv4.icanhazip.com";
+ try
+ {
+ using (var response = await HttpClient.Get(new HttpRequestOptions
+ {
+ Url = url,
+ LogErrorResponseBody = false,
+ LogErrors = false,
+ LogRequest = false,
+ TimeoutMs = 10000,
+ BufferContent = false,
+ CancellationToken = cancellationToken
+ }))
+ {
+ return GetLocalApiUrl(response.ReadToEnd().Trim());
+ }
+ }
+ catch(Exception ex)
+ {
+ Logger.ErrorException("Error getting WAN Ip address information", ex);
+ }
+ return null;
+ }
+
public string GetLocalApiUrl(IpAddressInfo ipAddress)
{
if (ipAddress.AddressFamily == IpAddressFamily.InterNetworkV6)