From 71e85cea728010f64d92dc6b95c8e39f0c4f3739 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Thu, 2 Jan 2014 15:50:52 -0800 Subject: [PATCH] Adding a DNS domain config --- command/agent/config.go | 16 ++++++++++++++++ command/agent/dns.go | 2 +- command/agent/dns_test.go | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/command/agent/config.go b/command/agent/config.go index 557ea19926..08c16e27f5 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -30,6 +30,9 @@ type Config struct { // DNSAddr is the address of the DNS server for the agent DNSAddr string + // Domain is the DNS domain for the records. Defaults to "consul." + Domain string + // Encryption key to use for the Serf communication EncryptKey string @@ -91,6 +94,7 @@ func DefaultConfig() *Config { return &Config{ Datacenter: consul.DefaultDC, DNSAddr: "127.0.0.1:8600", + Domain: "consul.", HTTPAddr: "127.0.0.1:8500", LogLevel: "INFO", RPCAddr: "127.0.0.1:8400", @@ -147,6 +151,12 @@ func MergeConfig(a, b *Config) *Config { if b.DataDir != "" { result.DataDir = b.DataDir } + if b.DNSAddr != "" { + result.DNSAddr = b.DNSAddr + } + if b.Domain != "" { + result.Domain = b.Domain + } if b.EncryptKey != "" { result.EncryptKey = b.EncryptKey } @@ -156,6 +166,9 @@ func MergeConfig(a, b *Config) *Config { if b.LogLevel != "" { result.LogLevel = b.LogLevel } + if b.NodeName != "" { + result.NodeName = b.NodeName + } if b.RPCAddr != "" { result.RPCAddr = b.RPCAddr } @@ -171,6 +184,9 @@ func MergeConfig(a, b *Config) *Config { if b.ServerAddr != "" { result.ServerAddr = b.ServerAddr } + if b.AdvertiseAddr != "" { + result.AdvertiseAddr = b.AdvertiseAddr + } if b.Server == true { result.Server = b.Server } diff --git a/command/agent/dns.go b/command/agent/dns.go index d55b6aaf7e..44eac097a5 100644 --- a/command/agent/dns.go +++ b/command/agent/dns.go @@ -18,7 +18,7 @@ type DNSServer struct { } // 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 mux := dns.NewServeMux() diff --git a/command/agent/dns_test.go b/command/agent/dns_test.go index 6c66ba680e..c0892a4728 100644 --- a/command/agent/dns_test.go +++ b/command/agent/dns_test.go @@ -9,7 +9,7 @@ import ( func makeDNSServer(t *testing.T) (string, *DNSServer) { conf := nextConfig() 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 { t.Fatalf("err: %v", err) }