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:
110
tests/debug/test-mask-application-verification.php
Normal file
110
tests/debug/test-mask-application-verification.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
use App\Framework\QrCode\QrCodeGenerator;
|
||||
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 "=== Mask Application Verification ===\n\n";
|
||||
|
||||
// Test with simple data
|
||||
$testData = 'HELLO WORLD';
|
||||
$config = new QrCodeConfig(
|
||||
version: QrCodeVersion::fromNumber(1),
|
||||
errorCorrectionLevel: ErrorCorrectionLevel::M,
|
||||
encodingMode: EncodingMode::BYTE
|
||||
);
|
||||
|
||||
$matrix = QrCodeGenerator::generate($testData, $config);
|
||||
$size = $matrix->getSize();
|
||||
|
||||
// Get mask pattern from format info
|
||||
$formatCols = [0, 1, 2, 3, 4, 5, 7, 8, $size - 1, $size - 2, $size - 3, $size - 4, $size - 5, $size - 6, $size - 7];
|
||||
$formatH = '';
|
||||
foreach ($formatCols as $col) {
|
||||
$formatH .= $matrix->getModuleAt(8, $col)->isDark() ? '1' : '0';
|
||||
}
|
||||
|
||||
$xorMask = "101010000010010";
|
||||
$unmasked = '';
|
||||
for ($i = 0; $i < 15; $i++) {
|
||||
$unmasked .= (int)$formatH[$i] ^ (int)$xorMask[$i];
|
||||
}
|
||||
|
||||
$maskBits = substr($unmasked, 2, 3);
|
||||
$maskPattern = bindec($maskBits);
|
||||
|
||||
echo "Detected mask pattern: {$maskPattern}\n\n";
|
||||
|
||||
// Test mask application by checking if unmasking gives correct data
|
||||
use App\Framework\QrCode\Masking\MaskPattern as MaskPatternEnum;
|
||||
|
||||
$mask = match($maskPattern) {
|
||||
0 => MaskPatternEnum::PATTERN_0,
|
||||
1 => MaskPatternEnum::PATTERN_1,
|
||||
2 => MaskPatternEnum::PATTERN_2,
|
||||
3 => MaskPatternEnum::PATTERN_3,
|
||||
4 => MaskPatternEnum::PATTERN_4,
|
||||
5 => MaskPatternEnum::PATTERN_5,
|
||||
6 => MaskPatternEnum::PATTERN_6,
|
||||
7 => MaskPatternEnum::PATTERN_7,
|
||||
};
|
||||
|
||||
// Read first data bit position (20,20)
|
||||
$testRow = 20;
|
||||
$testCol = 20;
|
||||
|
||||
// Check if this should be masked
|
||||
$shouldInvert = $mask->shouldInvert($testRow, $testCol);
|
||||
echo "Testing position ({$testRow}, {$testCol}):\n";
|
||||
echo " Mask pattern {$maskPattern} should invert: " . ($shouldInvert ? 'YES' : 'NO') . "\n";
|
||||
|
||||
// Read masked value
|
||||
$maskedValue = $matrix->getModuleAt($testRow, $testCol)->isDark() ? 1 : 0;
|
||||
echo " Masked value in matrix: {$maskedValue}\n";
|
||||
|
||||
// Unmask
|
||||
$unmaskedValue = $shouldInvert ? (1 - $maskedValue) : $maskedValue;
|
||||
echo " Unmasked value: {$unmaskedValue}\n\n";
|
||||
|
||||
// Now test with the actual URL
|
||||
echo "=== Testing with URL ===\n";
|
||||
$url = 'https://localhost/';
|
||||
$urlConfig = QrCodeConfig::autoSize($url, ErrorCorrectionLevel::M);
|
||||
$urlMatrix = QrCodeGenerator::generate($url, $urlConfig);
|
||||
|
||||
$urlSize = $urlMatrix->getSize();
|
||||
|
||||
// Get mask for URL
|
||||
$urlFormatCols = [0, 1, 2, 3, 4, 5, 7, 8, $urlSize - 1, $urlSize - 2, $urlSize - 3, $urlSize - 4, $urlSize - 5, $urlSize - 6, $urlSize - 7];
|
||||
$urlFormatH = '';
|
||||
foreach ($urlFormatCols as $col) {
|
||||
$urlFormatH .= $urlMatrix->getModuleAt(8, $col)->isDark() ? '1' : '0';
|
||||
}
|
||||
|
||||
$urlUnmasked = '';
|
||||
for ($i = 0; $i < 15; $i++) {
|
||||
$urlUnmasked .= (int)$urlFormatH[$i] ^ (int)$xorMask[$i];
|
||||
}
|
||||
|
||||
$urlMaskBits = substr($urlUnmasked, 2, 3);
|
||||
$urlMaskPattern = bindec($urlMaskBits);
|
||||
|
||||
echo "URL mask pattern: {$urlMaskPattern}\n";
|
||||
echo "URL matrix size: {$urlSize}x{$urlSize}\n\n";
|
||||
|
||||
// Generate SVG for URL
|
||||
$renderer = new \App\Framework\QrCode\QrCodeRenderer();
|
||||
$urlSvg = $renderer->renderSvg($urlMatrix);
|
||||
$urlSvgFile = __DIR__ . '/url-qrcode-test.svg';
|
||||
file_put_contents($urlSvgFile, $urlSvg);
|
||||
echo "URL QR Code saved to: {$urlSvgFile}\n\n";
|
||||
|
||||
echo "✅ QR Code generation complete. Please test with a scanner.\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user