File

net/resolvers/manual.lua @ 13497:da9be0ad4bbc 0.12

net.server_event: Add 'wrapserver' API This enables accepting admin stream socket (UNIX) connections trough the same procedures as any other (TCP) socket, which avoids problems caused by using the wrapclient API, which ends up discarding early data due to only expecting early connection failure. Fixes #1867
author Kim Alvefur <zash@zash.se>
date Sun, 07 Jul 2024 18:28:17 +0200 (8 months ago)
parent 9691:e11e076f0eb8
child 12589:39ae08180c81
line wrap: on
line source
local methods = {};
local resolver_mt = { __index = methods };
local unpack = table.unpack or unpack; -- luacheck: ignore 113

-- 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;
};