Skip to content

Commit

Permalink
chore: Update Util.php to handle missing swoole_get_local_ip function…
Browse files Browse the repository at this point in the history
… (#689)

* chore: Update Util.php to handle missing swoole_get_local_ip function

* chore: Remove unused ContainerInterface property from Hub class

---------

Co-authored-by: Deeka Wong <[email protected]>
  • Loading branch information
huangdijia and huangdijia committed Jul 20, 2024
1 parent c76029e commit a2a085e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ class Util
*/
public static function getInternalIp(): string
{
$ips = swoole_get_local_ip();
if (function_exists('swoole_get_local_ip')) {
$ips = swoole_get_local_ip();

if (is_array($ips) && ! empty($ips)) {
return current($ips);
if (is_array($ips) && ! empty($ips)) {
return current($ips);
}
}

/** @var mixed|string $ip */
$ip = gethostbyname(gethostname());

if (is_string($ip)) {
return $ip;
}
Expand Down

0 comments on commit a2a085e

Please sign in to comment.