Add a feature switch to reachability

This commit is contained in:
2026-08-03 21:02:31 +02:00
parent 51d76cd451
commit 781c6047ca
2 changed files with 15 additions and 8 deletions
+2
View File
@@ -5,3 +5,5 @@ $state_file = "state.json"; // The location for the state file. If it does not e
$error_reporting = false; // Whether PHP errors should be shown. Not recommended for production. $error_reporting = false; // Whether PHP errors should be shown. Not recommended for production.
$lobby_timeout_seconds = 30; // How long it should take for unresponsive lobbies to get auto-delisted. $lobby_timeout_seconds = 30; // How long it should take for unresponsive lobbies to get auto-delisted.
$check_reachability = true; // Whether to reach out to the lobby listing host to confirm the lobby is reachable.
+5
View File
@@ -30,6 +30,7 @@ if ($error_reporting) {
$reachable = false; $reachable = false;
if (isset($_GET["new"])) { if (isset($_GET["new"])) {
if ($check_reachability) {
require "enet_probe.php"; require "enet_probe.php";
$host = $_SERVER['REMOTE_ADDR']; $host = $_SERVER['REMOTE_ADDR'];
if (!empty($_GET["host"])) { if (!empty($_GET["host"])) {
@@ -40,6 +41,10 @@ if (isset($_GET["new"])) {
$port = intval($_GET["port"]); $port = intval($_GET["port"]);
} }
$reachable = enet_probe($host, $port); $reachable = enet_probe($host, $port);
}
else {
$reachable = true;
}
} }
$dirname = dirname($state_file); $dirname = dirname($state_file);