mirror of
https://github.com/vx3r/wg-gen-web.git
synced 2024-12-18 00:13:23 +00:00
bug issue #47
This commit is contained in:
parent
4a6cc6dea8
commit
8b4038c238
@ -6,7 +6,6 @@ import (
|
|||||||
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/auth"
|
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/auth"
|
||||||
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/core"
|
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/core"
|
||||||
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/model"
|
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/model"
|
||||||
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/template"
|
|
||||||
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/version"
|
"gitlab.127-0-0-1.fr/vx3r/wg-gen-web/version"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -74,30 +73,12 @@ func updateServer(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func configServer(c *gin.Context) {
|
func configServer(c *gin.Context) {
|
||||||
clients, err := core.ReadClients()
|
configData, err := core.ReadWgConfigFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"err": err,
|
"err": err,
|
||||||
}).Error("failed to read clients")
|
}).Error("failed to read wg config file")
|
||||||
c.AbortWithStatus(http.StatusUnprocessableEntity)
|
c.AbortWithStatus(http.StatusInternalServerError)
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
server, err := core.ReadServer()
|
|
||||||
if err != nil {
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"err": err,
|
|
||||||
}).Error("failed to read server")
|
|
||||||
c.AbortWithStatus(http.StatusUnprocessableEntity)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
configData, err := template.DumpServerWg(clients, server)
|
|
||||||
if err != nil {
|
|
||||||
log.WithFields(log.Fields{
|
|
||||||
"err": err,
|
|
||||||
}).Error("failed to dump wg config")
|
|
||||||
c.AbortWithStatus(http.StatusUnprocessableEntity)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,3 +168,8 @@ func GetAllReservedIps() ([]string, error) {
|
|||||||
|
|
||||||
return reserverIps, nil
|
return reserverIps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadWgConfigFile return content of wireguard config file
|
||||||
|
func ReadWgConfigFile() ([]byte, error) {
|
||||||
|
return util.ReadFile(filepath.Join(os.Getenv("WG_CONF_DIR"), os.Getenv("WG_INTERFACE_NAME")))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user