From dce92c437ae10cc79abacc7960482065299fd230 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 16 Feb 2020 23:48:31 +0100 Subject: net.resolvers.service: Fix resolving of targets with multiple IPs Each basic resolver was only used once and not kept around to try any IP addresses but the first one found. --- net/resolvers/service.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'net') diff --git a/net/resolvers/service.lua b/net/resolvers/service.lua index b4300d08..f74338db 100644 --- a/net/resolvers/service.lua +++ b/net/resolvers/service.lua @@ -14,14 +14,17 @@ local resolver_mt = { __index = methods }; -- pass it to cb() function methods:next(cb) if self.targets then - if #self.targets == 0 then - cb(nil); - return; + if not self.resolver then + if #self.targets == 0 then + cb(nil); + return; + end + local next_target = table.remove(self.targets, 1); + self.resolver = basic.new(unpack(next_target, 1, 4)); end - local next_target = table.remove(self.targets, 1); - self.resolver = basic.new(unpack(next_target, 1, 4)); self.resolver:next(function (...) if ... == nil then + self.resolver = nil; self:next(cb); else cb(...); -- cgit v1.2.3