diff options
| author | Phlogi <Phlogi@users.noreply.github.com> | 2019-03-24 11:59:40 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-24 11:59:40 +0100 |
| commit | 414a318a0d422a893401d1ecf84526043df36210 (patch) | |
| tree | c1de92f86937648ce803c9ab62694e5492bc9434 /Emby.Server.Implementations/ApplicationHost.cs | |
| parent | 0e787f4e9fb9f4a7159ca75bcd319c7f908df9a3 (diff) | |
WAN Address should use public ports instead of local ports.
https://github.com/jellyfin/jellyfin/issues/601#issuecomment-475941080
Diffstat (limited to 'Emby.Server.Implementations/ApplicationHost.cs')
| -rw-r--r-- | Emby.Server.Implementations/ApplicationHost.cs | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 484942946..5f4c30f0f 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1476,7 +1476,7 @@ namespace Emby.Server.Implementations CancellationToken = cancellationToken }).ConfigureAwait(false)) { - return GetLocalApiUrl(response.ReadToEnd().Trim()); + return GetWanApiUrl(response.ReadToEnd().Trim()); } } catch (Exception ex) @@ -1493,16 +1493,45 @@ namespace Emby.Server.Implementations return GetLocalApiUrl("[" + ipAddress.Address + "]"); } - return GetLocalApiUrl(ipAddress.Address); + return GetLocalApiUrlWithPort(ipAddress.Address); } - public string GetLocalApiUrl(string host) + public string GetLocalApiUrlWithPort(string host) { + if (EnableHttps) + { + return string.Format("http://{0}:{1}", + host, + HttpsPort.ToString(CultureInfo.InvariantCulture)); + } 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 GetLocalApiUrl("[" + ipAddress.Address + "]"); + } + + return GetWanApiUrlWithPort(ipAddress.Address); + } + + public string GetWanApiUrlWithPort(string host) + { + if (EnableHttps) + { + return string.Format("http://{0}:{1}", + host, + ServerConfiguration.PublicHttpsPort.ToString(CultureInfo.InvariantCulture)); + } + return string.Format("http://{0}:{1}", + host, + ServerConfiguration.PublicPort.ToString(CultureInfo.InvariantCulture)); + } + public Task<List<IpAddressInfo>> GetLocalIpAddresses(CancellationToken cancellationToken) { return GetLocalIpAddressesInternal(true, 0, cancellationToken); |
