Compare commits

..

9 Commits

Author SHA1 Message Date
amery 4c07bf85d3 cluster: load regions when scanning a directory
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 19:26:00 +00:00
amery d71dd99c15 cluster: introduce SyncRegions() to write regions file
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 19:26:00 +00:00
amery 135f098bf1 cluster: fix regions/zones mapping when the region exists
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 19:25:07 +00:00
amery f79123caee Merge branch 'pr-amery-dns-ignore' into next-amery 2023-10-30 19:23:43 +00:00
amery 99998dc7e8 cluster: mark Machine as Inactive if the "region" file contains "none"
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 19:21:08 +00:00
amery 892d849740 cluster: introduce Machine.Inactive flag
if a Machine is Inactive, it won't be included on the DNS
aliases for the zone or it's regions.

v2:
- Machine.Active() renamed to Machine.IsActive()

Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 19:20:45 +00:00
amery 242c1e9067 wireguard: switch from gcfg to asciigoat.org/ini/basic
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 19:16:10 +00:00
amery 125a4c0dbe wireguard: implement EndpointAddress.UnmarshalText
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 19:13:41 +00:00
amery 7c811d7813 wireguard: implement UnmarshalText for PrivateKey and PublicKey
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 19:13:41 +00:00
4 changed files with 13 additions and 15 deletions
+1 -1
View File
@@ -52,7 +52,7 @@ func populateDNSManager(mgr *dns.Manager, m *cluster.Cluster) error {
m.ForEachZone(func(z *cluster.Zone) bool {
z.ForEachMachine(func(p *cluster.Machine) bool {
err = mgr.AddHost(ctx, z.Name, p.ID, p.Active(), p.PublicAddresses...)
err = mgr.AddHost(ctx, z.Name, p.ID, p.IsActive(), p.PublicAddresses...)
return err != nil
})
+2 -2
View File
@@ -44,8 +44,8 @@ func (m *Machine) FullName() string {
return strings.Join(name, ".")
}
// Active indicates the machine is to be included in regions' DNS entries
func (m *Machine) Active() bool {
// IsActive indicates the machine is to be included in regions' DNS entries
func (m *Machine) IsActive() bool {
return !m.Inactive
}
+2 -2
View File
@@ -37,7 +37,7 @@ func (r *Region) ForEachMachine(fn func(*Machine) bool) {
var term bool
z.ForEachMachine(func(p *Machine) bool {
if p.Active() {
if p.IsActive() {
term = fn(p)
}
return term
@@ -178,7 +178,7 @@ func (z *Zone) SyncRegions() error {
err := z.syncZoneRegions()
if err == nil {
z.ForEachMachine(func(p *Machine) bool {
if p.Active() {
if p.IsActive() {
err = p.RemoveFile("region")
} else {
err = p.WriteStringFile("none\n", "region")
+8 -10
View File
@@ -54,25 +54,23 @@ func (pub PublicKey) String() string {
// UnmarshalText loads the value from base64
func (key *PrivateKey) UnmarshalText(b []byte) error {
v, err := PrivateKeyFromBase64(string(b))
switch {
case err != nil:
if err != nil {
return err
default:
*key = v
return nil
}
*key = v
return nil
}
// UnmarshalText loads the value from base64
func (pub *PublicKey) UnmarshalText(b []byte) error {
v, err := PublicKeyFromBase64(string(b))
switch {
case err != nil:
if err != nil {
return err
default:
*pub = v
return nil
}
*pub = v
return nil
}
// MarshalJSON encodes the key for JSON, omitting empty.