Browse Source

write persistent keepalive to wg.conf file

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

+ 3 - 0
netclient/wireguard/common.go

@@ -379,6 +379,9 @@ func UpdateWgPeers(wgInterface string, peers []wgtypes.PeerConfig) error {
 		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 {
+			wireguard.SectionWithIndex(section_peers, i).Key("PersistentKeepalive").SetValue(strconv.FormatInt((int64)(peer.PersistentKeepaliveInterval.Seconds()), 10))
+		}
 	}
 	}
 	if err := wireguard.SaveTo(file); err != nil {
 	if err := wireguard.SaveTo(file); err != nil {
 		return err
 		return err