You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/10/15 08:08:54 UTC

[GitHub] [apisix] membphis commented on a change in pull request #2424: feat: In dns parse, when the parameter `resolvers` is empty, the local dns is used as `resolvers` by default

membphis commented on a change in pull request #2424:
URL: https://github.com/apache/apisix/pull/2424#discussion_r505310823



##########
File path: apisix/core/utils.lua
##########
@@ -100,11 +101,16 @@ local function dns_parse(resolvers, domain)
         return nil, "unsupport DNS answer"
     end
 
-    return dns_parse(resolvers, answer.cname)
+    return dns_parse(answer.cname, resolvers)

Review comment:
       I think we can remove the argument `resolvers` here

##########
File path: t/core/utils.t
##########
@@ -68,3 +68,50 @@ qr/random seed \d+\ntwice: false/
 GET /t
 --- no_error_log
 [error]
+
+
+
+=== TEST 3: resolvers is not empty

Review comment:
       bad title

##########
File path: t/core/utils.t
##########
@@ -68,3 +68,50 @@ qr/random seed \d+\ntwice: false/
 GET /t
 --- no_error_log
 [error]
+
+
+
+=== TEST 3: resolvers is not empty
+--- config
+    location /t {
+        content_by_lua_block {
+            local core = require("apisix.core")
+            local resolvers = {"8.8.8.8"}
+            core.utils.set_resolver(resolvers)
+            local ip_info, err = core.utils.dns_parse("baidu.com", resolvers)
+            if not ip_info then
+                core.log.error("failed to parse domain: ", host, ", error: ",err)
+            end
+            ngx.say(core.json.encode(ip_info))
+        }
+    }
+--- request
+GET /t
+--- response_body eval
+qr/"address":.+,"name":"baidu.com"/
+--- no_error_log
+[error]
+--- LAST
+
+
+=== TEST 4: resolvers is empty

Review comment:
       bad title

##########
File path: t/core/utils.t
##########
@@ -68,3 +68,50 @@ qr/random seed \d+\ntwice: false/
 GET /t
 --- no_error_log
 [error]
+
+
+
+=== TEST 3: resolvers is not empty
+--- config
+    location /t {
+        content_by_lua_block {
+            local core = require("apisix.core")
+            local resolvers = {"8.8.8.8"}
+            core.utils.set_resolver(resolvers)
+            local ip_info, err = core.utils.dns_parse("baidu.com", resolvers)

Review comment:
       please change it to `github.com`

##########
File path: apisix/init.lua
##########
@@ -177,7 +178,7 @@ end
 
 
 local function parse_domain(host)
-    local ip_info, err = core.utils.dns_parse(dns_resolver, host)
+    local ip_info, err = core.utils.dns_parse(host, dns_resolver)

Review comment:
       ditto




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org