mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-22 00:19:39 +08:00
fixing build dependency issues
This commit is contained in:
@@ -1,9 +1,13 @@
|
|||||||
package ncutils
|
package ncutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RunCmd - runs a local command
|
// RunCmd - runs a local command
|
||||||
@@ -19,6 +23,10 @@ func RunCmd(command string, printerr bool) (string, error) {
|
|||||||
return string(out), err
|
return string(out), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RunCmdFormatted(command string, printerr bool) (string, error) {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
// CreateUserSpaceConf - creates a user space WireGuard conf
|
// CreateUserSpaceConf - creates a user space WireGuard conf
|
||||||
func CreateUserSpaceConf(address string, privatekey string, listenPort string, mtu int32, fwmark int32, perskeepalive int32, peers []wgtypes.PeerConfig) (string, error) {
|
func CreateUserSpaceConf(address string, privatekey string, listenPort string, mtu int32, fwmark int32, perskeepalive int32, peers []wgtypes.PeerConfig) (string, error) {
|
||||||
peersString, err := parsePeers(perskeepalive, peers)
|
peersString, err := parsePeers(perskeepalive, peers)
|
||||||
|
@@ -2,13 +2,20 @@ package ncutils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
"log"
|
"log"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func RunCmdFormatted(command string, printerr bool) (string, error) {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
// Runs Commands for FreeBSD
|
// Runs Commands for FreeBSD
|
||||||
func RunCmd(command string, printerr bool) (string, error) {
|
func RunCmd(command string, printerr bool) (string, error) {
|
||||||
args := strings.Fields(command)
|
args := strings.Fields(command)
|
||||||
@@ -27,3 +34,39 @@ func RunCmd(command string, printerr bool) (string, error) {
|
|||||||
}
|
}
|
||||||
return string(out), err
|
return string(out), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CreateUserSpaceConf - creates a user space WireGuard conf
|
||||||
|
func CreateUserSpaceConf(address string, privatekey string, listenPort string, mtu int32, fwmark int32, perskeepalive int32, peers []wgtypes.PeerConfig) (string, error) {
|
||||||
|
peersString, err := parsePeers(perskeepalive, peers)
|
||||||
|
var listenPortString string
|
||||||
|
var fwmarkString string
|
||||||
|
if mtu <= 0 {
|
||||||
|
mtu = 1280
|
||||||
|
}
|
||||||
|
if listenPort != "" {
|
||||||
|
listenPortString += "ListenPort = " + listenPort
|
||||||
|
}
|
||||||
|
if fwmark != 0 {
|
||||||
|
fwmarkString += "FWMark = " + strconv.Itoa(int(fwmark))
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
config := fmt.Sprintf(`[Interface]
|
||||||
|
Address = %s
|
||||||
|
PrivateKey = %s
|
||||||
|
MTU = %s
|
||||||
|
%s
|
||||||
|
%s
|
||||||
|
|
||||||
|
%s
|
||||||
|
|
||||||
|
`,
|
||||||
|
address+"/32",
|
||||||
|
privatekey,
|
||||||
|
strconv.Itoa(int(mtu)),
|
||||||
|
listenPortString,
|
||||||
|
fwmarkString,
|
||||||
|
peersString)
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
@@ -1,9 +1,13 @@
|
|||||||
package ncutils
|
package ncutils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RunCmd - runs a local command
|
// RunCmd - runs a local command
|
||||||
@@ -19,6 +23,10 @@ func RunCmd(command string, printerr bool) (string, error) {
|
|||||||
return string(out), err
|
return string(out), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RunCmdFormatted(command string, printerr bool) (string, error) {
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
// CreateUserSpaceConf - creates a user space WireGuard conf
|
// CreateUserSpaceConf - creates a user space WireGuard conf
|
||||||
func CreateUserSpaceConf(address string, privatekey string, listenPort string, mtu int32, fwmark int32, perskeepalive int32, peers []wgtypes.PeerConfig) (string, error) {
|
func CreateUserSpaceConf(address string, privatekey string, listenPort string, mtu int32, fwmark int32, perskeepalive int32, peers []wgtypes.PeerConfig) (string, error) {
|
||||||
peersString, err := parsePeers(perskeepalive, peers)
|
peersString, err := parsePeers(perskeepalive, peers)
|
||||||
|
Reference in New Issue
Block a user