mirror of
https://github.com/gravitl/netmaker.git
synced 2025-02-28 01:52:58 +08:00
fix UpdateWgPeers to enable multiple peer sections
This commit is contained in:
parent
e215f2a9d0
commit
efbb166e51
1 changed files with 6 additions and 1 deletions
|
@ -339,15 +339,20 @@ func WriteWgConfig(cfg config.ClientConfig, privateKey string, peers []wgtypes.P
|
|||
|
||||
// UpdateWgPeers - updates the peers of a network
|
||||
func UpdateWgPeers(wgInterface string, peers []wgtypes.PeerConfig) error {
|
||||
options := ini.LoadOptions{
|
||||
AllowNonUniqueSections: true,
|
||||
AllowShadows: true,
|
||||
}
|
||||
file := ncutils.GetNetclientPathSpecific() + wgInterface + ".conf"
|
||||
ncutils.Log("updating " + file)
|
||||
wireguard, err := ini.ShadowLoad(file)
|
||||
wireguard, err := ini.LoadSources(options, file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//delete the peers sections as they are going to be replaced
|
||||
wireguard.DeleteSection(section_peers)
|
||||
for i, peer := range peers {
|
||||
ncutils.Log("adding peer section for peer #: " + string(i) + peer.PublicKey.String())
|
||||
wireguard.SectionWithIndex(section_peers, i).Key("PublicKey").SetValue(peer.PublicKey.String())
|
||||
//if peer.PresharedKey.String() != "" {
|
||||
//wireguard.SectionWithIndex(section_peers, i).Key("PreSharedKey").SetValue(peer.PresharedKey.String())
|
||||
|
|
Loading…
Reference in a new issue