Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
2023-09-12 04:37:51 +00:00
parent 60d3a5f650
commit 8d1b9c4f04
10 changed files with 443 additions and 4 deletions
+41
View File
@@ -0,0 +1,41 @@
package dns
import (
"context"
"io/fs"
"net/netip"
)
// AddHost registers a machine
func (mgr *Manager) AddHost(_ context.Context, zone string, id int,
active bool, addrs ...netip.Addr) error {
//
if zone == "" || id <= 0 {
return fs.ErrInvalid
}
z, ok := mgr.zones[zone]
if !ok {
z = &Zone{
Name: zone,
Machines: make(map[int]*Machine),
}
mgr.zones[zone] = z
}
z.Machines[id] = &Machine{
ID: id,
Active: active,
Addrs: SortAddrSlice(addrs),
}
return nil
}
// AddRegion specifies a new region and the zones it contains
func (mgr *Manager) AddRegion(_ context.Context, region string, zones ...string) error {
mgr.l.Debug().WithField("region", region).WithField("zones", zones).Print()
mgr.regions[region] = append(mgr.regions[region], zones...)
return nil
}