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.
105 lines
3.2 KiB
PHP
105 lines
3.2 KiB
PHP
<?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 "=== Format Information Decode Test ===\n\n";
|
|
|
|
$config = new QrCodeConfig(
|
|
version: QrCodeVersion::fromNumber(1),
|
|
errorCorrectionLevel: ErrorCorrectionLevel::M,
|
|
encodingMode: EncodingMode::BYTE
|
|
);
|
|
|
|
$matrix = QrCodeGenerator::generate('HELLO WORLD', $config);
|
|
|
|
// Read format information
|
|
$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';
|
|
}
|
|
|
|
echo "Format Info (Horizontal): {$formatH}\n";
|
|
|
|
// XOR mask: 101010000010010
|
|
$xorMask = '101010000010010';
|
|
echo "XOR Mask: {$xorMask}\n";
|
|
|
|
$unmasked = '';
|
|
for ($i = 0; $i < 15; $i++) {
|
|
$unmasked .= (int)$formatH[$i] ^ (int)$xorMask[$i];
|
|
}
|
|
echo "Unmasked: {$unmasked}\n\n";
|
|
|
|
// Decode format information
|
|
// Format: [EC Level (2 bits)] [Mask Pattern (3 bits)] [Error Correction (10 bits)]
|
|
$ecBits = substr($unmasked, 0, 2);
|
|
$maskBits = substr($unmasked, 2, 3); // Only 3 bits for mask pattern!
|
|
$errorCorrectionBits = substr($unmasked, 5, 10); // BCH error correction
|
|
|
|
echo "EC Level (bits 0-1): {$ecBits}\n";
|
|
echo "Mask Pattern (bits 2-4): {$maskBits}\n";
|
|
echo "Error Correction: {$errorCorrectionBits}\n\n";
|
|
|
|
$ecLevel = match($ecBits) {
|
|
'01' => 'L',
|
|
'00' => 'M',
|
|
'11' => 'Q',
|
|
'10' => 'H',
|
|
default => 'UNKNOWN'
|
|
};
|
|
|
|
$maskPattern = bindec($maskBits);
|
|
|
|
echo "Decoded:\n";
|
|
echo " EC Level: {$ecLevel}\n";
|
|
echo " Mask Pattern: {$maskPattern}\n\n";
|
|
|
|
if ($maskPattern > 7) {
|
|
echo "❌ ERROR: Mask Pattern {$maskPattern} is invalid! (should be 0-7)\n";
|
|
echo "This means the format information is corrupted or incorrect!\n\n";
|
|
|
|
// Check what mask pattern was actually used
|
|
echo "Checking what mask pattern was actually applied...\n";
|
|
|
|
// We can check by looking at the data area and trying to unmask
|
|
// But first, let's check if the format info itself is correct
|
|
|
|
// Expected format info for Level M, Mask 0-7
|
|
$expectedFormats = [
|
|
'101010000010010', // M, Mask 0
|
|
'101000100100101', // M, Mask 1
|
|
'101111001111100', // M, Mask 2
|
|
'101101101001011', // M, Mask 3
|
|
'100010111111001', // M, Mask 4
|
|
'100000011001110', // M, Mask 5
|
|
'100111110010111', // M, Mask 6
|
|
'100101010100000', // M, Mask 7
|
|
];
|
|
|
|
echo "\nExpected format info for Level M:\n";
|
|
foreach ($expectedFormats as $mask => $expected) {
|
|
$masked = '';
|
|
for ($i = 0; $i < 15; $i++) {
|
|
$masked .= (int)$expected[$i] ^ (int)$xorMask[$i];
|
|
}
|
|
echo " Mask {$mask}: {$masked} (unmasked: {$expected})\n";
|
|
|
|
if ($masked === $formatH) {
|
|
echo " ✅ This matches our format info!\n";
|
|
echo " So mask pattern {$mask} was used.\n";
|
|
}
|
|
}
|
|
} else {
|
|
echo "✅ Mask Pattern is valid\n";
|
|
}
|
|
|