net/resolvers/manual.lua
author Matthew Wild <mwild1@gmail.com>
Sun, 17 Mar 2024 10:10:24 +0000
changeset 13464 a688947fab1e
parent 12593 39ae08180c81
permissions -rw-r--r--
mod_bosh: Set base_type on session This fixes a traceback with mod_saslauth. Ideally we move this to util.session at some point, though.

local methods = {};
local resolver_mt = { __index = methods };
local unpack = table.unpack;

-- Find the next target to connect to, and
-- pass it to cb()
function methods:next(cb)
	if #self.targets == 0 then
		cb(nil);
		return;
	end
	local next_target = table.remove(self.targets, 1);
	cb(unpack(next_target, 1, 4));
end

local function new(targets, conn_type, extra)
	return setmetatable({
		conn_type = conn_type;
		extra = extra;
		targets = targets or {};
	}, resolver_mt);
end

return {
	new = new;
};