fix(wireguard): check every line of generated client configs

The WireGuard and AmneziaWG .conf builders (subscription service, clients
page, inbound modal and subscription page) checked only a few of the values
they write. Each builder now assembles the file line by line and renders
nothing when a line holds a control character, so every value is covered
whatever stored it. A decoded vpn:// payload is refused when it carries a
wg-quick hook directive, which no panel builder writes, and the subscription
page hides a config block that rendered nothing.

The inbound form now validates a WireGuard/AmneziaWG client's allowedIPs on
create and on update, including the stored clients a protocol switch keeps,
as the client endpoints already did.
This commit is contained in:
MHSanaei
2026-10-24 01:10:09 +02:00
parent 57fd61790c
commit 0faad4f4f3
12 changed files with 285 additions and 222 deletions
+7
View File
@@ -1409,6 +1409,9 @@ func (s *InboundService) AddInbound(inbound *model.Inbound) (*model.Inbound, boo
if client.PublicKey == "" {
return inbound, false, common.NewError("wireguard client requires a key")
}
if _, err := normalizeWireguardAllowedIPs(client.AllowedIPs); err != nil {
return inbound, false, err
}
case "mtproto":
if client.Secret == "" {
return inbound, false, common.NewError("mtproto client requires a secret")
@@ -1923,6 +1926,10 @@ func (s *InboundService) validateUpdatedInboundClients(inbound *model.Inbound) e
if client.Password == "" {
return common.NewError("empty client ID")
}
case model.WireGuard, model.AmneziaWG:
if _, err := normalizeWireguardAllowedIPs(client.AllowedIPs); err != nil {
return err
}
case model.TUIC:
if client.ID == "" {
return common.NewError("empty client ID")