diff --git a/index.php b/index.php index a02a6f5..420ff84 100644 --- a/index.php +++ b/index.php @@ -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"])) {