zones: Zones.WriteWireguardKeys() and Zone.WriteWireguardKeys()
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package zones
|
package zones
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
// PruneWireguardConfig removes wgN.conf files of machines with
|
// PruneWireguardConfig removes wgN.conf files of machines with
|
||||||
// the corresponding ring disabled.
|
// the corresponding ring disabled.
|
||||||
func (z *Zone) PruneWireguardConfig(ring int) error {
|
func (z *Zone) PruneWireguardConfig(ring int) error {
|
||||||
@@ -16,6 +18,23 @@ func (z *Zone) PruneWireguardConfig(ring int) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteWireguardKeys rewrites all wgN.{key,pub} files on this zone
|
||||||
|
func (z *Zone) WriteWireguardKeys(ring int) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
z.ForEachMachine(func(p *Machine) bool {
|
||||||
|
err = p.WriteWireguardKeys(ring)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
// ignore
|
||||||
|
err = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return err != nil
|
||||||
|
})
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// PruneWireguardConfig removes wgN.conf files of machines with
|
// PruneWireguardConfig removes wgN.conf files of machines with
|
||||||
// the corresponding ring disabled on all zones
|
// the corresponding ring disabled on all zones
|
||||||
func (m *Zones) PruneWireguardConfig(ring int) error {
|
func (m *Zones) PruneWireguardConfig(ring int) error {
|
||||||
@@ -28,3 +47,15 @@ func (m *Zones) PruneWireguardConfig(ring int) error {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WriteWireguardKeys rewrites all wgN.{key,pub} files
|
||||||
|
func (m *Zones) WriteWireguardKeys(ring int) error {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
m.ForEachZone(func(z *Zone) bool {
|
||||||
|
err = z.WriteWireguardKeys(ring)
|
||||||
|
return err != nil
|
||||||
|
})
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user