mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
chore: disable DLNA by default
This commit is contained in:
parent
2a89683e80
commit
b4954985be
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
|
||||||
{
|
{
|
||||||
@ -54,8 +55,6 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[Produces(MediaTypeNames.Text.Xml)]
|
[Produces(MediaTypeNames.Text.Xml)]
|
||||||
[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 url = GetAbsoluteUri();
|
||||||
var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase));
|
var serverAddress = url.Substring(0, url.IndexOf("/dlna/", StringComparison.OrdinalIgnoreCase));
|
||||||
@ -63,9 +62,6 @@ namespace Jellyfin.Api.Controllers
|
|||||||
return Ok(xml);
|
return Ok(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
return StatusCode(StatusCodes.Status503ServiceUnavailable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets Dlna content directory xml.
|
/// Gets Dlna content directory xml.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -82,15 +78,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[ProducesFile(MediaTypeNames.Text.Xml)]
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
||||||
[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>
|
||||||
/// Gets Dlna media receiver registrar xml.
|
/// Gets Dlna media receiver registrar xml.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -107,15 +98,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[ProducesFile(MediaTypeNames.Text.Xml)]
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
||||||
[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>
|
||||||
/// Gets Dlna media receiver registrar xml.
|
/// Gets Dlna media receiver registrar xml.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -132,15 +118,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[ProducesFile(MediaTypeNames.Text.Xml)]
|
[ProducesFile(MediaTypeNames.Text.Xml)]
|
||||||
[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>
|
||||||
/// Process a content directory control request.
|
/// Process a content directory control request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -154,15 +135,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[Produces(MediaTypeNames.Text.Xml)]
|
[Produces(MediaTypeNames.Text.Xml)]
|
||||||
[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>
|
||||||
/// Process a connection manager control request.
|
/// Process a connection manager control request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -176,15 +152,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[Produces(MediaTypeNames.Text.Xml)]
|
[Produces(MediaTypeNames.Text.Xml)]
|
||||||
[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>
|
||||||
/// Process a media receiver registrar control request.
|
/// Process a media receiver registrar control request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -198,15 +169,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[Produces(MediaTypeNames.Text.Xml)]
|
[Produces(MediaTypeNames.Text.Xml)]
|
||||||
[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>
|
||||||
/// Processes an event subscription request.
|
/// Processes an event subscription request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -223,15 +189,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[Produces(MediaTypeNames.Text.Xml)]
|
[Produces(MediaTypeNames.Text.Xml)]
|
||||||
[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>
|
||||||
/// Processes an event subscription request.
|
/// Processes an event subscription request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -248,15 +209,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[Produces(MediaTypeNames.Text.Xml)]
|
[Produces(MediaTypeNames.Text.Xml)]
|
||||||
[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>
|
||||||
/// Processes an event subscription request.
|
/// Processes an event subscription request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -273,15 +229,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[Produces(MediaTypeNames.Text.Xml)]
|
[Produces(MediaTypeNames.Text.Xml)]
|
||||||
[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>
|
||||||
/// Gets a server icon.
|
/// Gets a server icon.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -298,15 +249,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
||||||
[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>
|
||||||
/// Gets a server icon.
|
/// Gets a server icon.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -321,15 +267,10 @@ namespace Jellyfin.Api.Controllers
|
|||||||
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
[ProducesResponseType(StatusCodes.Status503ServiceUnavailable)]
|
||||||
[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)
|
||||||
{
|
{
|
||||||
var icon = _dlnaManager.GetIcon(fileName);
|
var icon = _dlnaManager.GetIcon(fileName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user