Merge pull request #7868 from cvium/disable_dlna
This commit is contained in:
commit
aa0f6cb5eb
|
@ -13,7 +13,7 @@ namespace Emby.Dlna.Configuration
|
||||||
public DlnaOptions()
|
public DlnaOptions()
|
||||||
{
|
{
|
||||||
EnablePlayTo = true;
|
EnablePlayTo = true;
|
||||||
EnableServer = true;
|
EnableServer = false;
|
||||||
BlastAliveMessages = true;
|
BlastAliveMessages = true;
|
||||||
SendOnlyMatchedHost = true;
|
SendOnlyMatchedHost = true;
|
||||||
ClientDiscoveryIntervalSeconds = 60;
|
ClientDiscoveryIntervalSeconds = 60;
|
||||||
|
|
25
Jellyfin.Api/Attributes/DlnaEnabledAttribute.cs
Normal file
25
Jellyfin.Api/Attributes/DlnaEnabledAttribute.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
using Emby.Dlna;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace Jellyfin.Api.Attributes;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public sealed class DlnaEnabledAttribute : ActionFilterAttribute
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override void OnActionExecuting(ActionExecutingContext context)
|
||||||
|
{
|
||||||
|
var serverConfigurationManager = context.HttpContext.RequestServices.GetRequiredService<IServerConfigurationManager>();
|
||||||
|
|
||||||
|
var enabled = serverConfigurationManager.GetDlnaConfiguration().EnableServer;
|
||||||
|
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
context.Result = new StatusCodeResult(StatusCodes.Status503ServiceUnavailable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
/// Dlna Server Controller.
|
/// Dlna Server Controller.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Route("Dlna")]
|
[Route("Dlna")]
|
||||||
|
[DlnaEnabled]
|
||||||
[Authorize(Policy = Policies.AnonymousLanAccessPolicy)]
|
[Authorize(Policy = Policies.AnonymousLanAccessPolicy)]
|
||||||
public class DlnaServerController : BaseJellyfinApiController
|
public class DlnaServerController : BaseJellyfinApiController
|
||||||
{
|
{
|
||||||
|
@ -55,15 +56,10 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesFile(MediaTypeNames.Text.Xml)]
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
||||||
public ActionResult GetDescriptionXml([FromRoute, Required] string serverId)
|
public ActionResult GetDescriptionXml([FromRoute, Required] string serverId)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
var url = GetAbsoluteUri();
|
||||||
{
|
var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase));
|
||||||
var url = GetAbsoluteUri();
|
var xml = _dlnaManager.GetServerDescriptionXml(Request.Headers, serverId, serverAddress);
|
||||||
var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase));
|
return Ok(xml);
|
||||||
var xml = _dlnaManager.GetServerDescriptionXml(Request.Headers, serverId, serverAddress);
|
|
||||||
return Ok(xml);
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -83,12 +79,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
||||||
public ActionResult GetContentDirectory([FromRoute, Required] string serverId)
|
public ActionResult GetContentDirectory([FromRoute, Required] string serverId)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
return Ok(_contentDirectory.GetServiceXml());
|
||||||
{
|
|
||||||
return Ok(_contentDirectory.GetServiceXml());
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -108,12 +99,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
||||||
public ActionResult GetMediaReceiverRegistrar([FromRoute, Required] string serverId)
|
public ActionResult GetMediaReceiverRegistrar([FromRoute, Required] string serverId)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
return Ok(_mediaReceiverRegistrar.GetServiceXml());
|
||||||
{
|
|
||||||
return Ok(_mediaReceiverRegistrar.GetServiceXml());
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -133,12 +119,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "serverId", Justification = "Required for DLNA")]
|
||||||
public ActionResult GetConnectionManager([FromRoute, Required] string serverId)
|
public ActionResult GetConnectionManager([FromRoute, Required] string serverId)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
return Ok(_connectionManager.GetServiceXml());
|
||||||
{
|
|
||||||
return Ok(_connectionManager.GetServiceXml());
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -155,12 +136,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesFile(MediaTypeNames.Text.Xml)]
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
||||||
public async Task<ActionResult<ControlResponse>> ProcessContentDirectoryControlRequest([FromRoute, Required] string serverId)
|
public async Task<ActionResult<ControlResponse>> ProcessContentDirectoryControlRequest([FromRoute, Required] string serverId)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _contentDirectory).ConfigureAwait(false);
|
||||||
{
|
|
||||||
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _contentDirectory).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -177,12 +153,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesFile(MediaTypeNames.Text.Xml)]
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
||||||
public async Task<ActionResult<ControlResponse>> ProcessConnectionManagerControlRequest([FromRoute, Required] string serverId)
|
public async Task<ActionResult<ControlResponse>> ProcessConnectionManagerControlRequest([FromRoute, Required] string serverId)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _connectionManager).ConfigureAwait(false);
|
||||||
{
|
|
||||||
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _connectionManager).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -199,12 +170,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesFile(MediaTypeNames.Text.Xml)]
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
||||||
public async Task<ActionResult<ControlResponse>> ProcessMediaReceiverRegistrarControlRequest([FromRoute, Required] string serverId)
|
public async Task<ActionResult<ControlResponse>> ProcessMediaReceiverRegistrarControlRequest([FromRoute, Required] string serverId)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _mediaReceiverRegistrar).ConfigureAwait(false);
|
||||||
{
|
|
||||||
return await ProcessControlRequestInternalAsync(serverId, Request.Body, _mediaReceiverRegistrar).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -224,12 +190,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesFile(MediaTypeNames.Text.Xml)]
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
||||||
public ActionResult<EventSubscriptionResponse> ProcessMediaReceiverRegistrarEventRequest(string serverId)
|
public ActionResult<EventSubscriptionResponse> ProcessMediaReceiverRegistrarEventRequest(string serverId)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
return ProcessEventRequest(_mediaReceiverRegistrar);
|
||||||
{
|
|
||||||
return ProcessEventRequest(_mediaReceiverRegistrar);
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -249,12 +210,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesFile(MediaTypeNames.Text.Xml)]
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
||||||
public ActionResult<EventSubscriptionResponse> ProcessContentDirectoryEventRequest(string serverId)
|
public ActionResult<EventSubscriptionResponse> ProcessContentDirectoryEventRequest(string serverId)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
return ProcessEventRequest(_contentDirectory);
|
||||||
{
|
|
||||||
return ProcessEventRequest(_contentDirectory);
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -274,12 +230,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesFile(MediaTypeNames.Text.Xml)]
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
||||||
public ActionResult<EventSubscriptionResponse> ProcessConnectionManagerEventRequest(string serverId)
|
public ActionResult<EventSubscriptionResponse> ProcessConnectionManagerEventRequest(string serverId)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
return ProcessEventRequest(_connectionManager);
|
||||||
{
|
|
||||||
return ProcessEventRequest(_connectionManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -299,12 +250,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesImageFile]
|
[ProducesImageFile]
|
||||||
public ActionResult GetIconId([FromRoute, Required] string serverId, [FromRoute, Required] string fileName)
|
public ActionResult GetIconId([FromRoute, Required] string serverId, [FromRoute, Required] string fileName)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
return GetIconInternal(fileName);
|
||||||
{
|
|
||||||
return GetIconInternal(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -322,12 +268,7 @@ namespace Jellyfin.Api.Controllers
|
||||||
[ProducesImageFile]
|
[ProducesImageFile]
|
||||||
public ActionResult GetIcon([FromRoute, Required] string fileName)
|
public ActionResult GetIcon([FromRoute, Required] string fileName)
|
||||||
{
|
{
|
||||||
if (DlnaEntryPoint.Enabled)
|
return GetIconInternal(fileName);
|
||||||
{
|
|
||||||
return GetIconInternal(fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ActionResult GetIconInternal(string fileName)
|
private ActionResult GetIconInternal(string fileName)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user