Browse Source

fix lookup for netclient wg config file

Matthew R Kasun 3 years ago
parent
commit
9c6a26dcc5
1 changed files with 3 additions and 2 deletions
  1. 3 2
      netclient/wireguard/common.go

+ 3 - 2
netclient/wireguard/common.go

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