Browse Source

cluster: fix wg1.conf generator

Signed-off-by: Nagy Károly Gábriel <k@jpi.io>
pull/56/head
Nagy Károly Gábriel 5 months ago
parent
commit
48ece57bbc
Signed by: karasz
GPG Key ID: FA002E83BC206F83
  1. 11
      pkg/cluster/rings.go

11
pkg/cluster/rings.go

@ -225,13 +225,21 @@ func (r *Ring) setRingZeroAllowedIPs(rp *RingPeer) {
rp.AllowCIDR(rp.Address, 32)
}
// revive:disable:cognitive-complexity
func (r *Ring) setRingOneGatewayAllowedIPs(rp *RingPeer) {
// revive:enable:cognitive-complexity
regionID, zoneID, _, _ := r.Decode(rp.Address)
// peer
rp.AllowCIDR(rp.Address, 32)
// ring1 gateways connect to all other ring1 networks
m, ok := r.ZoneIterator.(RegionIterator)
if !ok {
panic("Cannot iterate Region from Zone")
}
m.ForEachRegion(func(r2 *Region) bool {
if r2.IsPrimary() {
r.ForEachZone(func(z *Zone) bool {
if !z.Is(regionID, zoneID) {
subnet := z.RingOnePrefix()
@ -239,6 +247,9 @@ func (r *Ring) setRingOneGatewayAllowedIPs(rp *RingPeer) {
}
return false
})
}
return false
})
// ring1 gateways also connect to all ring0 addresses
r.ForEachZone(func(z *Zone) bool {

Loading…
Cancel
Save