доп фукнции апи

This commit is contained in:
2026-07-28 20:42:23 +04:00
parent c007a755fe
commit 6c18cad816
13 changed files with 894 additions and 6 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Services;
class RealmStatusProbe
{
public function isOnline(string $address, int $port): bool
{
if ($address === '' || $port < 1 || $port > 65535) {
return false;
}
$host = str_contains($address, ':') && ! str_starts_with($address, '[')
? '['.$address.']'
: $address;
$timeout = max(0.1, min(3.0, (float) config('moonwell.launcher.realm_status_timeout', 0.5)));
$socket = @stream_socket_client(
'tcp://'.$host.':'.$port,
$errorCode,
$errorMessage,
$timeout,
STREAM_CLIENT_CONNECT,
);
if ($socket === false) {
return false;
}
fclose($socket);
return true;
}
}