fix(amneziawg): validate peer subnets before enabling kernel mode (#6965)

A kernel-mode AmneziaWG inbound routes and masquerades only its interface subnet, so peers whose AllowedIPs lay outside it (a restored backup, a changed subnet) handshook but got no internet. Enabling kernel mode, saving an active kernel inbound, and adding, enabling or re-addressing a client now refuse out-of-subnet peers with the offending client named. Legacy stray peers still start and can still be edited or disabled.
This commit is contained in:
Aleksey
2026-11-03 17:52:26 +03:00
committed by GitHub
parent e093854f5b
commit fee7b1621d
9 changed files with 286 additions and 9 deletions
+2 -2
View File
@@ -293,7 +293,7 @@ func (s *ClientService) Create(inboundSvc *InboundService, payload *ClientCreate
// comment on the Attach path.
clientForInbound.AllowedIPs = nil
}
if err := validateAmneziaWGClientWrite(inbound, []model.Client{clientForInbound}); err != nil {
if err := validateAmneziaWGClientWrite(inbound, []model.Client{clientForInbound}, ""); err != nil {
return false, fmt.Errorf("inbound %d: %w", ibId, err)
}
settingsPayload, mErr := json.Marshal(map[string][]model.Client{"clients": {clientWithInboundFlow(clientForInbound, inbound)}})
@@ -846,7 +846,7 @@ func (s *ClientService) Update(inboundSvc *InboundService, id int, updated model
// instead.
clientForInbound.AllowedIPs = nil
}
if err := validateAmneziaWGClientWrite(inbound, []model.Client{clientForInbound}); err != nil {
if err := validateAmneziaWGClientWrite(inbound, []model.Client{clientForInbound}, existing.Email); err != nil {
return false, fmt.Errorf("inbound %d: %w", ibId, err)
}
settingsPayload, mErr := json.Marshal(map[string][]model.Client{"clients": {clientWithInboundFlow(clientForInbound, inbound)}})