Extensions: updated GetRemoteEndPoint() to remove the conditional private ip check option.

This commit is contained in:
Shreyas Zare
2024-11-23 13:12:54 +05:30
parent c55bc9bcb8
commit 862857e725

View File

@@ -32,7 +32,7 @@ namespace DnsServerCore
{
readonly static string[] HTTP_METHODS = new string[] { "GET", "POST" };
public static IPEndPoint GetRemoteEndPoint(this HttpContext context, string realIpHeaderName = null, bool readRealIpHeaderForPrivateIpOnly = true)
public static IPEndPoint GetRemoteEndPoint(this HttpContext context, string realIpHeaderName = null)
{
try
{
@@ -43,7 +43,7 @@ namespace DnsServerCore
if (remoteIP.IsIPv4MappedToIPv6)
remoteIP = remoteIP.MapToIPv4();
if (!string.IsNullOrEmpty(realIpHeaderName) && (!readRealIpHeaderForPrivateIpOnly || NetUtilities.IsPrivateIP(remoteIP)))
if (!string.IsNullOrEmpty(realIpHeaderName) && NetUtilities.IsPrivateIP(remoteIP))
{
//get the real IP address of the requesting client from X-Real-IP header set in nginx proxy_pass block
string xRealIp = context.Request.Headers[realIpHeaderName];