diff --git a/src/CAVerifierServer.HttpApi.Host/RealIpMiddleware.cs b/src/CAVerifierServer.HttpApi.Host/RealIpMiddleware.cs index 951a7af..31edc1b 100644 --- a/src/CAVerifierServer.HttpApi.Host/RealIpMiddleware.cs +++ b/src/CAVerifierServer.HttpApi.Host/RealIpMiddleware.cs @@ -28,35 +28,35 @@ public RealIpMiddleware(RequestDelegate requestDelegate, IOptions public async Task Invoke(HttpContext context) { - var headers = context.Request.Headers; - if (!headers.ContainsKey(_realIpOptions.HeaderKey)) - { - throw new ExternalException("Unknown ip address. no setting"); - } - - var ipArr = headers["X-Forwarded-For"].ToString().Split(','); - if (ipArr.Length == 0) - { - _logger.LogDebug("Unknown ip address"); - throw new ExternalException("Unknown ip address. Refused visit server.ipArr is null"); - } -#if DEBUG - if (ipArr.Contains(LocalIpaddress)) - { - await _requestDelegate(context); - return; - } -#endif - _logger.LogDebug("Received IpList is :{ipList}", headers["X-Forwarded-For"]); - var ipList = ipArr.Select(ip => ip.Trim()).ToList(); - _logger.LogInformation("ipList count {count} :",ipList.Count); - var caServerAddressIp = await _accountAppService.WhiteListCheckAsync(ipList); - _logger.LogInformation("caServerAddressIp is {0}",caServerAddressIp); - if (string.IsNullOrEmpty(caServerAddressIp)) - { - _logger.LogDebug($"Resolve real ip is not in whiteList,Please check and retry."); - throw new ExternalException("Resolve real ip is not in whiteList,Please check and retry."); - } +// var headers = context.Request.Headers; +// if (!headers.ContainsKey(_realIpOptions.HeaderKey)) +// { +// throw new ExternalException("Unknown ip address. no setting"); +// } +// +// var ipArr = headers["X-Forwarded-For"].ToString().Split(','); +// if (ipArr.Length == 0) +// { +// _logger.LogDebug("Unknown ip address"); +// throw new ExternalException("Unknown ip address. Refused visit server.ipArr is null"); +// } +// #if DEBUG +// if (ipArr.Contains(LocalIpaddress)) +// { +// await _requestDelegate(context); +// return; +// } +// #endif +// _logger.LogDebug("Received IpList is :{ipList}", headers["X-Forwarded-For"]); +// var ipList = ipArr.Select(ip => ip.Trim()).ToList(); +// _logger.LogInformation("ipList count {count} :",ipList.Count); +// var caServerAddressIp = await _accountAppService.WhiteListCheckAsync(ipList); +// _logger.LogInformation("caServerAddressIp is {0}",caServerAddressIp); +// if (string.IsNullOrEmpty(caServerAddressIp)) +// { +// _logger.LogDebug($"Resolve real ip is not in whiteList,Please check and retry."); +// throw new ExternalException("Resolve real ip is not in whiteList,Please check and retry."); +// } await _requestDelegate(context); } } \ No newline at end of file