Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
feat(client) honor resolv.conf option rotate
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske committed Feb 14, 2021
1 parent 13f1442 commit 8c8718b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/resty/dns/client.lua
Expand Up @@ -417,6 +417,11 @@ local poolMaxRetry
-- -- `resolv.conf` or otherwise set to 1
-- local ndots = 1
--
-- -- `no_random`, if set disables randomly picking the first nameserver, if not
-- -- given it is taken from `resolv.conf` option `rotate` (inverted).
-- -- Defaults to `true`.
-- local no_random = true
--
-- -- `search`, same as the `resolv.conf` option, if not given it is taken from
-- -- `resolv.conf`, or set to the `domain` option, or no search is performed
-- local search = {
Expand All @@ -434,6 +439,7 @@ local poolMaxRetry
-- hosts = hosts,
-- resolvConf = resolvConf,
-- ndots = ndots,
-- no_random = no_random,
-- search = search,
-- order = order,
-- badTtl = badTtl,
Expand Down Expand Up @@ -583,6 +589,13 @@ _M.init = function(options)
options.retrans = options.retrans or resolv.options.attempts or 5 -- 5 is openresty default
log(DEBUG, PREFIX, "attempts = ", options.retrans)
if options.no_random == nil then
options.no_random = not resolv.options.rotate
else
options.no_random = not not options.no_random -- force to boolean
end
log(DEBUG, PREFIX, "no_random = ", options.no_random)
if not options.timeout then
if resolv.options.timeout then
options.timeout = resolv.options.timeout * 1000
Expand Down

0 comments on commit 8c8718b

Please sign in to comment.