zones: introduce RingInfo and Machine.Rings

RingInfo includes Wireguard ring related details

Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-08-22 17:10:04 +00:00
parent 4d25ea1d16
commit c92873f07d
2 changed files with 17 additions and 3 deletions
+3 -2
View File
@@ -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 {
+14 -1
View File
@@ -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 {