Browse Source

Adding a DNS domain config

pull/19/head
Armon Dadgar 11 years ago
parent
commit
71e85cea72
  1. 16
      command/agent/config.go
  2. 2
      command/agent/dns.go
  3. 2
      command/agent/dns_test.go

16
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
}

2
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()

2
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)
}

Loading…
Cancel
Save