Changeset

10650:324a0c7d1c6a

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.
author Kim Alvefur <zash@zash.se>
date Sun, 16 Feb 2020 23:48:31 +0100
parents 10649:228277be4a28
children 10651:1196f1e8d178
files net/resolvers/service.lua
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/net/resolvers/service.lua	Sat Feb 15 16:43:18 2020 +0100
+++ b/net/resolvers/service.lua	Sun Feb 16 23:48:31 2020 +0100
@@ -14,14 +14,17 @@
 -- 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(...);