refactor(deployment): Remove WireGuard VPN dependency and restore public service access
Remove WireGuard integration from production deployment to simplify infrastructure: - Remove docker-compose-direct-access.yml (VPN-bound services) - Remove VPN-only middlewares from Grafana, Prometheus, Portainer - Remove WireGuard middleware definitions from Traefik - Remove WireGuard IPs (10.8.0.0/24) from Traefik forwarded headers All monitoring services now publicly accessible via subdomains: - grafana.michaelschiemer.de (with Grafana native auth) - prometheus.michaelschiemer.de (with Basic Auth) - portainer.michaelschiemer.de (with Portainer native auth) All services use Let's Encrypt SSL certificates via Traefik.
This commit is contained in:
122
tests/debug/test-encoding-exact-structure.php
Normal file
122
tests/debug/test-encoding-exact-structure.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
echo "=== Exact Encoding Structure ===\n\n";
|
||||
|
||||
$testData = 'HELLO WORLD';
|
||||
|
||||
// Build our encoding
|
||||
$bits = '';
|
||||
|
||||
// 1. Mode indicator (4 bits) - Byte mode = 0100
|
||||
$bits .= '0100';
|
||||
|
||||
// 2. Character count (8 bits)
|
||||
$bits .= str_pad(decbin(11), 8, '0', STR_PAD_LEFT);
|
||||
|
||||
// 3. Data bytes
|
||||
for ($i = 0; $i < 11; $i++) {
|
||||
$byte = ord($testData[$i]);
|
||||
$bits .= str_pad(decbin($byte), 8, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
echo "After mode + count + data: " . strlen($bits) . " bits\n";
|
||||
|
||||
// Convert to codewords so far
|
||||
$codewordsSoFar = [];
|
||||
for ($i = 0; $i < strlen($bits); $i += 8) {
|
||||
if ($i + 8 <= strlen($bits)) {
|
||||
$byte = substr($bits, $i, 8);
|
||||
$codewordsSoFar[] = bindec($byte);
|
||||
}
|
||||
}
|
||||
|
||||
echo "Codewords so far: " . count($codewordsSoFar) . "\n";
|
||||
echo implode(', ', $codewordsSoFar) . "\n\n";
|
||||
|
||||
// Check: mode + count + data should be exactly 100 bits
|
||||
// But we need to check if the last byte is complete
|
||||
$remainder = strlen($bits) % 8;
|
||||
echo "Remainder after data: {$remainder}\n";
|
||||
|
||||
if ($remainder !== 0) {
|
||||
echo "⚠️ Data doesn't end at byte boundary! Last {$remainder} bits incomplete.\n";
|
||||
} else {
|
||||
echo "✅ Data ends at byte boundary.\n";
|
||||
}
|
||||
|
||||
// Expected codewords
|
||||
$expected = [64, 180, 132, 84, 196, 196, 242, 5, 116, 245, 174, 59, 64, 109, 236, 233];
|
||||
|
||||
// Build expected bit string
|
||||
$expectedBits = '';
|
||||
foreach ($expected as $cw) {
|
||||
$expectedBits .= str_pad(decbin($cw), 8, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
echo "\n=== Comparison ===\n";
|
||||
echo "Our bits length: " . strlen($bits) . "\n";
|
||||
echo "Expected bits length: " . strlen($expectedBits) . "\n\n";
|
||||
|
||||
// Show first 13 codewords (mode + count + data should be 12 codewords = 96 bits)
|
||||
// But we have 100 bits, so that's 12.5 codewords?
|
||||
echo "First 12 codewords (96 bits):\n";
|
||||
echo "Our: " . substr($bits, 0, 96) . "\n";
|
||||
echo "Expected: " . substr($expectedBits, 0, 96) . "\n";
|
||||
echo "Match: " . (substr($bits, 0, 96) === substr($expectedBits, 0, 96) ? "✅" : "❌") . "\n\n";
|
||||
|
||||
// Show bits 96-104 (this should be the last 4 bits of data + terminator)
|
||||
echo "Bits 96-104 (last 4 data bits + terminator):\n";
|
||||
echo "Our: " . substr($bits, 96, 8) . "\n";
|
||||
echo "Expected: " . substr($expectedBits, 96, 8) . "\n";
|
||||
echo "Match: " . (substr($bits, 96, 8) === substr($expectedBits, 96, 8) ? "✅" : "❌") . "\n\n";
|
||||
|
||||
// The issue: After 100 bits of data, we should have:
|
||||
// - 4 bits terminator (making 104 bits total)
|
||||
// - Then pad to byte (making 104 bits, which is already a multiple of 8)
|
||||
// - Then add pad codewords to reach 128 bits (3 pad codewords = 24 bits)
|
||||
|
||||
echo "Expected structure:\n";
|
||||
echo " Bits 0-99: Mode + Count + Data (100 bits)\n";
|
||||
echo " Bits 100-103: Terminator (4 bits)\n";
|
||||
echo " Bits 104-127: Pad codewords (24 bits = 3 codewords)\n\n";
|
||||
|
||||
echo "Expected bits 100-127:\n";
|
||||
echo substr($expectedBits, 100, 28) . "\n";
|
||||
echo "This should be: terminator (4 bits) + padding (24 bits)\n\n";
|
||||
|
||||
// Show what our encoding produces
|
||||
echo "Our bits 100-127:\n";
|
||||
// But we only have 104 bits so far!
|
||||
echo "Current length: " . strlen($bits) . " bits\n";
|
||||
|
||||
// Add terminator
|
||||
$requiredBits = 128;
|
||||
$terminatorLength = min(4, max(0, $requiredBits - strlen($bits)));
|
||||
$bits .= str_repeat('0', $terminatorLength);
|
||||
echo "After terminator ({$terminatorLength} bits): " . strlen($bits) . " bits\n";
|
||||
|
||||
// Pad to byte
|
||||
$remainder = strlen($bits) % 8;
|
||||
if ($remainder !== 0) {
|
||||
$bits .= str_repeat('0', 8 - $remainder);
|
||||
}
|
||||
echo "After padding to byte: " . strlen($bits) . " bits\n";
|
||||
|
||||
// Add pad codewords
|
||||
$padBytes = ['11101100', '00010001'];
|
||||
$padIndex = 0;
|
||||
while (strlen($bits) < $requiredBits) {
|
||||
$bits .= $padBytes[$padIndex % 2];
|
||||
$padIndex++;
|
||||
}
|
||||
echo "After pad codewords: " . strlen($bits) . " bits\n\n";
|
||||
|
||||
echo "Our bits 100-127:\n";
|
||||
echo substr($bits, 100, 28) . "\n";
|
||||
echo "Expected bits 100-127:\n";
|
||||
echo substr($expectedBits, 100, 28) . "\n";
|
||||
echo "Match: " . (substr($bits, 100, 28) === substr($expectedBits, 100, 28) ? "✅" : "❌") . "\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user