write persistent keepalive to wg.conf file

This commit is contained in:
Matthew R Kasun 2022-01-21 09:36:29 -05:00
parent 799f32c664
commit 1a00f8377e

View file

@ -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