Skip to content

Commit 6218598

Browse files
committed
http/client: If address family is specified don't add records of other families
1 parent b8dd999 commit 6218598

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

http/client.lua

+8-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ local AF_UNIX = cs.AF_UNIX
2222
local AF_INET = cs.AF_INET
2323
local AF_INET6 = cs.AF_INET6
2424

25+
local DNS_SECTION_ANSWER = cqueues_dns_record.ANSWER
2526
local DNS_CLASS_IN = cqueues_dns_record.IN
2627
local DNS_TYPE_A = cqueues_dns_record.A
2728
local DNS_TYPE_AAAA = cqueues_dns_record.AAAA
@@ -107,7 +108,7 @@ end
107108
local function each_matching_record(pkt, name, type)
108109
-- First need to do CNAME chasing
109110
local params = {
110-
section = "answer";
111+
section = DNS_SECTION_ANSWER;
111112
class = DNS_CLASS_IN;
112113
type = DNS_TYPE_CNAME;
113114
name = name .. ".";
@@ -239,13 +240,17 @@ local function lookup_records(options, timeout)
239240

240241
local ipv4 = IPv4address:match(host)
241242
if ipv4 then
242-
records:add_v4(host, port)
243+
if family == AF_UNSPEC or family == AF_INET then
244+
records:add_v4(host, port)
245+
end
243246
return records
244247
end
245248

246249
local ipv6 = IPv6addrz:match(host)
247250
if ipv6 then
248-
records:add_v6(ipv6, port)
251+
if family == AF_UNSPEC or family == AF_INET6 then
252+
records:add_v6(ipv6, port)
253+
end
249254
return records
250255
end
251256

0 commit comments

Comments
 (0)