Browse Source

Apewer-6.0.4:修正 GetClientIP 参数不生效的问题。

dev
Elivo 5 years ago
parent
commit
3d15781ad7
  1. 2
      Apewer/Apewer.csproj
  2. 23
      Apewer/Web/WebUtility.cs
  3. 3
      Apewer/_ChangeLog.md

2
Apewer/Apewer.csproj

@ -14,7 +14,7 @@
<TargetFrameworks>netstandard2.1;net20;net40;net461;netcoreapp3.1</TargetFrameworks>
<Title>Apewer</Title>
<Product>Apewer Libraries</Product>
<Version>6.0.3</Version>
<Version>6.0.4</Version>
</PropertyGroup>
<!-- Info -->

23
Apewer/Web/WebUtility.cs

@ -149,17 +149,20 @@ namespace Apewer.Web
#endif
{
if (request == null) return null;
var direct = GetDirectIP(request);
var x_forwarded_for = GetForwardedIP(request);
var d = GetDirectIP(request);
var f = GetForwardedIP(request);
if (string.IsNullOrEmpty(direct))
{
return string.IsNullOrEmpty(x_forwarded_for) ? "NULL" : $"{x_forwarded_for},NULL";
}
else
{
return string.IsNullOrEmpty(x_forwarded_for) ? $"{direct}" : $"{x_forwarded_for},{direct}";
}
// return string.IsNullOrEmpty(f) ? "NULL" : $"{f},NULL";
// return string.IsNullOrEmpty(f) ? $"{d}" : $"{f},{d}";
// 没有代理,返回 Direct IP。
if (string.IsNullOrEmpty(f)) return d;
// 有代理,先加入 Forwarded IP,再加入 Direct IP。
var ip = f;
if (withProxy && !string.IsNullOrEmpty(d)) ip = ip + "," + d;
return ip;
}
/// <summary>请求来自于可信客户端。</summary>

3
Apewer/_ChangeLog.md

@ -5,6 +5,9 @@
### 最新提交
### 6.0.4
- 修正 GetClientIP 参数不生效的问题。
### 6.0.3
- 修正 GetParameter 获取不到 GET 参数的问题。

Loading…
Cancel
Save