|
|
@ -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>
|
|
|
|