From 067d0af323f226aa9af8ab600d52fb84c6e7df30 Mon Sep 17 00:00:00 2001 From: sysops Date: Sun, 12 Jul 2026 23:39:26 +0200 Subject: [PATCH] Fix "no such file" error creating clients on non-default servers SuggestIPAllocation always looked up the legacy "wg0" server regardless of which server the request was for, so any setup without a migrated wg0 (i.e. every fresh multi-server install) failed with "open db/servers/wg0.json: no such file or directory" when adding a new client. Now accepts an optional server_id query param (falling back to wg0 for the legacy bare routes), and the per-server clients page passes its own server ID. Co-Authored-By: Claude Sonnet 5 --- DEVLOG.md | 33 +++++++++++++++++++++++++++++++++ handler/routes.go | 6 +++++- templates/server_clients.html | 2 +- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/DEVLOG.md b/DEVLOG.md index a334a45..7975624 100644 --- a/DEVLOG.md +++ b/DEVLOG.md @@ -2169,3 +2169,36 @@ Keine Commits in dieser Session. - util/util.go | 63 +++++++++++++++++++++----- --- +## 2026-07-12 23:27 – 23:27 (0m) +**Beschreibung:** Claude Code Session +**Projekt:** wireguard-ui-multi + +### Commits +- 8a92958 Update DEVLOG session log + +### Geänderte Dateien +- DEVLOG.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ + +--- +## 2026-07-12 23:29 – 23:30 (1m) +**Beschreibung:** Claude Code Session +**Projekt:** wireguard-ui-multi + +### Commits +Keine Commits in dieser Session. + +### Geänderte Dateien +- DEVLOG.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ + +--- +## 2026-07-12 23:32 – 23:34 (2m) +**Beschreibung:** Claude Code Session +**Projekt:** wireguard-ui-multi + +### Commits +Keine Commits in dieser Session. + +### Geänderte Dateien +- DEVLOG.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ + +--- diff --git a/handler/routes.go b/handler/routes.go index b6e8c96..49c1135 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -1588,7 +1588,11 @@ func GetOrderedSubnetRanges() echo.HandlerFunc { // SuggestIPAllocation handler to get the list of ip address for client func SuggestIPAllocation(db store.IStore) echo.HandlerFunc { return func(c echo.Context) error { - server, err := db.GetServerByID(util.DefaultServerID) + serverID := c.QueryParam("server_id") + if serverID == "" { + serverID = util.DefaultServerID + } + server, err := db.GetServerByID(serverID) if err != nil { log.Error("Cannot fetch server config from database: ", err) return c.JSON(http.StatusBadRequest, jsonHTTPResponse{false, err.Error()}) diff --git a/templates/server_clients.html b/templates/server_clients.html index d00b405..cdf0206 100644 --- a/templates/server_clients.html +++ b/templates/server_clients.html @@ -322,7 +322,7 @@ Wireguard Clients $.ajax({ cache: false, method: 'GET', - url: `{{.basePath}}/api/suggest-client-ips?sr=${subnetRange}`, + url: `{{.basePath}}/api/suggest-client-ips?sr=${subnetRange}&server_id={{.serverID}}`, dataType: 'json', contentType: "application/json", success: function(data) {