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:
107
tests/debug/test-encoding-bit-by-bit.php
Normal file
107
tests/debug/test-encoding-bit-by-bit.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
echo "=== Bit-by-Bit Encoding Comparison ===\n\n";
|
||||
|
||||
$testData = 'HELLO WORLD';
|
||||
$dataLength = strlen($testData);
|
||||
|
||||
// Build our bit string
|
||||
$bits = '';
|
||||
|
||||
// 1. Mode indicator (4 bits) - Byte mode = 0100
|
||||
$bits .= '0100';
|
||||
|
||||
// 2. Character count (8 bits for version 1-9)
|
||||
$bits .= str_pad(decbin($dataLength), 8, '0', STR_PAD_LEFT);
|
||||
|
||||
// 3. Data bytes
|
||||
for ($i = 0; $i < $dataLength; $i++) {
|
||||
$byte = ord($testData[$i]);
|
||||
$bits .= str_pad(decbin($byte), 8, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
echo "Bits after mode + count + data: " . strlen($bits) . "\n";
|
||||
echo "First 60 bits: " . substr($bits, 0, 60) . "...\n\n";
|
||||
|
||||
// 4. Terminator
|
||||
$requiredBits = 16 * 8; // 128 bits for version 1, level M
|
||||
$terminatorLength = min(4, max(0, $requiredBits - strlen($bits)));
|
||||
$bits .= str_repeat('0', $terminatorLength);
|
||||
echo "After terminator ({$terminatorLength} bits): " . strlen($bits) . " bits\n\n";
|
||||
|
||||
// 5. Pad to multiple of 8
|
||||
$remainder = strlen($bits) % 8;
|
||||
if ($remainder !== 0) {
|
||||
$bits .= str_repeat('0', 8 - $remainder);
|
||||
}
|
||||
echo "After padding to byte: " . strlen($bits) . " bits\n\n";
|
||||
|
||||
// 6. Add pad codewords
|
||||
$padBytes = ['11101100', '00010001'];
|
||||
$padIndex = 0;
|
||||
$padBits = '';
|
||||
while (strlen($bits) < $requiredBits) {
|
||||
$padBits .= $padBytes[$padIndex % 2];
|
||||
$bits .= $padBytes[$padIndex % 2];
|
||||
$padIndex++;
|
||||
}
|
||||
echo "Pad codewords added: {$padIndex}\n";
|
||||
echo "Pad bits: {$padBits}\n\n";
|
||||
|
||||
// 7. Convert to codewords
|
||||
$codewords = [];
|
||||
for ($i = 0; $i < strlen($bits); $i += 8) {
|
||||
$byte = substr($bits, $i, 8);
|
||||
$codewords[] = bindec($byte);
|
||||
}
|
||||
|
||||
echo "Generated codewords:\n";
|
||||
echo implode(', ', $codewords) . "\n\n";
|
||||
|
||||
// Expected codewords
|
||||
$expected = [64, 180, 132, 84, 196, 196, 242, 5, 116, 245, 174, 59, 64, 109, 236, 233];
|
||||
echo "Expected codewords:\n";
|
||||
echo implode(', ', $expected) . "\n\n";
|
||||
|
||||
// Compare bit strings
|
||||
$expectedBits = '';
|
||||
foreach ($expected as $codeword) {
|
||||
$expectedBits .= str_pad(decbin($codeword), 8, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
echo "=== Bit String Comparison ===\n";
|
||||
echo "Our bit string length: " . strlen($bits) . "\n";
|
||||
echo "Expected bit string length: " . strlen($expectedBits) . "\n\n";
|
||||
|
||||
// Find first difference
|
||||
$minLength = min(strlen($bits), strlen($expectedBits));
|
||||
for ($i = 0; $i < $minLength; $i++) {
|
||||
if ($bits[$i] !== $expectedBits[$i]) {
|
||||
$codewordIndex = intval($i / 8);
|
||||
$bitInCodeword = $i % 8;
|
||||
echo "❌ First difference at bit {$i} (codeword {$codewordIndex}, bit {$bitInCodeword})\n";
|
||||
echo " Our bit: {$bits[$i]}\n";
|
||||
echo " Expected: {$expectedBits[$i]}\n";
|
||||
echo " Codeword {$codewordIndex}: ours={$codewords[$codewordIndex]}, expected={$expected[$codewordIndex]}\n";
|
||||
echo " Our bits: " . substr($bits, $codewordIndex * 8, 8) . "\n";
|
||||
echo " Expected: " . substr($expectedBits, $codewordIndex * 8, 8) . "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Show codeword 10 in detail
|
||||
echo "\n=== Codeword 10 Detail ===\n";
|
||||
$codeword10Offset = 10 * 8;
|
||||
echo "Our bits (80-87): " . substr($bits, $codeword10Offset, 8) . " = " . $codewords[10] . "\n";
|
||||
echo "Expected bits: " . substr($expectedBits, $codeword10Offset, 8) . " = " . $expected[10] . "\n";
|
||||
|
||||
// Show surrounding context
|
||||
echo "\nContext (bits 72-95, codewords 9-11):\n";
|
||||
echo "Our: " . substr($bits, 72, 24) . "\n";
|
||||
echo "Expected: " . substr($expectedBits, 72, 24) . "\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user