fix(wireguard-dashboard): Fix QR code generation

- Use SVG output instead of PNG (PNG disabled in OpenWrt qrencode)
- Fix endpoint port duplication when port already in endpoint string

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
CyberMind-FR 2026-02-01 08:56:25 +01:00
parent f0ac51ddd1
commit dcc000c55d

View File

@ -722,6 +722,13 @@ generate_qr() {
# Get DNS servers
local dns=$(uci -q get network.$iface.dns || echo "1.1.1.1, 1.0.0.1")
# Build endpoint - only add port if not already present
local full_endpoint="$server_endpoint"
case "$server_endpoint" in
*:*) ;; # Already has port
*) full_endpoint="${server_endpoint}:${server_port}" ;;
esac
# Build configuration
local config="[Interface]
PrivateKey = ${peer_privkey}
@ -730,7 +737,7 @@ DNS = ${dns}
[Peer]
PublicKey = ${server_pubkey}
Endpoint = ${server_endpoint}:${server_port}
Endpoint = ${full_endpoint}
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25"
@ -739,10 +746,10 @@ PersistentKeepalive = 25"
PresharedKey = ${psk}"
fi
# Generate QR code PNG and convert to base64
local qr_base64=$(echo "$config" | qrencode -t PNG -o - | base64 -w 0)
# Generate QR code as SVG (PNG disabled in OpenWrt qrencode) and convert to base64
local qr_base64=$(echo "$config" | qrencode -t SVG -o - | base64 -w 0)
json_add_string "qrcode" "data:image/png;base64,$qr_base64"
json_add_string "qrcode" "data:image/svg+xml;base64,$qr_base64"
json_add_string "config" "$config"
json_dump