fix(clients): collapse repeated inbound ids before fanning a client out

Create, BulkCreate, Attach and BulkAttach built one marshalled copy of
the client per entry of the request's inboundIds and held all of them
until the fan-out returned, with repeated ids never collapsed. An id
costs two bytes of request body, so a large client named on the same
inbound a few thousand times needed gigabytes and the panel died.

Every fan-out entry point now collapses the id list first, keeping the
order of first occurrence so credentials are still minted on the first
inbound.
This commit is contained in:
MHSanaei
2026-11-01 08:44:16 +01:00
parent f8ceede46f
commit 0972ac31eb
4 changed files with 59 additions and 2 deletions
+3
View File
@@ -191,6 +191,8 @@ func (s *ClientService) Create(inboundSvc *InboundService, payload *ClientCreate
if payload == nil {
return false, common.NewError("empty payload")
}
// A repeated id adds nothing but another copy of the client held through the fan-out.
payload.InboundIds = uniqueInts(payload.InboundIds)
client := payload.Client
if strings.TrimSpace(client.Email) == "" {
return false, common.NewError("client email is required")
@@ -1138,6 +1140,7 @@ func addressesFitAmneziaWGInbound(addrs []string, ib *model.Inbound) bool {
// Attach applies the client to every requested inbound: one failing inbound no
// longer aborts the others, so the error can name several and needRestart holds.
func (s *ClientService) Attach(inboundSvc *InboundService, id int, inboundIds []int) (bool, error) {
inboundIds = uniqueInts(inboundIds)
existing, err := s.GetByID(id)
if err != nil {
return false, err