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 2022/11/18 02:58:53 UTC

[GitHub] [apisix] tzssangglass commented on a diff in pull request #8270: feat: add method that parse ip from /etc/hosts in high priority

tzssangglass commented on code in PR #8270:
URL: https://github.com/apache/apisix/pull/8270#discussion_r1025939255


##########
apisix/core/resolver.lua:
##########
@@ -19,15 +19,31 @@
 --
 -- @module core.resolver
 
-local json = require("apisix.core.json")
-local log = require("apisix.core.log")
-local utils = require("apisix.core.utils")
+local json           = require("apisix.core.json")
+local log            = require("apisix.core.log")
+local utils          = require("apisix.core.utils")
+local dns_utils      = require("resty.dns.utils")
+
+
+local HOSTS_IP_MATCH_CACHE = {}
 
 
 local _M = {}
 
 
+local function init_hosts_ip()
+    local hosts, err = dns_utils.parseHosts()
+    if not hosts then
+        return hosts, err
+    end
+    HOSTS_IP_MATCH_CACHE = hosts

Review Comment:
   When will `HOSTS_IP_MATCH_CACHE` be cleaned? APISIX will not update it after it is read at startup. Unless APISIX is restarted.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

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