aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/ApplicationHost.cs
diff options
context:
space:
mode:
authorBaronGreenback <jimcartlidge@yahoo.co.uk>2021-05-01 17:21:14 +0100
committerBaronGreenback <jimcartlidge@yahoo.co.uk>2021-05-03 17:27:23 +0100
commit7936ea59eb199980eaa47891a0e017143bbf8319 (patch)
tree0ab90a5fb3e08a79faab010e34a06be30a73444e /Emby.Server.Implementations/ApplicationHost.cs
parent2e01fb3cdaa788042009ac9d26f96cc6c336a8de (diff)
Changed selection method
Diffstat (limited to 'Emby.Server.Implementations/ApplicationHost.cs')
-rw-r--r--Emby.Server.Implementations/ApplicationHost.cs22
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/>