Closed joanhey closed 1 year ago
Create it in Http.php like this.
public function decode($buffer, $connection) { $_SERVER[‘SERVER_ADDR’] = $connection->getRemoteIp();
}
------------------ Original ------------------ From: Joan Miquel @.> Date: Wed,Jun 28,2023 6:25 PM To: walkor/workerman @.> Cc: walkor @.>, Mention @.> Subject: Re: [walkor/workerman] No way to get Server IP and Port directly (Issue #921)
Hi, Walkor
I want to add $_SERVER['SERVER_ADDR'] to Adapterman, but I can't find a direct way to get it.
I can create it in the Http.php, from Worker->socketName. But perhaps it will be better to be in the Worker.php, as it's useful in many apps.
@walkor What do you think is the best way or alternative ?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Hmmm;
getRemoteIP()
is the ip of the client, not the Server IP.
Update: Connection also have getLocalIp()
and getLocalPort()
. It isn't very fast, but we will update it later.
Hi, Walkor
I want to add
$_SERVER['SERVER_ADDR']
to Adapterman, but I can't find a direct way to get it.I can create it in the
Http.php
, fromWorker->socketName
. But perhaps it will be better to be in theWorker.php
, as it's useful in many apps.@walkor What do you think is the best way or alternative ?