2021-11-16 18:04:01 +00:00
|
|
|
//go:build !consulent
|
2019-12-10 02:26:41 +00:00
|
|
|
// +build !consulent
|
|
|
|
|
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2022-04-05 21:10:06 +00:00
|
|
|
"github.com/hashicorp/consul/acl"
|
2019-12-10 02:26:41 +00:00
|
|
|
"github.com/hashicorp/consul/agent/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
type enterpriseDNSConfig struct{}
|
|
|
|
|
|
|
|
func getEnterpriseDNSConfig(conf *config.RuntimeConfig) enterpriseDNSConfig {
|
|
|
|
return enterpriseDNSConfig{}
|
|
|
|
}
|
|
|
|
|
2022-07-06 16:30:04 +00:00
|
|
|
// parseLocality can parse peer name or datacenter from a DNS query's labels.
|
|
|
|
// Peer name is parsed from the same query part that datacenter is, so given this ambiguity
|
|
|
|
// we parse a "peerOrDatacenter". The caller or RPC handler are responsible for disambiguating.
|
|
|
|
func (d *DNSServer) parseLocality(labels []string, cfg *dnsConfig) (queryLocality, bool) {
|
2019-12-10 02:26:41 +00:00
|
|
|
switch len(labels) {
|
|
|
|
case 1:
|
2022-07-06 16:30:04 +00:00
|
|
|
return queryLocality{peerOrDatacenter: labels[0]}, true
|
|
|
|
|
2019-12-10 02:26:41 +00:00
|
|
|
case 0:
|
2022-07-06 16:30:04 +00:00
|
|
|
return queryLocality{}, true
|
2019-12-10 02:26:41 +00:00
|
|
|
}
|
2022-07-06 16:30:04 +00:00
|
|
|
|
|
|
|
return queryLocality{}, false
|
2019-12-10 02:26:41 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 21:10:06 +00:00
|
|
|
func serviceCanonicalDNSName(name, kind, datacenter, domain string, _ *acl.EnterpriseMeta) string {
|
2020-06-22 19:14:12 +00:00
|
|
|
return fmt.Sprintf("%s.%s.%s.%s", name, kind, datacenter, domain)
|
2019-12-10 02:26:41 +00:00
|
|
|
}
|