diff options
author | Kim Alvefur <zash@zash.se> | 2020-02-16 23:48:31 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-02-16 23:48:31 +0100 |
commit | 2327c841256b8ccd83c9ef35b7a1151b46366b34 (patch) | |
tree | a3cec3cb565eeb266766b0905ae1943f7375722d /net/resolvers/service.lua | |
parent | 99e46313aa83db68f265aa4e5c07bbca4f1a60ed (diff) | |
download | prosody-2327c841256b8ccd83c9ef35b7a1151b46366b34.tar.gz prosody-2327c841256b8ccd83c9ef35b7a1151b46366b34.zip |
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.
Diffstat (limited to 'net/resolvers/service.lua')
-rw-r--r-- | net/resolvers/service.lua | 13 |
1 files changed, 8 insertions, 5 deletions
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(...); |