|
|
@ -118,21 +118,31 @@ func (m *Machine) tryApplyWireguardConfig(ring int) error { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (m *Machine) applyWireguardConfig(ring int, wg *wireguard.Config) error { |
|
|
|
func (m *Machine) applyWireguardConfigNode(ring int, wg *wireguard.Config) error { |
|
|
|
addr := wg.GetAddress() |
|
|
|
addr := wg.GetAddress() |
|
|
|
zoneID, nodeID, ok := Rings[ring].Decode(addr) |
|
|
|
if !core.IsZero(addr) { |
|
|
|
if !ok { |
|
|
|
zoneID, nodeID, ok := Rings[ring].Decode(addr) |
|
|
|
return fmt.Errorf("%s: invalid address", addr) |
|
|
|
if !ok { |
|
|
|
} |
|
|
|
return fmt.Errorf("%s: invalid address", addr) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := m.applyZoneNodeID(zoneID, nodeID); err != nil { |
|
|
|
if err := m.applyZoneNodeID(zoneID, nodeID); err != nil { |
|
|
|
return core.Wrap(err, "%s: invalid address", addr) |
|
|
|
return core.Wrap(err, "%s: invalid address", addr) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := m.applyWireguardInterfaceConfig(ring, wg.Interface); err != nil { |
|
|
|
if err := m.applyWireguardInterfaceConfig(ring, wg.Interface); err != nil { |
|
|
|
return core.Wrap(err, "interface") |
|
|
|
return core.Wrap(err, "interface") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (m *Machine) applyWireguardConfig(ring int, wg *wireguard.Config) error { |
|
|
|
|
|
|
|
if err := m.applyWireguardConfigNode(ring, wg); err != nil { |
|
|
|
|
|
|
|
return err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for _, peer := range wg.Peer { |
|
|
|
for _, peer := range wg.Peer { |
|
|
|
err := m.applyWireguardPeerConfig(ring, peer) |
|
|
|
err := m.applyWireguardPeerConfig(ring, peer) |
|
|
|
switch { |
|
|
|
switch { |
|
|
|