diff --git a/command/agent/config.go b/command/agent/config.go index 9fc2619e8..3a926499f 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -97,6 +97,11 @@ type Config struct { // DataDir is the directory to store our state in DataDir string `mapstructure:"data_dir"` + // DNSRecursors can be set to allow the DNS servers to recursively + // resolve non-consul domains. It is deprecated, and merges into the + // recursors array. + DNSRecursor string `mapstructure:"recursor"` + // DNSRecursors can be set to allow the DNS servers to recursively // resolve non-consul domains DNSRecursors []string `mapstructure:"recursors"` @@ -500,6 +505,11 @@ func DecodeConfig(r io.Reader) (*Config, error) { result.RetryInterval = dur } + // Merge the single recursor + if result.DNSRecursor != "" { + result.DNSRecursors = append(result.DNSRecursors, result.DNSRecursor) + } + return &result, nil } diff --git a/command/agent/config_test.go b/command/agent/config_test.go index 0c09e02d4..77e67a172 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -109,7 +109,7 @@ func TestDecodeConfig(t *testing.T) { } // DNS setup - input = `{"ports": {"dns": 8500}, "recursor": ["8.8.8.8","8.8.4.4"], "domain": "foobar"}` + input = `{"ports": {"dns": 8500}, "recursors": ["8.8.8.8","8.8.4.4"], "recursor":"127.0.0.1", "domain": "foobar"}` config, err = DecodeConfig(bytes.NewReader([]byte(input))) if err != nil { t.Fatalf("err: %s", err) @@ -119,7 +119,7 @@ func TestDecodeConfig(t *testing.T) { t.Fatalf("bad: %#v", config) } - if len(config.DNSRecursors) != 2 { + if len(config.DNSRecursors) != 3 { t.Fatalf("bad: %#v", config) } if config.DNSRecursors[0] != "8.8.8.8" { @@ -128,6 +128,9 @@ func TestDecodeConfig(t *testing.T) { if config.DNSRecursors[1] != "8.8.4.4" { t.Fatalf("bad: %#v", config) } + if config.DNSRecursors[2] != "127.0.0.1" { + t.Fatalf("bad: %#v", config) + } if config.Domain != "foobar" { t.Fatalf("bad: %#v", config) diff --git a/website/source/docs/agent/http.html.markdown b/website/source/docs/agent/http.html.markdown index 1dc999eb1..96055c7c6 100644 --- a/website/source/docs/agent/http.html.markdown +++ b/website/source/docs/agent/http.html.markdown @@ -333,6 +333,7 @@ It returns a JSON body like this: "Server": true, "Datacenter": "dc1", "DataDir": "/tmp/consul", + "DNSRecursor": "", "DNSRecursors": [], "Domain": "consul.", "LogLevel": "INFO", diff --git a/website/source/docs/agent/options.html.markdown b/website/source/docs/agent/options.html.markdown index 5264900f3..dbbda8d33 100644 --- a/website/source/docs/agent/options.html.markdown +++ b/website/source/docs/agent/options.html.markdown @@ -321,6 +321,9 @@ definitions support being updated during a reload. * `protocol` - Equivalent to the `-protocol` command-line flag. +* `recursor` - Provides a single recursor address. This has been deprecated, and + the value is appended to the `recursors` list for backwards compatibility. + * `recursors` - This flag provides addresses of upstream DNS servers that are used to recursively resolve queries if they are not inside the service domain for consul. For example, a node can use Consul directly as a DNS server, and if the record is outside of the "consul." domain,