mirror of
https://github.com/fergalmoran/DnsServer.git
synced 2025-12-24 02:20:34 +00:00
WebService: fixed minor issue in GetRequestRemoteEndPoint().
This commit is contained in:
@@ -535,21 +535,18 @@ namespace DnsServerCore
|
||||
|
||||
private IPEndPoint GetRequestRemoteEndPoint(HttpListenerRequest request)
|
||||
{
|
||||
//this is due to mono NullReferenceException issue
|
||||
try
|
||||
{
|
||||
if (NetUtilities.IsPrivateIP(request.RemoteEndPoint.Address))
|
||||
string xRealIp = request.Headers["X-Real-IP"];
|
||||
if (IPAddress.TryParse(xRealIp, out IPAddress address))
|
||||
{
|
||||
//reverse proxy X-Real-IP header supported only when remote IP address is private
|
||||
|
||||
string xRealIp = request.Headers["X-Real-IP"];
|
||||
if (!string.IsNullOrEmpty(xRealIp))
|
||||
{
|
||||
//get the real IP address of the requesting client from X-Real-IP header set in nginx proxy_pass block
|
||||
return new IPEndPoint(IPAddress.Parse(xRealIp), 0);
|
||||
}
|
||||
//get the real IP address of the requesting client from X-Real-IP header set in nginx proxy_pass block
|
||||
return new IPEndPoint(address, 0);
|
||||
}
|
||||
|
||||
if (request.RemoteEndPoint == null)
|
||||
return new IPEndPoint(IPAddress.Any, 0);
|
||||
|
||||
return request.RemoteEndPoint;
|
||||
}
|
||||
catch
|
||||
|
||||
Reference in New Issue
Block a user