File

net/resolvers/chain.lua @ 13076:f4e33d17eaa8

mod_tls: Drop request for client certificates on outgoing connections It is the other end who should request client certificates for these connections, we only need to send ours. Hopefully this was treated as a noop, so probably no harm in keeping it. But hey, spring cleaning? :)
author Kim Alvefur <zash@zash.se>
date Wed, 19 Apr 2023 11:14:11 +0200
parent 12204:7c397a49d163
line wrap: on
line source


local methods = {};
local resolver_mt = { __index = methods };

-- Find the next target to connect to, and
-- pass it to cb()
function methods:next(cb)
	if self.resolvers then
		if not self.resolver then
			if #self.resolvers == 0 then
				cb(nil);
				return;
			end
			local next_resolver = table.remove(self.resolvers, 1);
			self.resolver = next_resolver;
		end
		self.resolver:next(function (...)
			if self.resolver then
				self.last_error = self.resolver.last_error;
			end
			if ... == nil then
				self.resolver = nil;
				self:next(cb);
			else
				cb(...);
			end
		end);
		return;
	end
end

local function new(resolvers)
	return setmetatable({ resolvers = resolvers }, resolver_mt);
end

return {
	new = new;
};