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.
90 lines
3.2 KiB
PHP
90 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\QrCode\ErrorCorrection\ReedSolomonEncoder;
|
|
|
|
echo "=== RS EC Codewords Reference Test ===\n\n";
|
|
|
|
// Known reference data codewords for "HELLO WORLD" Version 1, Level M
|
|
// From QR code specification examples
|
|
$referenceDataCodewords = [64, 180, 132, 84, 196, 196, 242, 5, 116, 245, 174, 59, 64, 109, 236, 233];
|
|
|
|
// But wait - our encoding produces different codewords starting at index 10
|
|
// Let's check what our actual encoding produces
|
|
$ourDataCodewords = [64, 180, 132, 84, 196, 196, 242, 5, 116, 245, 36, 196, 64, 236, 17, 236];
|
|
|
|
echo "Reference data codewords (from spec):\n";
|
|
echo implode(', ', $referenceDataCodewords) . "\n\n";
|
|
|
|
echo "Our data codewords:\n";
|
|
echo implode(', ', $ourDataCodewords) . "\n\n";
|
|
|
|
// Compare
|
|
echo "Differences:\n";
|
|
for ($i = 0; $i < min(count($referenceDataCodewords), count($ourDataCodewords)); $i++) {
|
|
if ($referenceDataCodewords[$i] !== $ourDataCodewords[$i]) {
|
|
echo " Codeword {$i}: reference={$referenceDataCodewords[$i]}, ours={$ourDataCodewords[$i]}\n";
|
|
}
|
|
}
|
|
echo "\n";
|
|
|
|
// Now test RS encoding with reference data codewords
|
|
echo "=== Testing RS with Reference Data Codewords ===\n";
|
|
$rs = new ReedSolomonEncoder();
|
|
$ecCodewords = 10;
|
|
|
|
$referenceEC = $rs->encode($referenceDataCodewords, $ecCodewords);
|
|
echo "EC codewords (from reference data): " . implode(', ', $referenceEC) . "\n\n";
|
|
|
|
// Test RS encoding with our data codewords
|
|
$ourEC = $rs->encode($ourDataCodewords, $ecCodewords);
|
|
echo "EC codewords (from our data): " . implode(', ', $ourEC) . "\n\n";
|
|
|
|
// Verify both with decoder
|
|
require_once __DIR__ . '/test-reed-solomon-decoder.php';
|
|
$decoder = new SimpleRSDecoder();
|
|
|
|
// Test reference
|
|
$fullReference = array_merge($referenceDataCodewords, $referenceEC);
|
|
$syndromesRef = $decoder->calculateSyndromes($fullReference, $ecCodewords);
|
|
echo "Reference syndromes: " . implode(', ', $syndromesRef) . "\n";
|
|
$allZeroRef = true;
|
|
foreach ($syndromesRef as $s) {
|
|
if ($s !== 0) {
|
|
$allZeroRef = false;
|
|
break;
|
|
}
|
|
}
|
|
echo ($allZeroRef ? "✅" : "❌") . " Reference codewords are " . ($allZeroRef ? "valid" : "invalid") . "\n\n";
|
|
|
|
// Test ours
|
|
$fullOurs = array_merge($ourDataCodewords, $ourEC);
|
|
$syndromesOurs = $decoder->calculateSyndromes($fullOurs, $ecCodewords);
|
|
echo "Our syndromes: " . implode(', ', $syndromesOurs) . "\n";
|
|
$allZeroOurs = true;
|
|
foreach ($syndromesOurs as $s) {
|
|
if ($s !== 0) {
|
|
$allZeroOurs = false;
|
|
break;
|
|
}
|
|
}
|
|
echo ($allZeroOurs ? "✅" : "❌") . " Our codewords are " . ($allZeroOurs ? "valid" : "invalid") . "\n\n";
|
|
|
|
// Now try to find expected EC codewords from known sources
|
|
echo "=== Finding Expected EC Codewords ===\n";
|
|
echo "If we can find a working QR code generator or reference implementation,\n";
|
|
echo "we can compare our EC codewords with the expected ones.\n\n";
|
|
|
|
// Known EC codewords from QR code specification for "HELLO WORLD"
|
|
// These are from the ISO/IEC 18004 specification example
|
|
// But we need to verify if our data codewords match first
|
|
|
|
// The issue is: our data codewords don't match the reference!
|
|
// This means the problem is in the encoding step, not Reed-Solomon.
|
|
// But let's still test if RS works correctly with correct input.
|
|
|
|
|