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:
221
tests/debug/test-qrcode-scannability.php
Normal file
221
tests/debug/test-qrcode-scannability.php
Normal file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
use App\Framework\QrCode\QrCodeGenerator;
|
||||
use App\Framework\QrCode\QrCodeRenderer;
|
||||
use App\Framework\QrCode\ValueObjects\ErrorCorrectionLevel;
|
||||
use App\Framework\QrCode\ValueObjects\QrCodeConfig;
|
||||
use App\Framework\QrCode\ValueObjects\QrCodeVersion;
|
||||
use App\Framework\QrCode\ValueObjects\EncodingMode;
|
||||
|
||||
echo "=== QR Code Scannability Test ===\n\n";
|
||||
|
||||
// Generate a simple QR code first
|
||||
$testData = 'HELLO WORLD';
|
||||
$config = new QrCodeConfig(
|
||||
version: QrCodeVersion::fromNumber(1),
|
||||
errorCorrectionLevel: ErrorCorrectionLevel::M,
|
||||
encodingMode: EncodingMode::BYTE
|
||||
);
|
||||
|
||||
echo "Generating QR code for: '{$testData}'\n\n";
|
||||
|
||||
$matrix = QrCodeGenerator::generate($testData, $config);
|
||||
$size = $matrix->getSize();
|
||||
|
||||
echo "Matrix size: {$size}x{$size}\n\n";
|
||||
|
||||
// Detailed validation
|
||||
echo "=== Detailed Validation ===\n\n";
|
||||
|
||||
// 1. Format Information
|
||||
echo "1. Format Information:\n";
|
||||
$formatCols = [0, 1, 2, 3, 4, 5, 7, 8, 20, 19, 18, 17, 16, 15, 14];
|
||||
$formatH = '';
|
||||
foreach ($formatCols as $col) {
|
||||
$formatH .= $matrix->getModuleAt(8, $col)->isDark() ? '1' : '0';
|
||||
}
|
||||
|
||||
$formatRows = [20, 19, 18, 17, 16, 15, 14, 8, 7, 5, 4, 3, 2, 1, 0];
|
||||
$formatV = '';
|
||||
foreach ($formatRows as $row) {
|
||||
$formatV .= $matrix->getModuleAt($row, 8)->isDark() ? '1' : '0';
|
||||
}
|
||||
|
||||
echo " Horizontal: {$formatH}\n";
|
||||
echo " Vertical: {$formatV}\n";
|
||||
|
||||
if ($formatH === $formatV) {
|
||||
echo " ✅ Match\n";
|
||||
|
||||
// Decode
|
||||
$xorMask = "101010000010010";
|
||||
$unmasked = '';
|
||||
for ($i = 0; $i < 15; $i++) {
|
||||
$unmasked .= (int)$formatH[$i] ^ (int)$xorMask[$i];
|
||||
}
|
||||
|
||||
$ecBits = substr($unmasked, 0, 2);
|
||||
$maskBits = substr($unmasked, 2, 5);
|
||||
$ecLevel = match($ecBits) {
|
||||
'01' => 'L', '00' => 'M', '11' => 'Q', '10' => 'H',
|
||||
default => 'UNKNOWN'
|
||||
};
|
||||
$maskPattern = bindec($maskBits);
|
||||
|
||||
echo " EC Level: {$ecLevel}\n";
|
||||
echo " Mask Pattern: {$maskPattern}\n";
|
||||
} else {
|
||||
echo " ❌ MISMATCH - This will cause scanning to fail!\n";
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
|
||||
// 2. Finder Patterns
|
||||
echo "2. Finder Patterns:\n";
|
||||
$finderOk = true;
|
||||
$finderPatterns = [
|
||||
['name' => 'Top-Left', 'row' => 0, 'col' => 0],
|
||||
['name' => 'Top-Right', 'row' => 0, 'col' => 14],
|
||||
['name' => 'Bottom-Left', 'row' => 14, 'col' => 0],
|
||||
];
|
||||
|
||||
$expectedFinder = [
|
||||
[1, 1, 1, 1, 1, 1, 1],
|
||||
[1, 0, 0, 0, 0, 0, 1],
|
||||
[1, 0, 1, 1, 1, 0, 1],
|
||||
[1, 0, 1, 1, 1, 0, 1],
|
||||
[1, 0, 1, 1, 1, 0, 1],
|
||||
[1, 0, 0, 0, 0, 0, 1],
|
||||
[1, 1, 1, 1, 1, 1, 1],
|
||||
];
|
||||
|
||||
foreach ($finderPatterns as $finder) {
|
||||
$errors = 0;
|
||||
for ($r = 0; $r < 7; $r++) {
|
||||
for ($c = 0; $c < 7; $c++) {
|
||||
$row = $finder['row'] + $r;
|
||||
$col = $finder['col'] + $c;
|
||||
$isDark = $matrix->getModuleAt($row, $col)->isDark();
|
||||
$expectedDark = $expectedFinder[$r][$c] === 1;
|
||||
|
||||
if ($isDark !== $expectedDark) {
|
||||
$errors++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($errors === 0) {
|
||||
echo " ✅ {$finder['name']}\n";
|
||||
} else {
|
||||
echo " ❌ {$finder['name']} ({$errors} errors)\n";
|
||||
$finderOk = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$finderOk) {
|
||||
echo " ⚠️ Finder pattern errors will prevent scanning!\n";
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
|
||||
// 3. Timing Patterns
|
||||
echo "3. Timing Patterns:\n";
|
||||
$timingOk = true;
|
||||
|
||||
// Horizontal (row 6, cols 8-12)
|
||||
$timingH = '';
|
||||
for ($col = 8; $col <= 12; $col++) {
|
||||
$isDark = $matrix->getModuleAt(6, $col)->isDark();
|
||||
$expectedDark = (($col - 8) % 2) === 0;
|
||||
$timingH .= $isDark ? '1' : '0';
|
||||
if ($isDark !== $expectedDark) {
|
||||
$timingOk = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Vertical (col 6, rows 8-12)
|
||||
$timingV = '';
|
||||
for ($row = 8; $row <= 12; $row++) {
|
||||
$isDark = $matrix->getModuleAt($row, 6)->isDark();
|
||||
$expectedDark = (($row - 8) % 2) === 0;
|
||||
$timingV .= $isDark ? '1' : '0';
|
||||
if ($isDark !== $expectedDark) {
|
||||
$timingOk = false;
|
||||
}
|
||||
}
|
||||
|
||||
echo " Horizontal: {$timingH}\n";
|
||||
echo " Vertical: {$timingV}\n";
|
||||
|
||||
if ($timingOk) {
|
||||
echo " ✅ Correct\n";
|
||||
} else {
|
||||
echo " ❌ Incorrect\n";
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
|
||||
// 4. Dark Module
|
||||
echo "4. Dark Module:\n";
|
||||
$darkModuleRow = 4 * 1 + 9; // Version 1
|
||||
$darkModuleCol = 8;
|
||||
$isDark = $matrix->getModuleAt($darkModuleRow, $darkModuleCol)->isDark();
|
||||
|
||||
if ($isDark) {
|
||||
echo " ✅ Present at ({$darkModuleRow}, {$darkModuleCol})\n";
|
||||
} else {
|
||||
echo " ❌ Missing at ({$darkModuleRow}, {$darkModuleCol})\n";
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
|
||||
// 5. Generate optimized SVG
|
||||
echo "=== Generating Optimized SVG ===\n";
|
||||
$renderer = new QrCodeRenderer();
|
||||
$svg = $renderer->renderSvg($matrix);
|
||||
|
||||
// Save
|
||||
$outputDir = __DIR__ . '/test-qrcodes';
|
||||
if (!is_dir($outputDir)) {
|
||||
mkdir($outputDir, 0755, true);
|
||||
}
|
||||
|
||||
$outputPath = $outputDir . '/scannable-test.svg';
|
||||
file_put_contents($outputPath, $svg);
|
||||
|
||||
echo "✅ Saved: {$outputPath}\n";
|
||||
echo " Size: " . strlen($svg) . " bytes\n";
|
||||
|
||||
// Check SVG structure
|
||||
$rectCount = substr_count($svg, '<rect');
|
||||
echo " Rectangles: {$rectCount}\n";
|
||||
|
||||
if (strpos($svg, 'fill="white"') !== false && strpos($svg, 'fill="black"') !== false) {
|
||||
echo " ✅ Contains white and black fills\n";
|
||||
} else {
|
||||
echo " ⚠️ Missing expected colors\n";
|
||||
}
|
||||
|
||||
echo "\n";
|
||||
|
||||
// Summary
|
||||
echo "=== Summary ===\n";
|
||||
$allOk = $formatH === $formatV && $finderOk && $timingOk && $isDark;
|
||||
|
||||
if ($allOk) {
|
||||
echo "✅ All structural checks passed\n";
|
||||
echo "The QR code should be scannable.\n";
|
||||
echo "\nIf it still doesn't scan, possible issues:\n";
|
||||
echo "1. SVG rendering might have issues (try PNG instead)\n";
|
||||
echo "2. Quiet zone might be too small\n";
|
||||
echo "3. Module size might be too small for scanner\n";
|
||||
echo "4. Data encoding might have issues\n";
|
||||
} else {
|
||||
echo "❌ Some structural issues found\n";
|
||||
echo "Fix these issues first before testing scanning.\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user