소스 검색

Respond with Service Unavailable if not in correct network

Cody Robibero 1 년 전
부모
커밋
adb0837dc2
2개의 변경된 파일5개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      Jellyfin.Api/Middleware/IpBasedAccessValidationMiddleware.cs
  2. 3 0
      Jellyfin.Api/Middleware/LanFilteringMiddleware.cs

+ 2 - 0
Jellyfin.Api/Middleware/IpBasedAccessValidationMiddleware.cs

@@ -41,6 +41,8 @@ public class IPBasedAccessValidationMiddleware
 
         if (!networkManager.HasRemoteAccess(remoteIP))
         {
+            // No access from network, respond with 503 instead of 200.
+            httpContext.Response.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
             return;
         }
 

+ 3 - 0
Jellyfin.Api/Middleware/LanFilteringMiddleware.cs

@@ -1,3 +1,4 @@
+using System.Net;
 using System.Threading.Tasks;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.Net;
@@ -40,6 +41,8 @@ public class LanFilteringMiddleware
         var host = httpContext.GetNormalizedRemoteIP();
         if (!networkManager.IsInLocalNetwork(host))
         {
+            // No access from network, respond with 503 instead of 200.
+            httpContext.Response.StatusCode = (int)HttpStatusCode.ServiceUnavailable;
             return;
         }