Skip to content

Commit

Permalink
[revert] temporarily skip empty dns search scope
Browse files Browse the repository at this point in the history
  • Loading branch information
mikz committed Sep 12, 2017
1 parent d2568e0 commit acbb59e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion apicast/.s2i/bin/run
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fi

dnsmasq --listen-address=127.0.0.1 --port=5353 \
--all-servers --no-host --no-hosts \
--cache-size=1000 --no-negcache \
--cache-size=1000 --no-negcache --domain-needed \
--server="${RESOLVER:-}" \
--log-facility=- ${DNSMASQ_OPTIONS:-} \

Expand Down
32 changes: 22 additions & 10 deletions apicast/src/resty/resolver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ local default_resolver_port = 53
local _M = {
_VERSION = '0.1',
_nameservers = {},
search = { '' }
search = { }
}

local mt = { __index = _M }
Expand Down Expand Up @@ -234,17 +234,29 @@ local function search_dns(self, qname, stale)

local answers, err

for i=1, #search do
local query = qname .. '.' .. search[i]
ngx.log(ngx.DEBUG, 'resolver query: ', qname, ' search: ', search[i], ' query: ', query)
if is_fqdn(qname) then
answers, err = cache:get(qname, stale)
if not valid_answers(answers) then
answers, err = dns:query(qname, options)

if valid_answers(answers) then
cache:save(answers)
end
end
else
for i=1, #search do
local query = qname .. '.' .. search[i]
ngx.log(ngx.DEBUG, 'resolver query: ', qname, ' search: ', search[i], ' query: ', query)

answers, err = cache:get(query, stale)
if valid_answers(answers) then break end

answers, err = cache:get(query, stale)
if valid_answers(answers) then break end
answers, err = dns:query(query, options)

answers, err = dns:query(query, options)
if valid_answers(answers) then
cache:save(answers)
break
if valid_answers(answers) then
cache:save(answers)
break
end
end
end

Expand Down

0 comments on commit acbb59e

Please sign in to comment.