协程版仓库后端项目
Some checks failed
Build Docker / build (push) Has been cancelled

This commit is contained in:
2025-07-08 14:59:47 +08:00
commit 0b2299c427
134 changed files with 19277 additions and 0 deletions

View File

@ -0,0 +1,48 @@
<?php
/**
* Author: ykxiao
* Date: 2025/6/4
* Time: 上午9:51
* Description:
*
* (c) ykxiao <yk_9001@hotmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
declare(strict_types=1);
namespace App\Service;
use Psr\Http\Message\ServerRequestInterface;
/**
* Author: ykxiao
* Date: 2025/6/4
* Time: 上午10:19
* Description: 系统服务
*
* (c) ykxiao <yk_9001@hotmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
class SysService
{
/**
* 获取客户端IP信息
* @param ServerRequestInterface $request
* @return string
*/
public function getClientIpInfo(ServerRequestInterface $request): string
{
// 尝试从请求头获取客户端真实IP或转发的IP
$realIP = $request->getHeaderLine('x-real-ip');
$forwardedFor = $request->getHeaderLine('x-forwarded-for');
// 确定客户端IP优先使用 x-real-ip其次是 x-forwarded-for最后是默认IP
$clientIP = $realIP ?: $forwardedFor;
return $clientIP ?: '127.0.0.1';
}
}