aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Middleware/LanFilteringMiddleware.cs
diff options
context:
space:
mode:
authorjade <software@lfcode.ca>2025-06-03 14:22:30 -0700
committerGitHub <noreply@github.com>2025-06-03 15:22:30 -0600
commit44b5de156886995fdcf881cbc1208505ad0e8b0e (patch)
treea9134d5c4ae3d3871259ee82eef3f03b22c1e872 /Jellyfin.Api/Middleware/LanFilteringMiddleware.cs
parent08b2ffeaabdd2cf716e6c8fe2da744718ba9c0ea (diff)
Fix missing logging of connections by disallowed IPs (#14011)
Diffstat (limited to 'Jellyfin.Api/Middleware/LanFilteringMiddleware.cs')
-rw-r--r--Jellyfin.Api/Middleware/LanFilteringMiddleware.cs51
1 files changed, 0 insertions, 51 deletions
diff --git a/Jellyfin.Api/Middleware/LanFilteringMiddleware.cs b/Jellyfin.Api/Middleware/LanFilteringMiddleware.cs
deleted file mode 100644
index 35b0a1dd0..000000000
--- a/Jellyfin.Api/Middleware/LanFilteringMiddleware.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-using System.Net;
-using System.Threading.Tasks;
-using MediaBrowser.Common.Extensions;
-using MediaBrowser.Common.Net;
-using MediaBrowser.Controller.Configuration;
-using Microsoft.AspNetCore.Http;
-
-namespace Jellyfin.Api.Middleware;
-
-/// <summary>
-/// Validates the LAN host IP based on application configuration.
-/// </summary>
-public class LanFilteringMiddleware
-{
- private readonly RequestDelegate _next;
-
- /// <summary>
- /// Initializes a new instance of the <see cref="LanFilteringMiddleware"/> class.
- /// </summary>
- /// <param name="next">The next delegate in the pipeline.</param>
- public LanFilteringMiddleware(RequestDelegate next)
- {
- _next = next;
- }
-
- /// <summary>
- /// Executes the middleware action.
- /// </summary>
- /// <param name="httpContext">The current HTTP context.</param>
- /// <param name="networkManager">The network manager.</param>
- /// <param name="serverConfigurationManager">The server configuration manager.</param>
- /// <returns>The async task.</returns>
- public async Task Invoke(HttpContext httpContext, INetworkManager networkManager, IServerConfigurationManager serverConfigurationManager)
- {
- if (serverConfigurationManager.GetNetworkConfiguration().EnableRemoteAccess)
- {
- await _next(httpContext).ConfigureAwait(false);
- return;
- }
-
- var host = httpContext.GetNormalizedRemoteIP();
- if (!networkManager.IsInLocalNetwork(host))
- {
- // No access from network, respond with 503 instead of 200.
- httpContext.Response.StatusCode = StatusCodes.Status503ServiceUnavailable;
- return;
- }
-
- await _next(httpContext).ConfigureAwait(false);
- }
-}