ed9808c4f1
This commit updates the DNS query locality parsing so that the virtual IP for an imported service can be queried. Note that: - Support for parsing a peer in other service discovery queries was not added. - Querying another datacenter for a virtual IP is not supported. This was technically allowed in 1.11 but is being rolled back for 1.13 because it is not a use-case we intended to support. Virtual IPs in different datacenters are going to collide because they are allocated sequentially.
37 lines
998 B
Go
37 lines
998 B
Go
//go:build !consulent
|
|
// +build !consulent
|
|
|
|
package agent
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/hashicorp/consul/acl"
|
|
"github.com/hashicorp/consul/agent/config"
|
|
)
|
|
|
|
type enterpriseDNSConfig struct{}
|
|
|
|
func getEnterpriseDNSConfig(conf *config.RuntimeConfig) enterpriseDNSConfig {
|
|
return enterpriseDNSConfig{}
|
|
}
|
|
|
|
// 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) {
|
|
switch len(labels) {
|
|
case 1:
|
|
return queryLocality{peerOrDatacenter: labels[0]}, true
|
|
|
|
case 0:
|
|
return queryLocality{}, true
|
|
}
|
|
|
|
return queryLocality{}, false
|
|
}
|
|
|
|
func serviceCanonicalDNSName(name, kind, datacenter, domain string, _ *acl.EnterpriseMeta) string {
|
|
return fmt.Sprintf("%s.%s.%s.%s", name, kind, datacenter, domain)
|
|
}
|