From c92873f07da1ec812c6ddd7576a5dc3f9767a036 Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Tue, 22 Aug 2023 17:10:04 +0000 Subject: [PATCH] zones: introduce RingInfo and Machine.Rings RingInfo includes Wireguard ring related details Signed-off-by: Alejandro Mery --- pkg/zones/machine.go | 5 +++-- pkg/zones/rings.go | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/pkg/zones/machine.go b/pkg/zones/machine.go index 752e6ad..ce9a8e8 100644 --- a/pkg/zones/machine.go +++ b/pkg/zones/machine.go @@ -16,9 +16,10 @@ type Machine struct { zone *Zone id int - Name string + Name string `toml:"name"` - PublicAddresses []netip.Addr + PublicAddresses []netip.Addr `toml:"public,omitempty"` + RingAddresses []*RingInfo `toml:"rings,omitempty"` } func (m *Machine) String() string { diff --git a/pkg/zones/rings.go b/pkg/zones/rings.go index 1eb36e8..fbd6927 100644 --- a/pkg/zones/rings.go +++ b/pkg/zones/rings.go @@ -1,6 +1,10 @@ package zones -import "net/netip" +import ( + "net/netip" + + "git.jpi.io/amery/jpictl/pkg/wireguard" +) const ( // MaxZoneID indicates the highest ID allowed for a Zone @@ -11,6 +15,15 @@ const ( RingsCount = 2 ) +// RingInfo contains represents the Wireguard endpoint details +// for a Machine on a particular ring +type RingInfo struct { + Ring int `toml:"ring"` + Enabled bool `toml:"enabled,omitempty"` + Keys *wireguard.KeyPair `toml:"keys,omitempty"` + Address netip.Addr `toml:"address,omitempty"` +} + // RingAddressEncoder provides encoder/decoder access for a particular // Wireguard ring type RingAddressEncoder struct {