BonCodeAJP13.ServerPackets.BonCodeAJP13ForwardRequest.GetRemoteAddr C# (CSharp) Method

GetRemoteAddr() private method

Check for override on REMOTE_ADDR and return the value from designated header instead. Intermediaries such as Proxy Servers and Load Balancers hide the REMOTE_ADDR but add alternate headers. Most likely the HTTP_X_FORWARDED_FOR header is used for this.
private GetRemoteAddr ( NameValueCollection httpHeaders ) : string
httpHeaders System.Collections.Specialized.NameValueCollection
return string
        private string GetRemoteAddr(NameValueCollection httpHeaders)
        {
            string retVal = GetKeyValue(httpHeaders, "REMOTE_ADDR");
            //HTTP_X_FORWARDED_FOR
            if (BonCodeAJP13Settings.BONCODEAJP13_REMOTEADDR_FROM != "") {
                try
                {
                    string tempVal = GetKeyValue(httpHeaders,BonCodeAJP13Settings.BONCODEAJP13_REMOTEADDR_FROM);
                    if (tempVal != "") retVal = tempVal.Split(new char[] { ',' })[0];
                    //TODO: interate through and find left most non-private address
                    //(Left(testIP,3) NEQ "10.")  AND   (Left(testIP,7) NEQ "172.16.")   AND   (Left(testIP,8) NEQ "192.168.")
                } catch  {
                    //we will not return an alternate value in case of error
                }
            }

            return retVal;
        }