Merge branch 'master' into client-default-settings

This commit is contained in:
Arminas 2023-05-19 01:30:17 +03:00 committed by GitHub
commit 97e7ead5fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 81 additions and 82 deletions
handler

View file

@ -5,13 +5,13 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"io/fs"
"net/http"
"os"
"sort"
"strings"
"time"
rice "github.com/GeertJohan/go.rice"
"github.com/gorilla/sessions"
"github.com/labstack/echo-contrib/session"
"github.com/labstack/echo/v4"
@ -994,7 +994,7 @@ func SuggestIPAllocation(db store.IStore) echo.HandlerFunc {
}
// ApplyServerConfig handler to write config file and restart Wireguard server
func ApplyServerConfig(db store.IStore, tmplBox *rice.Box) echo.HandlerFunc {
func ApplyServerConfig(db store.IStore, tmplDir fs.FS) echo.HandlerFunc {
return func(c echo.Context) error {
server, err := db.GetServer()
@ -1022,14 +1022,14 @@ func ApplyServerConfig(db store.IStore, tmplBox *rice.Box) echo.HandlerFunc {
}
// Write config file
err = util.WriteWireGuardServerConfig(tmplBox, server, clients, users, settings)
err = util.WriteWireGuardServerConfig(tmplDir, server, clients, users, settings)
if err != nil {
log.Error("Cannot apply server config: ", err)
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{
false, fmt.Sprintf("Cannot apply server config: %v", err),
})
}
err = util.UpdateHashes(db)
if err != nil {
log.Error("Cannot update hashes: ", err)
@ -1062,4 +1062,3 @@ func AboutPage() echo.HandlerFunc {
})
}
}