|
|
@ -1369,7 +1369,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
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1419,7 +1429,17 @@ 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 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 PublicSystemInfo
|
|
|
|
return new PublicSystemInfo
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Version = ApplicationVersion,
|
|
|
|
Version = ApplicationVersion,
|
|
|
@ -1457,7 +1477,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
|
|
|
@ -1473,7 +1493,7 @@ namespace Emby.Server.Implementations
|
|
|
|
}).ConfigureAwait(false))
|
|
|
|
}).ConfigureAwait(false))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string res = await response.ReadToEndAsync().ConfigureAwait(false);
|
|
|
|
string res = await response.ReadToEndAsync().ConfigureAwait(false);
|
|
|
|
return GetLocalApiUrl(res.Trim());
|
|
|
|
return GetWanApiUrl(res.Trim());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
catch (Exception ex)
|
|
|
@ -1495,9 +1515,38 @@ 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}",
|
|
|
|
|
|
|
|
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}",
|
|
|
|
return string.Format("http://{0}:{1}",
|
|
|
|
host,
|
|
|
|
host,
|
|
|
|
HttpPort.ToString(CultureInfo.InvariantCulture));
|
|
|
|
ServerConfigurationManager.Configuration.PublicPort.ToString(CultureInfo.InvariantCulture));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Task<List<IpAddressInfo>> GetLocalIpAddresses(CancellationToken cancellationToken)
|
|
|
|
public Task<List<IpAddressInfo>> GetLocalIpAddresses(CancellationToken cancellationToken)
|
|
|
|