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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
8a92958a84
commit
067d0af323
+5
-1
@@ -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()})
|
||||
|
||||
Reference in New Issue
Block a user