Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-08-26 16:37:41 +00:00
parent 25f221e13c
commit 6bd18c472a
4 changed files with 139 additions and 3 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