comparison net/resolvers/basic.lua @ 13901:cc406878209d

net.resolvers.basic: Allow a filter callback to eliminate potential targets
author Matthew Wild <mwild1@gmail.com>
date Thu, 26 Jun 2025 13:02:34 +0100
parents ba409c67353b
children bc33a7269f5a
comparison
equal deleted inserted replaced
13900:d7e907830260 13901:cc406878209d
64 if #self.targets == 0 then 64 if #self.targets == 0 then
65 cb(nil); 65 cb(nil);
66 return; 66 return;
67 end 67 end
68 local next_target = table.remove(self.targets, 1); 68 local next_target = table.remove(self.targets, 1);
69 if self.filter and not self.filter(next_target[1], next_target[2], next_target[3], next_target[4], not not self.targets[1]) then
70 return self:next(cb);
71 end
69 cb(next_target[1], next_target[2], next_target[3], next_target[4], not not self.targets[1]); 72 cb(next_target[1], next_target[2], next_target[3], next_target[4], not not self.targets[1]);
70 return; 73 return;
71 end 74 end
72 75
73 if not self.hostname then 76 if not self.hostname then
140 return setmetatable({ 143 return setmetatable({
141 hostname = ascii_host; 144 hostname = ascii_host;
142 port = port; 145 port = port;
143 conn_type = conn_type; 146 conn_type = conn_type;
144 extra = extra or {}; 147 extra = extra or {};
148 filter = extra and extra.filter;
145 targets = targets; 149 targets = targets;
146 }, resolver_mt); 150 }, resolver_mt);
147 end 151 end
148 152
149 return { 153 return {