|
@@ -1368,7 +1368,17 @@ namespace Emby.Server.Implementations
|
|
public async Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken)
|
|
public async Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
|
|
var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
|
|
- var wanAddress = await GetWanApiUrl(cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
+
|
|
|
|
+ string wanAddress;
|
|
|
|
+
|
|
|
|
+ if (string.IsNullOrEmpty(ServerConfigurationManager.Configuration.WanDdns))
|
|
|
|
+ {
|
|
|
|
+ wanAddress = await GetWanApiUrlFromExternal(cancellationToken).ConfigureAwait(false);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ wanAddress = GetWanApiUrl(ServerConfigurationManager.Configuration.WanDdns);
|
|
|
|
+ }
|
|
|
|
|
|
return new SystemInfo
|
|
return new SystemInfo
|
|
{
|
|
{
|
|
@@ -1417,8 +1427,18 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
public async Task<PublicSystemInfo> GetPublicSystemInfo(CancellationToken cancellationToken)
|
|
public async Task<PublicSystemInfo> GetPublicSystemInfo(CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
- var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
|
|
|
|
- var wanAddress = await GetWanApiUrl(cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
+ var localAddress = await GetLocalApiUrl(cancellationToken).ConfigureAwait(false);
|
|
|
|
+
|
|
|
|
+ string wanAddress;
|
|
|
|
+
|
|
|
|
+ if (string.IsNullOrEmpty(ServerConfigurationManager.Configuration.WanDdns))
|
|
|
|
+ {
|
|
|
|
+ wanAddress = await GetWanApiUrlFromExternal(cancellationToken).ConfigureAwait(false);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ wanAddress = GetWanApiUrl(ServerConfigurationManager.Configuration.WanDdns);
|
|
|
|
+ }
|
|
return new PublicSystemInfo
|
|
return new PublicSystemInfo
|
|
{
|
|
{
|
|
Version = ApplicationVersion,
|
|
Version = ApplicationVersion,
|
|
@@ -1456,7 +1476,7 @@ namespace Emby.Server.Implementations
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- public async Task<string> GetWanApiUrl(CancellationToken cancellationToken)
|
|
|
|
|
|
+ public async Task<string> GetWanApiUrlFromExternal(CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
const string Url = "http://ipv4.icanhazip.com";
|
|
const string Url = "http://ipv4.icanhazip.com";
|
|
try
|
|
try
|
|
@@ -1472,7 +1492,7 @@ namespace Emby.Server.Implementations
|
|
CancellationToken = cancellationToken
|
|
CancellationToken = cancellationToken
|
|
}).ConfigureAwait(false))
|
|
}).ConfigureAwait(false))
|
|
{
|
|
{
|
|
- return GetLocalApiUrl(response.ReadToEnd().Trim());
|
|
|
|
|
|
+ return GetWanApiUrl(response.ReadToEnd().Trim());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -1494,11 +1514,40 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
public string GetLocalApiUrl(string host)
|
|
public string GetLocalApiUrl(string host)
|
|
{
|
|
{
|
|
|
|
+ if (EnableHttps)
|
|
|
|
+ {
|
|
|
|
+ return string.Format("https://{0}:{1}",
|
|
|
|
+ host,
|
|
|
|
+ HttpsPort.ToString(CultureInfo.InvariantCulture));
|
|
|
|
+ }
|
|
return string.Format("http://{0}:{1}",
|
|
return string.Format("http://{0}:{1}",
|
|
- host,
|
|
|
|
- HttpPort.ToString(CultureInfo.InvariantCulture));
|
|
|
|
|
|
+ host,
|
|
|
|
+ HttpPort.ToString(CultureInfo.InvariantCulture));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public string GetWanApiUrl(IpAddressInfo ipAddress)
|
|
|
|
+ {
|
|
|
|
+ if (ipAddress.AddressFamily == IpAddressFamily.InterNetworkV6)
|
|
|
|
+ {
|
|
|
|
+ return GetWanApiUrl("[" + ipAddress.Address + "]");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return GetWanApiUrl(ipAddress.Address);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public string GetWanApiUrl(string host)
|
|
|
|
+ {
|
|
|
|
+ if (EnableHttps)
|
|
|
|
+ {
|
|
|
|
+ return string.Format("https://{0}:{1}",
|
|
|
|
+ host,
|
|
|
|
+ ServerConfigurationManager.Configuration.PublicHttpsPort.ToString(CultureInfo.InvariantCulture));
|
|
|
|
+ }
|
|
|
|
+ return string.Format("http://{0}:{1}",
|
|
|
|
+ host,
|
|
|
|
+ ServerConfigurationManager.Configuration.PublicPort.ToString(CultureInfo.InvariantCulture));
|
|
|
|
+ }
|
|
|
|
+
|
|
public Task<List<IpAddressInfo>> GetLocalIpAddresses(CancellationToken cancellationToken)
|
|
public Task<List<IpAddressInfo>> GetLocalIpAddresses(CancellationToken cancellationToken)
|
|
{
|
|
{
|
|
return GetLocalIpAddressesInternal(true, 0, cancellationToken);
|
|
return GetLocalIpAddressesInternal(true, 0, cancellationToken);
|