zones: Machine.SetGateway()

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-08-26 18:32:44 +00:00
parent b4f1d2e4d9
commit af90825f13
2 changed files with 38 additions and 0 deletions
+18
View File
@@ -43,6 +43,24 @@ func (m *Machine) IsGateway() bool {
return ok
}
// SetGateway enables/disables a Machine ring0 integration
func (m *Machine) SetGateway(enabled bool) error {
ri, found := m.getRingInfo(0)
switch {
case !found && !enabled:
return nil
case !found:
var err error
if ri, err = m.createRingInfo(0, false); err != nil {
return err
}
}
ri.Enabled = enabled
return m.SyncWireguardConfig(0)
}
// Zone indicates the [Zone] this machine belongs to
func (m *Machine) Zone() int {
return m.zone.ID