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