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:
parent
f0ac51ddd1
commit
dcc000c55d
@ -722,6 +722,13 @@ generate_qr() {
|
|||||||
# Get DNS servers
|
# Get DNS servers
|
||||||
local dns=$(uci -q get network.$iface.dns || echo "1.1.1.1, 1.0.0.1")
|
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
|
# Build configuration
|
||||||
local config="[Interface]
|
local config="[Interface]
|
||||||
PrivateKey = ${peer_privkey}
|
PrivateKey = ${peer_privkey}
|
||||||
@ -730,7 +737,7 @@ DNS = ${dns}
|
|||||||
|
|
||||||
[Peer]
|
[Peer]
|
||||||
PublicKey = ${server_pubkey}
|
PublicKey = ${server_pubkey}
|
||||||
Endpoint = ${server_endpoint}:${server_port}
|
Endpoint = ${full_endpoint}
|
||||||
AllowedIPs = 0.0.0.0/0, ::/0
|
AllowedIPs = 0.0.0.0/0, ::/0
|
||||||
PersistentKeepalive = 25"
|
PersistentKeepalive = 25"
|
||||||
|
|
||||||
@ -739,10 +746,10 @@ PersistentKeepalive = 25"
|
|||||||
PresharedKey = ${psk}"
|
PresharedKey = ${psk}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate QR code PNG and convert to base64
|
# Generate QR code as SVG (PNG disabled in OpenWrt qrencode) and convert to base64
|
||||||
local qr_base64=$(echo "$config" | qrencode -t PNG -o - | base64 -w 0)
|
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_add_string "config" "$config"
|
||||||
|
|
||||||
json_dump
|
json_dump
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user