mirror of
https://gitee.com/iresty/apisix.git
synced 2024-12-04 13:07:34 +08:00
fix: init dns resolvers in stream subsystem (#4186)
This commit is contained in:
parent
17ae333df4
commit
f7460eeee3
@ -85,7 +85,11 @@ stream {
|
||||
init_by_lua_block {
|
||||
require "resty.core"
|
||||
apisix = require("apisix")
|
||||
apisix.stream_init()
|
||||
local dns_resolver = { {% for _, dns_addr in ipairs(dns_resolver or {}) do %} "{*dns_addr*}", {% end %} }
|
||||
local args = {
|
||||
dns_resolver = dns_resolver,
|
||||
}
|
||||
apisix.stream_init(args)
|
||||
}
|
||||
|
||||
init_worker_by_lua_block {
|
||||
|
@ -715,9 +715,11 @@ function _M.http_control()
|
||||
end
|
||||
|
||||
|
||||
function _M.stream_init()
|
||||
function _M.stream_init(args)
|
||||
core.log.info("enter stream_init")
|
||||
|
||||
core.resolver.init_resolver(args)
|
||||
|
||||
if core.config.init then
|
||||
local ok, err = core.config.init()
|
||||
if not ok then
|
||||
|
@ -263,7 +263,10 @@ _EOC_
|
||||
require "resty.core"
|
||||
|
||||
apisix = require("apisix")
|
||||
apisix.stream_init()
|
||||
local args = {
|
||||
dns_resolver = $dns_addrs_tbl_str,
|
||||
}
|
||||
apisix.stream_init(args)
|
||||
_EOC_
|
||||
|
||||
$stream_config .= <<_EOC_;
|
||||
|
33
t/misc/patch.t
vendored
33
t/misc/patch.t
vendored
@ -151,3 +151,36 @@ apisix:
|
||||
GET /t
|
||||
--- response_body
|
||||
301
|
||||
|
||||
|
||||
|
||||
=== TEST 5: resolve host by ourselves (in stream sub-system)
|
||||
--- yaml_config
|
||||
apisix:
|
||||
node_listen: 1984
|
||||
enable_resolv_search_opt: true
|
||||
--- stream_enable
|
||||
--- stream_server_config
|
||||
content_by_lua_block {
|
||||
local sock = ngx.req.socket(true)
|
||||
-- drain the buffer
|
||||
local _, err = sock:receive(1)
|
||||
if err ~= nil then
|
||||
ngx.log(ngx.ERR, err)
|
||||
return ngx.exit(-1)
|
||||
end
|
||||
local http = require("resty.http")
|
||||
local httpc = http.new()
|
||||
local res, err = httpc:request_uri("http://apisix")
|
||||
if not res then
|
||||
ngx.log(ngx.ERR, err)
|
||||
return ngx.exit(-1)
|
||||
end
|
||||
sock:send(res.status)
|
||||
}
|
||||
--- stream_request eval
|
||||
m
|
||||
--- stream_response: 301
|
||||
|
||||
--- no_error_log
|
||||
[error]
|
||||
|
Loading…
Reference in New Issue
Block a user