fix lookup for netclient wg config file

This commit is contained in:
Matthew R Kasun 2022-01-21 14:07:28 -05:00
parent 95dea6a4ba
commit 9c6a26dcc5

View file

@ -165,7 +165,7 @@ func InitWireguard(node *models.Node, privkey string, peers []wgtypes.PeerConfig
// return err
//}
//if ncutils.IsWindows() {
confPath := ncutils.GetWGPathSpecific() + ifacename + ".conf"
confPath := ncutils.GetNetclientPathSpecific() + ifacename + ".conf"
// err = os.WriteFile(wgConfPath, []byte(newConf), 0644)
// if err != nil {
// ncutils.PrintLog("error writing wg conf file to "+wgConfPath+": "+err.Error(), 1)
@ -333,7 +333,7 @@ func WriteWgConfig(node *models.Node, privateKey string, peers []wgtypes.PeerCon
}
for i, peer := range peers {
wireguard.SectionWithIndex(section_peers, i).Key("PublicKey").SetValue(peer.PublicKey.String())
if peer.PresharedKey.String() != "" {
if peer.PresharedKey != nil {
wireguard.SectionWithIndex(section_peers, i).Key("PreSharedKey").SetValue(peer.PresharedKey.String())
}
if peer.AllowedIPs != nil {
@ -350,6 +350,7 @@ func WriteWgConfig(node *models.Node, privateKey string, peers []wgtypes.PeerCon
if peer.Endpoint != nil {
wireguard.SectionWithIndex(section_peers, i).Key("Endpoint").SetValue(peer.Endpoint.String())
}
if peer.PersistentKeepaliveInterval != nil && peer.PersistentKeepaliveInterval.Seconds() > 0 {
wireguard.SectionWithIndex(section_peers, i).Key("PersistentKeepalive").SetValue(strconv.FormatInt((int64)(peer.PersistentKeepaliveInterval.Seconds()), 10))
}