Merge pull request #7954 from cvium/fix_7953_dlna_url

pull/7961/head
Cody Robibero 2 years ago committed by GitHub
commit 2c0c3eb3ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -313,7 +313,7 @@ namespace Emby.Dlna.Main
_logger.LogInformation("Registering publisher for {ResourceName} on {DeviceAddress}", fullService, address);
var uri = new UriBuilder(_appHost.GetApiUrlForLocalAccess(false) + descriptorUri);
var uri = new UriBuilder(_appHost.GetApiUrlForLocalAccess(address, false) + descriptorUri);
var device = new SsdpRootDevice
{

@ -1114,13 +1114,13 @@ namespace Emby.Server.Implementations
}
/// <inheritdoc/>
public string GetApiUrlForLocalAccess(bool allowHttps = true)
public string GetApiUrlForLocalAccess(IPObject hostname = null, bool allowHttps = true)
{
// With an empty source, the port will be null
string smart = NetManager.GetBindInterface(string.Empty, out _);
var smart = NetManager.GetBindInterface(hostname ?? IPHost.None, out _);
var scheme = !allowHttps ? Uri.UriSchemeHttp : null;
int? port = !allowHttps ? HttpPort : null;
return GetLocalApiUrl(smart.Trim('/'), scheme, port);
return GetLocalApiUrl(smart, scheme, port);
}
/// <inheritdoc/>
@ -1134,11 +1134,13 @@ namespace Emby.Server.Implementations
// NOTE: If no BaseUrl is set then UriBuilder appends a trailing slash, but if there is no BaseUrl it does
// not. For consistency, always trim the trailing slash.
scheme ??= ListenWithHttps ? Uri.UriSchemeHttps : Uri.UriSchemeHttp;
var isHttps = string.Equals(scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase);
return new UriBuilder
{
Scheme = scheme ?? (ListenWithHttps ? Uri.UriSchemeHttps : Uri.UriSchemeHttp),
Scheme = scheme,
Host = hostname,
Port = port ?? (ListenWithHttps ? HttpsPort : HttpPort),
Port = port ?? (isHttps ? HttpsPort : HttpPort),
Path = ConfigurationManager.GetNetworkConfiguration().BaseUrl
}.ToString().TrimEnd('/');
}

@ -4,6 +4,7 @@
using System.Net;
using MediaBrowser.Common;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.System;
using Microsoft.AspNetCore.Http;
@ -74,9 +75,10 @@ namespace MediaBrowser.Controller
/// <summary>
/// Gets an URL that can be used to access the API over LAN.
/// </summary>
/// <param name="hostname">An optional hostname to use.</param>
/// <param name="allowHttps">A value indicating whether to allow HTTPS.</param>
/// <returns>The API URL.</returns>
string GetApiUrlForLocalAccess(bool allowHttps = true);
string GetApiUrlForLocalAccess(IPObject hostname = null, bool allowHttps = true);
/// <summary>
/// Gets a local (LAN) URL that can be used to access the API.

Loading…
Cancel
Save