From bbcf3dc625448f1534b50a590a5f6b2a40aacfde Mon Sep 17 00:00:00 2001 From: Elvin Efendi Date: Tue, 10 Sep 2019 10:00:21 -0400 Subject: [PATCH] regression test for the issue fixed in #4543 --- rootfs/etc/nginx/lua/test/util/resolv_conf_test.lua | 3 ++- rootfs/etc/nginx/lua/util/resolv_conf.lua | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rootfs/etc/nginx/lua/test/util/resolv_conf_test.lua b/rootfs/etc/nginx/lua/test/util/resolv_conf_test.lua index b8c706d1b2..b700d4754d 100644 --- a/rootfs/etc/nginx/lua/test/util/resolv_conf_test.lua +++ b/rootfs/etc/nginx/lua/test/util/resolv_conf_test.lua @@ -30,6 +30,7 @@ describe("resolv_conf", function() # This is a comment nameserver 10.96.0.10 nameserver 10.96.0.99 +nameserver 2001:4860:4860::8888 search ingress-nginx.svc.cluster.local svc.cluster.local cluster.local options ndots:5 ]===] @@ -37,7 +38,7 @@ options ndots:5 helpers.with_resolv_conf(conf, function() local resolv_conf = require("util.resolv_conf") assert.are.same({ - nameservers = { "10.96.0.10", "10.96.0.99" }, + nameservers = { "10.96.0.10", "10.96.0.99", "[2001:4860:4860::8888]" }, search = { "ingress-nginx.svc.cluster.local", "svc.cluster.local", "cluster.local" }, ndots = 5, }, resolv_conf) diff --git a/rootfs/etc/nginx/lua/util/resolv_conf.lua b/rootfs/etc/nginx/lua/util/resolv_conf.lua index 9dd015d435..82cd1d83bb 100644 --- a/rootfs/etc/nginx/lua/util/resolv_conf.lua +++ b/rootfs/etc/nginx/lua/util/resolv_conf.lua @@ -1,4 +1,5 @@ local ngx_re_split = require("ngx.re").split +local string_format = string.format local ngx_log = ngx.log local ngx_ERR = ngx.ERR @@ -52,7 +53,7 @@ local function parse_line(line) if keyword == "nameserver" then if not value:match("^%d+.%d+.%d+.%d+$") then - value = string.format("[%s]", value) + value = string_format("[%s]", value) end nameservers[#nameservers + 1] = value elseif keyword == "search" then