diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11aa72d..513677a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,4 +8,4 @@ jobs: steps: - uses: actions/checkout@v2 - name: Unit test - run: docker-compose up + run: docker compose up diff --git a/Dockerfile b/Dockerfile index 871691d..2972d0e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM openresty/openresty:stretch-fat +FROM openresty/openresty:bullseye-fat WORKDIR /app diff --git a/LICENSE b/LICENSE index 5c33706..25cafcf 100755 --- a/LICENSE +++ b/LICENSE @@ -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. \ No newline at end of file +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. diff --git a/README.markdown b/README.markdown index c0e5f77..c364e1a 100755 --- a/README.markdown +++ b/README.markdown @@ -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. @@ -352,4 +352,3 @@ See Also * the ngx_lua module: http://wiki.nginx.org/HttpLuaModule [Back to TOC](#table-of-contents) - diff --git a/docker-compose.yml b/docker-compose.yml index eda26fa..944a645 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.7" - services: lua-resty-resolver: build: @@ -7,4 +5,4 @@ services: volumes: - ".:/app" image: lua-resty-resolver:latest - command: make test \ No newline at end of file + command: make test diff --git a/lib/resolver/client.lua b/lib/resolver/client.lua index 9e95410..b0095c3 100755 --- a/lib/resolver/client.lua +++ b/lib/resolver/client.lua @@ -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 } @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/lib/resolver/master.lua b/lib/resolver/master.lua index 1698435..385dd9b 100755 --- a/lib/resolver/master.lua +++ b/lib/resolver/master.lua @@ -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 } @@ -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) diff --git a/lua-resty-resolver-0.05-1.rockspec b/lua-resty-resolver-0.06.rockspec similarity index 98% rename from lua-resty-resolver-0.05-1.rockspec rename to lua-resty-resolver-0.06.rockspec index 928df6b..f4dd2eb 100644 --- a/lua-resty-resolver-0.05-1.rockspec +++ b/lua-resty-resolver-0.06.rockspec @@ -1,5 +1,5 @@ package = "lua-resty-resolver" -version = "0.05-1" +version = "0.06" source = { url = "git://github.com/jkeys089/lua-resty-resolver", }