Correctly format ipv6 resolver config for lua

Fixes #3881
This commit is contained in:
Thomas Jackson 2019-03-09 16:39:25 -08:00
parent 2dbc1ea3b3
commit eba4a8b87c
2 changed files with 8 additions and 4 deletions

View file

@ -250,10 +250,14 @@ func buildResolversForLua(res interface{}, disableIpv6 interface{}) string {
r := []string{} r := []string{}
for _, ns := range nss { for _, ns := range nss {
if ing_net.IsIPV6(ns) && no6 { if ing_net.IsIPV6(ns) {
continue if no6 {
continue
}
r = append(r, fmt.Sprintf("\"[%v]\"", ns))
} else {
r = append(r, fmt.Sprintf("\"%v\"", ns))
} }
r = append(r, fmt.Sprintf("\"%v\"", ns))
} }
return strings.Join(r, ", ") return strings.Join(r, ", ")

View file

@ -516,7 +516,7 @@ func TestBuildResolversForLua(t *testing.T) {
t.Errorf("Expected '%v' but returned '%v'", expected, actual) t.Errorf("Expected '%v' but returned '%v'", expected, actual)
} }
expected = "\"192.0.0.1\", \"2001:db8:1234::\"" expected = "\"192.0.0.1\", \"[2001:db8:1234::]\""
actual = buildResolversForLua(ipList, false) actual = buildResolversForLua(ipList, false)
if expected != actual { if expected != actual {