Compare commits

...

2 Commits

Author SHA1 Message Date
Alejandro Mery 9810f5c6c1 cluster: drop wg1.conf generation 5 months ago
Alejandro Mery 8948b6702a Revert "cluster: fix wg1 generation (AllowedIPs)" 5 months ago
  1. 2
      pkg/cluster/errors.go
  2. 10
      pkg/cluster/rings.go
  3. 8
      pkg/cluster/wireguard.go

2
pkg/cluster/errors.go

@ -25,5 +25,5 @@ var (
// ErrInvalidRing returns an error indicating the [rings.RingID] // ErrInvalidRing returns an error indicating the [rings.RingID]
// can't be used for the intended purpose // can't be used for the intended purpose
func ErrInvalidRing(ringID rings.RingID) error { func ErrInvalidRing(ringID rings.RingID) error {
return core.QuietWrap(fs.ErrInvalid, "invalid ring %v", ringID) return core.QuietWrap(fs.ErrInvalid, "invalid ring %v", ringID-1)
} }

10
pkg/cluster/rings.go

@ -27,8 +27,6 @@ func AsWireguardInterfaceID(ring rings.RingID) (WireguardInterfaceID, error) {
switch ring { switch ring {
case rings.RingZeroID: case rings.RingZeroID:
return 0, nil return 0, nil
case rings.RingOneID:
return 1, nil
default: default:
return 0, ErrInvalidRing(ring) return 0, ErrInvalidRing(ring)
} }
@ -148,17 +146,9 @@ var (
Decode: rings.DecodeRingZeroAddress, Decode: rings.DecodeRingZeroAddress,
Encode: rings.RingZeroAddress, Encode: rings.RingZeroAddress,
} }
// RingOne is a wg1 address encoder/decoder
RingOne = RingAddressEncoder{
ID: rings.RingOneID,
Port: RingOnePort,
Decode: rings.DecodeRingOneAddress,
Encode: rings.RingOneAddress,
}
// Rings provides indexed access to the ring address encoders // Rings provides indexed access to the ring address encoders
Rings = []RingAddressEncoder{ Rings = []RingAddressEncoder{
RingZero, RingZero,
RingOne,
} }
) )

8
pkg/cluster/wireguard.go

@ -97,11 +97,15 @@ func (m *Cluster) WriteWireguardConfig(ring rings.RingID) error {
// WriteWireguardConfig rewrites all wgN.conf on all machines // WriteWireguardConfig rewrites all wgN.conf on all machines
// on the Zone attached to that ring // on the Zone attached to that ring
func (z *Zone) WriteWireguardConfig(ring rings.RingID) error { func (z *Zone) WriteWireguardConfig(ring rings.RingID) error {
if ring == rings.RingZeroID || ring == rings.RingOneID { switch ring {
case rings.RingZeroID:
return writeWireguardConfig(z.zones, z.zones, ring) return writeWireguardConfig(z.zones, z.zones, ring)
} case rings.RingOneID:
return writeWireguardConfig(z.zones, z, ring)
default:
return ErrInvalidRing(ring) return ErrInvalidRing(ring)
} }
}
func writeWireguardConfig(z ZoneIterator, m MachineIterator, ring rings.RingID) error { func writeWireguardConfig(z ZoneIterator, m MachineIterator, ring rings.RingID) error {
r, err := NewRing(z, m, ring) r, err := NewRing(z, m, ring)

Loading…
Cancel
Save