checker: build host FQDN from subdomain + apex at service scope
This commit is contained in:
parent
603e93355b
commit
77f8ee4024
5 changed files with 31 additions and 7 deletions
|
|
@ -9,7 +9,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
sdk "git.happydns.org/checker-sdk-go/checker"
|
||||
happydns "git.happydns.org/happyDomain/model"
|
||||
|
|
@ -36,15 +35,17 @@ func resolveServer(opts sdk.CheckerOptions) (*abstract.Server, error) {
|
|||
return &server, nil
|
||||
}
|
||||
|
||||
// addressesFromServer returns the (host, ips) tuple to probe.
|
||||
func addressesFromServer(server *abstract.Server) (host string, ips []string) {
|
||||
// addressesFromServer returns the (host, ips) tuple to probe. origin is
|
||||
// the service's parent zone; the A/AAAA Hdr.Name is relative to it as
|
||||
// happyDomain encodes service owners, so we must join before using as FQDN.
|
||||
func addressesFromServer(server *abstract.Server, origin string) (host string, ips []string) {
|
||||
if server.A != nil && len(server.A.A) > 0 {
|
||||
host = strings.TrimSuffix(server.A.Hdr.Name, ".")
|
||||
host = sdk.JoinRelative(server.A.Hdr.Name, origin)
|
||||
ips = append(ips, server.A.A.String())
|
||||
}
|
||||
if server.AAAA != nil && len(server.AAAA.AAAA) > 0 {
|
||||
if host == "" {
|
||||
host = strings.TrimSuffix(server.AAAA.Hdr.Name, ".")
|
||||
host = sdk.JoinRelative(server.AAAA.Hdr.Name, origin)
|
||||
}
|
||||
ips = append(ips, server.AAAA.AAAA.String())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue