Compare commits

..

13 Commits

Author SHA1 Message Date
amery ce7eac8e58 cluster: load regions when scanning a directory
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 18:55:18 +00:00
amery 935e69b0e9 cluster: introduce SyncRegions() to write regions file
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 18:55:18 +00:00
amery cbc863b14c cluster: fix regions/zones mapping when the region exists
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 18:55:18 +00:00
amery 0eb0647992 Merge branch 'pr-amery-dns-ignore' into next-amery 2023-10-30 18:54:01 +00:00
amery a725b66d14 cluster: mark Machine as Inactive if the "region" file contains "none"
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 18:52:38 +00:00
amery 851274954e 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.

Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-30 18:52:34 +00:00
amery 770f55c8f1 Merge branch 'pr-amery-wireguard-ini' into next-amery 2023-10-30 18:51:23 +00:00
amery 188f0a765f Merge branch 'pr-amery-unmarshaltext' into next-amery 2023-10-30 18:51:07 +00:00
amery 634941a1ef wireguard: implement EndpointAddress.UnmarshalText
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-28 15:55:09 +00:00
amery 1da505fd3d wireguard: implement UnmarshalText for PrivateKey and PublicKey
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-28 15:54:33 +00:00
amery 8d62bb0aae wireguard: switch from gcfg to asciigoat.org/ini/basic
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-27 20:17:47 +00:00
amery e748babf08 wireguard: implement EndpointAddress.UnmarshalText
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-27 20:16:32 +00:00
amery 71fafb1f21 wireguard: implement UnmarshalText for PrivateKey and PublicKey
Signed-off-by: Alejandro Mery <amery@jpi.io>
2023-10-27 20:16:32 +00:00
4 changed files with 15 additions and 13 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.IsActive(), p.PublicAddresses...)
err = mgr.AddHost(ctx, z.Name, p.ID, p.Active(), p.PublicAddresses...)
return err != nil
})
+2 -2
View File
@@ -44,8 +44,8 @@ func (m *Machine) FullName() string {
return strings.Join(name, ".")
}
// IsActive indicates the machine is to be included in regions' DNS entries
func (m *Machine) IsActive() bool {
// Active indicates the machine is to be included in regions' DNS entries
func (m *Machine) Active() 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.IsActive() {
if p.Active() {
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.IsActive() {
if p.Active() {
err = p.RemoveFile("region")
} else {
err = p.WriteStringFile("none\n", "region")
+10 -8
View File
@@ -54,23 +54,25 @@ func (pub PublicKey) String() string {
// UnmarshalText loads the value from base64
func (key *PrivateKey) UnmarshalText(b []byte) error {
v, err := PrivateKeyFromBase64(string(b))
if err != nil {
switch {
case 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))
if err != nil {
switch {
case err != nil:
return err
default:
*pub = v
return nil
}
*pub = v
return nil
}
// MarshalJSON encodes the key for JSON, omitting empty.