Compare commits
2 Commits
0d14510958
...
c92873f07d
| Author | SHA1 | Date | |
|---|---|---|---|
| c92873f07d | |||
| 4d25ea1d16 |
@@ -0,0 +1,30 @@
|
|||||||
|
package wireguard
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BinaryKey is a binary blob
|
||||||
|
type BinaryKey []byte
|
||||||
|
|
||||||
|
func (k BinaryKey) String() string {
|
||||||
|
return base64.StdEncoding.EncodeToString(k)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsZero tells if the key hasn't been set
|
||||||
|
func (k BinaryKey) IsZero() bool {
|
||||||
|
return len(k) == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// BinaryKeyFromBase64 decodes a base64-based string into
|
||||||
|
// a [BinaryKey]
|
||||||
|
func BinaryKeyFromBase64(data string) (BinaryKey, error) {
|
||||||
|
b, err := base64.StdEncoding.DecodeString(data)
|
||||||
|
return BinaryKey(b), err
|
||||||
|
}
|
||||||
|
|
||||||
|
// KeyPair holds a Key pair
|
||||||
|
type KeyPair struct {
|
||||||
|
PrivateKey BinaryKey
|
||||||
|
PublicKey BinaryKey
|
||||||
|
}
|
||||||
@@ -16,9 +16,10 @@ type Machine struct {
|
|||||||
|
|
||||||
zone *Zone
|
zone *Zone
|
||||||
id int
|
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 {
|
func (m *Machine) String() string {
|
||||||
|
|||||||
+14
-1
@@ -1,6 +1,10 @@
|
|||||||
package zones
|
package zones
|
||||||
|
|
||||||
import "net/netip"
|
import (
|
||||||
|
"net/netip"
|
||||||
|
|
||||||
|
"git.jpi.io/amery/jpictl/pkg/wireguard"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// MaxZoneID indicates the highest ID allowed for a Zone
|
// MaxZoneID indicates the highest ID allowed for a Zone
|
||||||
@@ -11,6 +15,15 @@ const (
|
|||||||
RingsCount = 2
|
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
|
// RingAddressEncoder provides encoder/decoder access for a particular
|
||||||
// Wireguard ring
|
// Wireguard ring
|
||||||
type RingAddressEncoder struct {
|
type RingAddressEncoder struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user