统一使用真实IP获取方式
将`getRemoteIp`和`getLocalIp`方法替换为`getRealIp`,确保在`OperationLogMiddleware`和`AdminAccountSafeCache`中获取的客户端IP地址一致。这个修改可能是为了应对代理或负载平衡器等中间件影响IP识别的情况。
This commit is contained in:
parent
a4d21adea5
commit
de60b1b1ca
@ -62,7 +62,7 @@ class OperationLogMiddleware implements MiddlewareInterface
|
|||||||
$systemLog->url = $request->url(true);
|
$systemLog->url = $request->url(true);
|
||||||
$systemLog->type = $request->post()?'POST':'GET';
|
$systemLog->type = $request->post()?'POST':'GET';
|
||||||
$systemLog->params = json_encode($params, true);
|
$systemLog->params = json_encode($params, true);
|
||||||
$systemLog->ip = $request->getRemoteIp();
|
$systemLog->ip = $request->getRealIp();
|
||||||
// $systemLog->result = $response->getContent();
|
// $systemLog->result = $response->getContent();
|
||||||
$systemLog->save();
|
$systemLog->save();
|
||||||
return $handler($request);
|
return $handler($request);
|
||||||
|
2
app/common/cache/AdminAccountSafeCache.php
vendored
2
app/common/cache/AdminAccountSafeCache.php
vendored
@ -14,7 +14,7 @@ class AdminAccountSafeCache extends BaseCache
|
|||||||
public function __construct($prefix = 'admin_')
|
public function __construct($prefix = 'admin_')
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$ip = \request()->getLocalIp();
|
$ip = \request()->getRealIp();
|
||||||
// $this->key = $this->tagName . $ip;
|
// $this->key = $this->tagName . $ip;
|
||||||
$this->key = $prefix . $ip;
|
$this->key = $prefix . $ip;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user