# HG changeset patch # User Matthew Wild # Date 1647619826 0 # Node ID 9f0baf15e7920a11d6d93f470cd512b879a65d16 # Parent acfc51b9530cbd812ba7780eb562e541e3eda23d net.resolvers.basic: Alternate IP address family targets, per RFC 8305 diff -r acfc51b9530c -r 9f0baf15e792 net/resolvers/basic.lua --- a/net/resolvers/basic.lua Fri Mar 18 16:09:22 2022 +0000 +++ b/net/resolvers/basic.lua Fri Mar 18 16:10:26 2022 +0000 @@ -42,8 +42,16 @@ local function merge_targets(ipv4_targets, ipv6_targets) local result = { secure = ipv4_targets.secure and ipv6_targets.secure }; - t_move(ipv6_targets, 1, #ipv6_targets, 1, result); - t_move(ipv4_targets, 1, #ipv4_targets, #result+1, result); + local common_length = math.min(#ipv4_targets, #ipv6_targets); + for i = 1, common_length do + table.insert(result, ipv6_targets[i]); + table.insert(result, ipv4_targets[i]); + end + if common_length < #ipv4_targets then + t_move(ipv4_targets, common_length+1, #ipv4_targets, common_length+1, result); + elseif common_length < #ipv6_targets then + t_move(ipv6_targets, common_length+1, #ipv6_targets, common_length+1, result); + end return result; end