Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression test for the issue fixed in #4543 #4548

Merged
merged 1 commit into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rootfs/etc/nginx/lua/test/util/resolv_conf_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ 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
]===]

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)
Expand Down
3 changes: 2 additions & 1 deletion rootfs/etc/nginx/lua/util/resolv_conf.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down