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.
88 lines
3.2 KiB
PHP
88 lines
3.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
|
|
|
use App\Framework\QrCode\ErrorCorrection\ReedSolomonEncoder;
|
|
|
|
echo "=== Reed-Solomon Decode Test ===\n\n";
|
|
|
|
// Test: Create a simple Reed-Solomon code and verify it can correct errors
|
|
// For RS(26, 16), we can correct up to 5 errors
|
|
|
|
$dataCodewords = [64, 180, 132, 84, 196, 196, 242, 5, 116, 245, 36, 196, 64, 236, 17, 236];
|
|
echo "Data codewords: " . implode(', ', $dataCodewords) . "\n\n";
|
|
|
|
// Encode
|
|
$reedSolomon = new ReedSolomonEncoder();
|
|
$ecCodewords = $reedSolomon->encode($dataCodewords, 10);
|
|
|
|
echo "EC codewords: " . implode(', ', $ecCodewords) . "\n\n";
|
|
|
|
// Create full codeword sequence
|
|
$allCodewords = array_merge($dataCodewords, $ecCodewords);
|
|
echo "Full codeword sequence (26): " . implode(', ', $allCodewords) . "\n\n";
|
|
|
|
// Verify: For Reed-Solomon, if we evaluate the message polynomial at the roots of the generator,
|
|
// we should get zero. This is a basic sanity check.
|
|
|
|
echo "=== Reed-Solomon Verification ===\n";
|
|
echo "Note: Full verification requires evaluating the polynomial at generator roots.\n";
|
|
echo "For now, we verify the structure:\n";
|
|
echo " - Generator polynomial: degree 10\n";
|
|
echo " - Data codewords: 16\n";
|
|
echo " - EC codewords: 10\n";
|
|
echo " - Total: 26 codewords\n\n";
|
|
|
|
// Test with a known working QR code library result
|
|
// From qrcode.js library, for "HELLO WORLD" V1 M:
|
|
// Expected EC codewords might be different
|
|
|
|
echo "=== Comparison with Known Values ===\n";
|
|
echo "Note: Different QR code implementations may use different mask patterns,\n";
|
|
echo "which affects which EC codewords are generated.\n\n";
|
|
|
|
// The key test: Can we decode our own encoded data?
|
|
// We need to verify that the EC codewords are correct by checking if
|
|
// they can be used to reconstruct the original data
|
|
|
|
echo "=== Reed-Solomon Structure Check ===\n";
|
|
echo "For RS(26, 16) with generator polynomial g(x):\n";
|
|
echo " - Message polynomial: m(x) = data + zeros\n";
|
|
echo " - Encoded: c(x) = m(x) * x^10 + (m(x) * x^10) mod g(x)\n";
|
|
echo " - EC codewords = remainder of (m(x) * x^10) / g(x)\n\n";
|
|
|
|
// Verify generator polynomial
|
|
$reflection = new ReflectionClass($reedSolomon);
|
|
$getGeneratorMethod = $reflection->getMethod('getGeneratorPolynomial');
|
|
$getGeneratorMethod->setAccessible(true);
|
|
$generator = $getGeneratorMethod->invoke($reedSolomon, 10);
|
|
|
|
echo "Generator polynomial coefficients: " . implode(', ', $generator) . "\n";
|
|
echo "Degree: " . (count($generator) - 1) . " (expected: 10)\n\n";
|
|
|
|
// Check if EC codewords match expected pattern
|
|
// For RS codes, the EC codewords should have certain properties
|
|
echo "EC codewords check:\n";
|
|
echo " - All EC codewords are bytes (0-255): ";
|
|
$allValid = true;
|
|
foreach ($ecCodewords as $ec) {
|
|
if ($ec < 0 || $ec > 255) {
|
|
$allValid = false;
|
|
break;
|
|
}
|
|
}
|
|
echo ($allValid ? "✅" : "❌") . "\n";
|
|
|
|
echo " - EC codeword count: " . count($ecCodewords) . " (expected: 10) ";
|
|
echo (count($ecCodewords) === 10 ? "✅" : "❌") . "\n\n";
|
|
|
|
echo "If the QR code doesn't scan, the issue might be:\n";
|
|
echo "1. EC codewords are incorrect (most likely)\n";
|
|
echo "2. Data codewords are incorrect (but we can decode them, so unlikely)\n";
|
|
echo "3. Mask pattern selection is wrong\n";
|
|
echo "4. Format information is wrong (but we verified it's correct)\n";
|
|
|
|
|