From ffdacb833be15e8678a19b3a4971df110adf9a9e Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Thu, 24 Aug 2023 17:34:00 +0000 Subject: [PATCH] zones: add Port information to RingAddressEncoder Signed-off-by: Alejandro Mery --- pkg/zones/rings.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/zones/rings.go b/pkg/zones/rings.go index 134adc8..763ae84 100644 --- a/pkg/zones/rings.go +++ b/pkg/zones/rings.go @@ -14,6 +14,10 @@ const ( MaxNodeID = 0xff - 1 // RingsCount indicates how many wireguard rings we have RingsCount = 2 + // RingZeroPort is the port wireguard uses for ring0 + RingZeroPort = 51800 + // RingOnePort is the port wireguard uses for ring1 + RingOnePort = 51810 ) // RingInfo contains represents the Wireguard endpoint details @@ -105,6 +109,7 @@ func canMergeKeyPairs(p1, p2 *wireguard.KeyPair) bool { // Wireguard ring type RingAddressEncoder struct { ID int + Port uint16 Encode func(zoneID, nodeID int) (netip.Addr, bool) Decode func(addr netip.Addr) (zoneID, nodeID int, ok bool) } @@ -113,12 +118,14 @@ var ( // RingZero is a wg0 address encoder/decoder RingZero = RingAddressEncoder{ ID: 0, + Port: RingZeroPort, Decode: ParseRingZeroAddress, Encode: RingZeroAddress, } // RingOne is a wg1 address encoder/decoder RingOne = RingAddressEncoder{ ID: 1, + Port: RingOnePort, Decode: ParseRingOneAddress, Encode: RingOneAddress, }