Update src/index.php

This commit is contained in:
2024-03-13 11:00:18 +08:00
parent a173adc5a6
commit 3ab884dac1

View File

@@ -1,24 +1,6 @@
// src/index.php // src/index.php
<?php <?php
<h2>This request is handeled by the server working on <?php echo $_SERVER['SERVER_ADDR'] ?></h2>
$gw = "Unknown"; echo "\nBuild no: 20240313-1100\n";
// Get the Docker host IP from the routing table
$table = file("/proc/net/route");
foreach ($table as $row) {
// Split the fields out of the routing table
$fields = preg_split("/[\t ]+/", trim($row));
// Skip this route if it's not the default gateway
if ($fields[1] != "00000000") continue;
// Convert the hex gateway IP to dotted-notation
$gw_hex = $fields[2];
$gw_rev = long2ip(hexdec("0x$gw_hex"));
$gw = implode(".", array_reverse(explode(".", $gw_rev)));
break;
}
echo "Docker host IP: $gw\n";
echo "Build no: 20240223-1725\n";
?> ?>