Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Unit test
run: docker-compose up
run: docker compose up
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openresty/openresty:stretch-fat
FROM openresty/openresty:bullseye-fat

WORKDIR /app

Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This module is licensed under the BSD license.
Copyright (C) 2012-2020, Thought Foundry Inc.
Copyright (C) 2012-2025, Thought Foundry Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3 changes: 1 addition & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ Copyright and License

This module is licensed under the BSD license.

Copyright (C) 2012-2020, Thought Foundry Inc.
Copyright (C) 2012-2025, Thought Foundry Inc.

All rights reserved.

Expand All @@ -352,4 +352,3 @@ See Also
* the ngx_lua module: http://wiki.nginx.org/HttpLuaModule

[Back to TOC](#table-of-contents)

4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
version: "3.7"

services:
lua-resty-resolver:
build:
context: .
volumes:
- ".:/app"
image: lua-resty-resolver:latest
command: make test
command: make test
14 changes: 7 additions & 7 deletions lib/resolver/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local ngx = require "ngx"
local setmetatable = setmetatable


local _M = { _VERSION = '0.05' }
local _M = { _VERSION = '0.06' }

local mt = { __index = _M }

Expand Down Expand Up @@ -30,7 +30,7 @@ local function sync(worker)
if exp then
if exp < next_sync then
next_sync = exp
end
end
hosts[#hosts+1] = {
address = k:sub(address_start),
exp = exp
Expand All @@ -40,7 +40,7 @@ local function sync(worker)
end

if #hosts > 0 then
if next_sync >= 1 then
if next_sync >= 1 then
next_sync = next_sync - 1
end
worker._hosts = hosts
Expand Down Expand Up @@ -85,7 +85,7 @@ function _M.get(self, exp_fallback_ok)
hosts = self._hosts
tot = #hosts
end

if tot < 1 then
return nil, "no hosts available"
end
Expand All @@ -94,7 +94,7 @@ function _M.get(self, exp_fallback_ok)
local idx = self._next_idx
local exp_idxs = {}
local cnt = 0

while not host and cnt < tot do
if idx > tot then
idx = 1
Expand All @@ -104,11 +104,11 @@ function _M.get(self, exp_fallback_ok)

if cur_host.exp > now then
host = cur_host
else
else
if not fallback_idx or cur_host.exp > hosts[fallback_idx].exp then
fallback_idx = idx
end

exp_idxs[#exp_idxs+1] = idx

idx = idx + 1
Expand Down
4 changes: 2 additions & 2 deletions lib/resolver/master.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local resolver = require "resty.dns.resolver"
local setmetatable = setmetatable


local _M = { _VERSION = '0.05' }
local _M = { _VERSION = '0.06' }

local mt = { __index = _M }

Expand Down Expand Up @@ -42,7 +42,7 @@ resolve = function(master)
while ns_cnt ~= 0 do
local tries = {}
answers, err = res:query(domain, master._qopts, tries)

for i, err in ipairs(tries) do
err = "resolver master failed to query DNS for domain '" .. domain .. "': " .. err
ngx.log(ngx.DEBUG, err)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package = "lua-resty-resolver"
version = "0.05-1"
version = "0.06"
source = {
url = "git://github.com/jkeys089/lua-resty-resolver",
}
Expand Down