zones: SetGateway [WIP]

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-08-23 14:32:36 +00:00
parent 87258c7a9e
commit 61d1ea85ee
2 changed files with 41 additions and 0 deletions
+16
View File
@@ -70,6 +70,22 @@ func (m *Machine) IsGateway() bool {
return false
}
// SetGateway enables/disables a Machine ring0 integration
func (m *Machine) SetGateway(enabled bool) error {
m.mu.Lock()
defer m.mu.Unlock()
ri, found := m.getRingInfo(0)
switch {
case !found && !enabled:
return nil
case !found:
return m.createRingInfo(0, true)
default:
ri.Enabled = enabled
return m.writeRingInfo(ri)
}
}
func (m *Machine) getPeerByName(name string) (*Machine, bool) {
return m.zone.zones.GetMachineByName(name)
}