Add custom port support

This commit is contained in:
2026-07-31 00:07:49 +02:00
parent 0ea8c1684e
commit 553cbf4eae
+8 -2
View File
@@ -52,6 +52,7 @@ if (isset($_GET["list"])) {
$list[$id] = [
"id" => $lobby["id"],
"host" => $lobby["host"],
"port" => $lobby["port"],
"name" => $lobby["name"],
"creator" => $lobby["creator"],
"version" => $lobby["version"],
@@ -67,7 +68,11 @@ elseif (isset($_GET["new"])) {
if (!empty($_GET["host"])) {
$host = $_GET["host"];
}
$reachable = enet_probe($host, 50403);
$port = 50403;
if (!empty($_GET["port"]) && is_numeric($_GET["port"])) {
$port = intval($_GET["port"]);
}
$reachable = enet_probe($host, $port);
header("Content-Type: application/json");
if ($reachable) {
$id = generate_uuid_v4();
@@ -82,6 +87,7 @@ elseif (isset($_GET["new"])) {
"id" => $id,
"secret" => $secret,
"host" => $host,
"port" => $port,
"name" => $name,
"version" => $version,
"creator" => $creator,
@@ -93,7 +99,7 @@ elseif (isset($_GET["new"])) {
}
else {
http_response_code(424);
echo json_encode(["error" => "NOT_REACHABLE", "host" => $host]);
echo json_encode(["error" => "NOT_REACHABLE", "host" => $host, "port" => $port]);
}
}
elseif (isset($_GET["update"])) {