mirror of https://github.com/status-im/consul.git
Adding a DNS domain config
This commit is contained in:
parent
a8d6e1cfd4
commit
71e85cea72
|
@ -30,6 +30,9 @@ type Config struct {
|
||||||
// DNSAddr is the address of the DNS server for the agent
|
// DNSAddr is the address of the DNS server for the agent
|
||||||
DNSAddr string
|
DNSAddr string
|
||||||
|
|
||||||
|
// Domain is the DNS domain for the records. Defaults to "consul."
|
||||||
|
Domain string
|
||||||
|
|
||||||
// Encryption key to use for the Serf communication
|
// Encryption key to use for the Serf communication
|
||||||
EncryptKey string
|
EncryptKey string
|
||||||
|
|
||||||
|
@ -91,6 +94,7 @@ func DefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
Datacenter: consul.DefaultDC,
|
Datacenter: consul.DefaultDC,
|
||||||
DNSAddr: "127.0.0.1:8600",
|
DNSAddr: "127.0.0.1:8600",
|
||||||
|
Domain: "consul.",
|
||||||
HTTPAddr: "127.0.0.1:8500",
|
HTTPAddr: "127.0.0.1:8500",
|
||||||
LogLevel: "INFO",
|
LogLevel: "INFO",
|
||||||
RPCAddr: "127.0.0.1:8400",
|
RPCAddr: "127.0.0.1:8400",
|
||||||
|
@ -147,6 +151,12 @@ func MergeConfig(a, b *Config) *Config {
|
||||||
if b.DataDir != "" {
|
if b.DataDir != "" {
|
||||||
result.DataDir = b.DataDir
|
result.DataDir = b.DataDir
|
||||||
}
|
}
|
||||||
|
if b.DNSAddr != "" {
|
||||||
|
result.DNSAddr = b.DNSAddr
|
||||||
|
}
|
||||||
|
if b.Domain != "" {
|
||||||
|
result.Domain = b.Domain
|
||||||
|
}
|
||||||
if b.EncryptKey != "" {
|
if b.EncryptKey != "" {
|
||||||
result.EncryptKey = b.EncryptKey
|
result.EncryptKey = b.EncryptKey
|
||||||
}
|
}
|
||||||
|
@ -156,6 +166,9 @@ func MergeConfig(a, b *Config) *Config {
|
||||||
if b.LogLevel != "" {
|
if b.LogLevel != "" {
|
||||||
result.LogLevel = b.LogLevel
|
result.LogLevel = b.LogLevel
|
||||||
}
|
}
|
||||||
|
if b.NodeName != "" {
|
||||||
|
result.NodeName = b.NodeName
|
||||||
|
}
|
||||||
if b.RPCAddr != "" {
|
if b.RPCAddr != "" {
|
||||||
result.RPCAddr = b.RPCAddr
|
result.RPCAddr = b.RPCAddr
|
||||||
}
|
}
|
||||||
|
@ -171,6 +184,9 @@ func MergeConfig(a, b *Config) *Config {
|
||||||
if b.ServerAddr != "" {
|
if b.ServerAddr != "" {
|
||||||
result.ServerAddr = b.ServerAddr
|
result.ServerAddr = b.ServerAddr
|
||||||
}
|
}
|
||||||
|
if b.AdvertiseAddr != "" {
|
||||||
|
result.AdvertiseAddr = b.AdvertiseAddr
|
||||||
|
}
|
||||||
if b.Server == true {
|
if b.Server == true {
|
||||||
result.Server = b.Server
|
result.Server = b.Server
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ type DNSServer struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDNSServer starts a new DNS server to provide an agent interface
|
// NewDNSServer starts a new DNS server to provide an agent interface
|
||||||
func NewDNSServer(agent *Agent, logOutput io.Writer, bind string) (*DNSServer, error) {
|
func NewDNSServer(agent *Agent, logOutput io.Writer, domain, bind string) (*DNSServer, error) {
|
||||||
// Construct the DNS components
|
// Construct the DNS components
|
||||||
mux := dns.NewServeMux()
|
mux := dns.NewServeMux()
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
func makeDNSServer(t *testing.T) (string, *DNSServer) {
|
func makeDNSServer(t *testing.T) (string, *DNSServer) {
|
||||||
conf := nextConfig()
|
conf := nextConfig()
|
||||||
dir, agent := makeAgent(t, conf)
|
dir, agent := makeAgent(t, conf)
|
||||||
server, err := NewDNSServer(agent, agent.logOutput, conf.DNSAddr)
|
server, err := NewDNSServer(agent, agent.logOutput, conf.Domain, conf.DNSAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue