|
|
@ -3,6 +3,7 @@ package zones |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"context" |
|
|
|
"context" |
|
|
|
"net/netip" |
|
|
|
"net/netip" |
|
|
|
|
|
|
|
"strconv" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -26,6 +27,10 @@ func (m *Machine) updatePublicAddresses() error { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *Machine) init() error { |
|
|
|
func (m *Machine) init() error { |
|
|
|
|
|
|
|
if err := m.setID(); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for i := 0; i < RingsCount; i++ { |
|
|
|
for i := 0; i < RingsCount; i++ { |
|
|
|
if err := m.tryReadWireguardKeys(i); err != nil { |
|
|
|
if err := m.tryReadWireguardKeys(i); err != nil { |
|
|
|
return err |
|
|
|
return err |
|
|
@ -34,6 +39,19 @@ func (m *Machine) init() error { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (m *Machine) setID() error { |
|
|
|
|
|
|
|
zoneName := m.zone.Name |
|
|
|
|
|
|
|
suffix := m.Name[len(zoneName)+1:] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
id, err := strconv.ParseInt(suffix, 10, 8) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m.ID = int(id) |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *Machine) scan() error { |
|
|
|
func (m *Machine) scan() error { |
|
|
|
for i := 0; i < RingsCount; i++ { |
|
|
|
for i := 0; i < RingsCount; i++ { |
|
|
|
if err := m.tryApplyWireguardConfig(i); err != nil { |
|
|
|
if err := m.tryApplyWireguardConfig(i); err != nil { |
|
|
|