From 3f66fab63ecffa7bf4d5bdb02ce8a688a4285709 Mon Sep 17 00:00:00 2001 From: seven dickens Date: Wed, 5 Jan 2022 09:32:13 +0800 Subject: [PATCH] fix: resolve unambiguous fully-qualified domain name(FQDN), i.e. ended in a dot (#5999) --- rockspec/apisix-master-0.rockspec | 2 +- t/node/upstream-domain.t | 48 +++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/rockspec/apisix-master-0.rockspec b/rockspec/apisix-master-0.rockspec index 883cd42f..6e391d0f 100644 --- a/rockspec/apisix-master-0.rockspec +++ b/rockspec/apisix-master-0.rockspec @@ -32,7 +32,7 @@ description = { dependencies = { "lua-resty-ctxdump = 0.1-0", - "lua-resty-dns-client = 5.2.0", + "lua-resty-dns-client = 5.2.3", "lua-resty-template = 2.0", "lua-resty-etcd = 1.6.0", "api7-lua-resty-http = 0.2.0", diff --git a/t/node/upstream-domain.t b/t/node/upstream-domain.t index 63069fda..2cf71dd8 100644 --- a/t/node/upstream-domain.t +++ b/t/node/upstream-domain.t @@ -399,3 +399,51 @@ GET /t 1980, 1981, 1981 --- no_error_log [error] + + + +=== TEST 15: set route(with upstream) +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + local code, body = t('/apisix/admin/routes/1', + ngx.HTTP_PUT, + [[{ + "uri": "/hello", + "upstream": { + "nodes": { + "foo.com.": 0, + "127.0.0.1:1980": 1 + }, + "type": "roundrobin", + "desc": "new upstream" + }, + "service_id": "1" + }]] + ) + + if code >= 300 then + ngx.status = code + end + ngx.say(body) + } + } +--- request +GET /t +--- response_body +passed +--- no_error_log +[error] + + + +=== TEST 16: hit routes, parse the domain of upstream node +--- request +GET /hello +--- response_body +hello world +--- error_log eval +qr/dns resolver domain: foo.com. to \d+.\d+.\d+.\d+/ +--- no_error_log +[error]