mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-07-26 20:00:27 +03:00
Added wireguard service in container
This commit is contained in:
parent
f43c59c043
commit
a13b78b1f5
6 changed files with 212 additions and 89 deletions
49
util/util.go
49
util/util.go
|
@ -7,6 +7,7 @@ import (
|
|||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
@ -375,6 +376,52 @@ func ValidateIPAllocation(serverAddresses []string, ipAllocatedList []string, ip
|
|||
return true, nil
|
||||
}
|
||||
|
||||
// StopWireguard Server to stop Wireguard server with config. e.g. wg0.conf
|
||||
func StopWireGuardServer(globalSettings model.GlobalSetting) error {
|
||||
|
||||
app := "wg-quick"
|
||||
|
||||
arg0 := "down"
|
||||
arg1 := globalSettings.ConfigFilePath
|
||||
|
||||
|
||||
cmd := exec.Command(app, arg0, arg1)
|
||||
stdout, err := cmd.Output()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
// Print the output
|
||||
fmt.Println(string(stdout))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// StartWireguard Server to start Wireguard server with config. e.g. wg0.conf
|
||||
func StartWireGuardServer(globalSettings model.GlobalSetting) error {
|
||||
|
||||
app := "wg-quick"
|
||||
|
||||
arg0 := "up"
|
||||
arg1 := globalSettings.ConfigFilePath
|
||||
|
||||
|
||||
cmd := exec.Command(app, arg0, arg1)
|
||||
stdout, err := cmd.Output()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
// Print the output
|
||||
fmt.Println(string(stdout))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// WriteWireGuardServerConfig to write Wireguard server config. e.g. wg0.conf
|
||||
func WriteWireGuardServerConfig(tmplBox *rice.Box, serverConfig model.Server, clientDataList []model.ClientData, globalSettings model.GlobalSetting) error {
|
||||
var tmplWireguardConf string
|
||||
|
@ -456,4 +503,4 @@ func LookupEnvOrStrings(key string, defaultVal []string) []string {
|
|||
return strings.Split(val, ",")
|
||||
}
|
||||
return defaultVal
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue