swoft-cloud / forum

Swoft Official Forum. Swoft 官方论坛
https://github.com/swoft-cloud/forum/issues
2 stars 1 forks source link

如何获取来源IP #5

Open ZoroZdd opened 4 years ago

ZoroZdd commented 4 years ago
Q A
Bug report? yes/no
Feature request? yes/no
Swoft version x.y.z
Swoole version x.y.z (by php --ri swoole)
PHP version x.y.z (by php -v)
Runtime environment Win10/Mac/CentOS 7/Ubuntu/Docker etc.

Describe the bug A clear and concise description of what the bug is.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Details

Describe what you are trying to achieve and what goes wrong.

// paste output here

Provide minimal script to reproduce the issue

// paste code
inhere commented 4 years ago

看你在什么server下

http server 可以:

$req = context()->getReqest();
$req->getServerParam('');

// 获取原始 swoole request
$swReq = $req->getSwooleServer();

rpc, tcp, ws 可以用: server()->getClientInfo($fd);