From 44b5de156886995fdcf881cbc1208505ad0e8b0e Mon Sep 17 00:00:00 2001 From: jade Date: Tue, 3 Jun 2025 14:22:30 -0700 Subject: Fix missing logging of connections by disallowed IPs (#14011) --- .../Extensions/HttpContextExtensions.cs | 2 +- MediaBrowser.Common/Net/INetworkManager.cs | 4 +-- .../Net/RemoteAccessPolicyResult.cs | 29 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 MediaBrowser.Common/Net/RemoteAccessPolicyResult.cs (limited to 'MediaBrowser.Common') diff --git a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs index a1056b7c8..739a53c7a 100644 --- a/MediaBrowser.Common/Extensions/HttpContextExtensions.cs +++ b/MediaBrowser.Common/Extensions/HttpContextExtensions.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Common.Extensions /// Checks the origin of the HTTP context. /// /// The incoming HTTP context. - /// true if the request is coming from LAN, false otherwise. + /// true if the request is coming from the same machine as is running the server, false otherwise. public static bool IsLocal(this HttpContext context) { return (context.Connection.LocalIpAddress is null diff --git a/MediaBrowser.Common/Net/INetworkManager.cs b/MediaBrowser.Common/Net/INetworkManager.cs index d838144ff..bd785bcbc 100644 --- a/MediaBrowser.Common/Net/INetworkManager.cs +++ b/MediaBrowser.Common/Net/INetworkManager.cs @@ -127,7 +127,7 @@ namespace MediaBrowser.Common.Net /// Checks if has access to the server. /// /// IP address of the client. - /// True if it has access, otherwise false. - bool HasRemoteAccess(IPAddress remoteIP); + /// The result of evaluating the access policy, Allow if it should be allowed. + RemoteAccessPolicyResult ShouldAllowServerAccess(IPAddress remoteIP); } } diff --git a/MediaBrowser.Common/Net/RemoteAccessPolicyResult.cs b/MediaBrowser.Common/Net/RemoteAccessPolicyResult.cs new file mode 100644 index 000000000..193d37228 --- /dev/null +++ b/MediaBrowser.Common/Net/RemoteAccessPolicyResult.cs @@ -0,0 +1,29 @@ +using System; + +namespace MediaBrowser.Common.Net; + +/// +/// Result of . +/// +public enum RemoteAccessPolicyResult +{ + /// + /// The connection should be allowed. + /// + Allow, + + /// + /// The connection should be rejected since it is not from a local IP and remote access is disabled. + /// + RejectDueToRemoteAccessDisabled, + + /// + /// The connection should be rejected since it is from a blocklisted IP. + /// + RejectDueToIPBlocklist, + + /// + /// The connection should be rejected since it is from a remote IP that is not in the allowlist. + /// + RejectDueToNotAllowlistedRemoteIP, +} -- cgit v1.2.3