Browse Source

zones: add Port information to RingAddressEncoder

Signed-off-by: Alejandro Mery <amery@jpi.io>
pull/1/head
Alejandro Mery 10 months ago
parent
commit
ffdacb833b
  1. 7
      pkg/zones/rings.go

7
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,
}

Loading…
Cancel
Save