mirror of https://github.com/slackhq/nebula.git
Allow `::` in lighthouse.dns.host config (#1115)
This commit is contained in:
parent
c1711bc9c5
commit
a5a07cc760
|
@ -129,7 +129,12 @@ func dnsMain(l *logrus.Logger, hostMap *HostMap, c *config.C) func() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDnsServerAddr(c *config.C) string {
|
func getDnsServerAddr(c *config.C) string {
|
||||||
return c.GetString("lighthouse.dns.host", "") + ":" + strconv.Itoa(c.GetInt("lighthouse.dns.port", 53))
|
dnsHost := strings.TrimSpace(c.GetString("lighthouse.dns.host", ""))
|
||||||
|
// Old guidance was to provide the literal `[::]` in `lighthouse.dns.host` but that won't resolve.
|
||||||
|
if dnsHost == "[::]" {
|
||||||
|
dnsHost = "::"
|
||||||
|
}
|
||||||
|
return net.JoinHostPort(dnsHost, strconv.Itoa(c.GetInt("lighthouse.dns.port", 53)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func startDns(l *logrus.Logger, c *config.C) {
|
func startDns(l *logrus.Logger, c *config.C) {
|
||||||
|
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
|
"github.com/slackhq/nebula/config"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParsequery(t *testing.T) {
|
func TestParsequery(t *testing.T) {
|
||||||
|
@ -17,3 +19,40 @@ func TestParsequery(t *testing.T) {
|
||||||
|
|
||||||
//parseQuery(m)
|
//parseQuery(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_getDnsServerAddr(t *testing.T) {
|
||||||
|
c := config.NewC(nil)
|
||||||
|
|
||||||
|
c.Settings["lighthouse"] = map[interface{}]interface{}{
|
||||||
|
"dns": map[interface{}]interface{}{
|
||||||
|
"host": "0.0.0.0",
|
||||||
|
"port": "1",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
assert.Equal(t, "0.0.0.0:1", getDnsServerAddr(c))
|
||||||
|
|
||||||
|
c.Settings["lighthouse"] = map[interface{}]interface{}{
|
||||||
|
"dns": map[interface{}]interface{}{
|
||||||
|
"host": "::",
|
||||||
|
"port": "1",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
assert.Equal(t, "[::]:1", getDnsServerAddr(c))
|
||||||
|
|
||||||
|
c.Settings["lighthouse"] = map[interface{}]interface{}{
|
||||||
|
"dns": map[interface{}]interface{}{
|
||||||
|
"host": "[::]",
|
||||||
|
"port": "1",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
assert.Equal(t, "[::]:1", getDnsServerAddr(c))
|
||||||
|
|
||||||
|
// Make sure whitespace doesn't mess us up
|
||||||
|
c.Settings["lighthouse"] = map[interface{}]interface{}{
|
||||||
|
"dns": map[interface{}]interface{}{
|
||||||
|
"host": "[::] ",
|
||||||
|
"port": "1",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
assert.Equal(t, "[::]:1", getDnsServerAddr(c))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue