mirror of
https://github.com/gravitl/netmaker.git
synced 2024-09-21 07:46:04 +08:00
remove call to wgctrl.Device for freebsd
This commit is contained in:
parent
c4aff93437
commit
a529b28a00
|
@ -50,7 +50,7 @@ func SetPeerRoutes(iface, currentNodeAddr string, oldPeers map[string][]net.IPNe
|
|||
}
|
||||
|
||||
// SetCurrentPeerRoutes - sets all the current peers
|
||||
func SetCurrentPeerRoutes(iface, currentAddr string, peers []wgtypes.Peer) {
|
||||
func SetCurrentPeerRoutes(iface, currentAddr string, peers []wgtypes.PeerConfig) {
|
||||
for _, peer := range peers {
|
||||
for _, allowedIP := range peer.AllowedIPs {
|
||||
setRoute(iface, &allowedIP, currentAddr)
|
||||
|
|
|
@ -172,8 +172,7 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
|
|||
d, _ = wgclient.Device(deviceiface)
|
||||
}
|
||||
|
||||
ApplyConf(node, deviceiface, confPath) // Apply initially
|
||||
|
||||
ApplyConf(node, deviceiface, confPath) // Apply initially
|
||||
ncutils.PrintLog("waiting for interface...", 1) // ensure interface is created
|
||||
output, _ := ncutils.RunCmd("wg", false)
|
||||
starttime := time.Now()
|
||||
|
@ -184,23 +183,29 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
|
|||
time.Sleep(time.Second)
|
||||
ifaceReady = strings.Contains(output, ifacename)
|
||||
}
|
||||
newDevice, devErr := wgclient.Device(deviceiface)
|
||||
if !ifaceReady || devErr != nil {
|
||||
return fmt.Errorf("could not reliably create interface, please check wg installation and retry")
|
||||
//wgclient does not work well on freebsd
|
||||
if node.OS == "freebsd" {
|
||||
if !ifaceReady {
|
||||
return fmt.Errorf("could not reliably create interface, please check wg installation and retry")
|
||||
}
|
||||
} else {
|
||||
_, devErr := wgclient.Device(deviceiface)
|
||||
if !ifaceReady || devErr != nil {
|
||||
return fmt.Errorf("could not reliably create interface, please check wg installation and retry")
|
||||
}
|
||||
}
|
||||
ncutils.PrintLog("interface ready - netclient engage", 1)
|
||||
|
||||
if syncconf { // should never be called really.
|
||||
err = SyncWGQuickConf(ifacename, confPath)
|
||||
}
|
||||
currentPeers := newDevice.Peers
|
||||
|
||||
_, cidr, cidrErr := net.ParseCIDR(modcfg.NetworkSettings.AddressRange)
|
||||
if cidrErr == nil {
|
||||
local.SetCIDRRoute(ifacename, node.Address, cidr)
|
||||
} else {
|
||||
ncutils.PrintLog("could not set cidr route properly: "+cidrErr.Error(), 1)
|
||||
}
|
||||
local.SetCurrentPeerRoutes(ifacename, node.Address, currentPeers[:])
|
||||
local.SetCurrentPeerRoutes(ifacename, node.Address, peers)
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue