This commit is contained in:
Gary Kwok
2024-02-23 18:13:31 +08:00
commit 0530779609
3215 changed files with 455593 additions and 0 deletions

24
src/index.php Normal file
View File

@@ -0,0 +1,24 @@
// src/index.php
<?php
$gw = "Unknown";
// 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";
?>