diff options
| author | BaronGreenback <jimcartlidge@yahoo.co.uk> | 2021-05-01 17:21:14 +0100 |
|---|---|---|
| committer | BaronGreenback <jimcartlidge@yahoo.co.uk> | 2021-05-03 17:27:23 +0100 |
| commit | 7936ea59eb199980eaa47891a0e017143bbf8319 (patch) | |
| tree | 0ab90a5fb3e08a79faab010e34a06be30a73444e /Emby.Server.Implementations/ApplicationHost.cs | |
| parent | 2e01fb3cdaa788042009ac9d26f96cc6c336a8de (diff) | |
Changed selection method
Diffstat (limited to 'Emby.Server.Implementations/ApplicationHost.cs')
| -rw-r--r-- | Emby.Server.Implementations/ApplicationHost.cs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index c28b4ae1c..bd2bb54bd 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1201,11 +1201,25 @@ namespace Emby.Server.Implementations } /// <inheritdoc/> - public string GetExternalFacingHttpApiUrl() + public string GetInterfaceHttpApiUrl() { - // Passing an external address cause GetBindInterface to return the externally facing interface on a multi-adapter system. - // LocalNetworkSubnets and LocalNetworkAddresses are used in conjunction with the ip address to help select the best interface. - return GetLocalApiUrl(NetManager.GetBindInterface("0.0.0.0", out var _), Uri.UriSchemeHttp, HttpPort); + // Published server ends with a / + if (!string.IsNullOrEmpty(PublishedServerUrl)) + { + // Published server ends with a '/', so we need to remove it. + return PublishedServerUrl.Trim('/'); + } + + var bind = NetManager.GetInternalBindAddresses().FirstOrDefault() ?? new IPNetAddress(IPAddress.None); + + string smart = NetManager.GetBindInterface(bind, out var port); + // If the smartAPI doesn't start with http then treat it as a host or ip. + if (smart.StartsWith("http", StringComparison.OrdinalIgnoreCase)) + { + return smart.Trim('/'); + } + + return GetLocalApiUrl(smart.Trim('/'), null, port); } /// <inheritdoc/> |
