authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-27 16:36:12-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-27 16:36:12-07:00
loga0aba69c1143073aa06f19f759dabe4aa58454d1
tree0ba99c424b8e9b441d0732d1c4a42029a2f33a44
parent908970df1c9a509c73d24a566292db2fba049498

std.Io: fix DNS lookup

The DNS lookup code incorrectly passed ip6_only=true when it intended to pass ip6_only=false. The other bug fix in be7065f7f541f3eb1dcb64869ef1fed716645cd1 revealed this additional bug.

4 files changed, 10 insertions(+), 8 deletions(-)

lib/std/Io/Kqueue.zig+2-2
......@@ -1401,9 +1401,9 @@ fn openSocketPosix(
14011401 };
14021402 errdefer closeFd(socket_fd);
14031403
1404 if (options.ip6_only) {
1404 if (options.ip6_only) |ip6_only| {
14051405 if (posix.IPV6 == void) return error.OptionUnsupported;
1406 try setSocketOption(k, socket_fd, posix.IPPROTO.IPV6, posix.IPV6.V6ONLY, 1);
1406 try setSocketOption(k, socket_fd, posix.IPPROTO.IPV6, posix.IPV6.V6ONLY, @intFromBool(ip6_only));
14071407 }
14081408
14091409 return socket_fd;
lib/std/Io/Threaded.zig+3-3
......@@ -12407,9 +12407,9 @@ fn openSocketPosix(
1240712407 };
1240812408 errdefer closeFd(socket_fd);
1240912409
12410 if (options.ip6_only) {
12410 if (options.ip6_only) |ip6_only| {
1241112411 if (posix.IPV6 == void) return error.OptionUnsupported;
12412 try setSocketOptionPosix(socket_fd, posix.IPPROTO.IPV6, posix.IPV6.V6ONLY, 1);
12412 try setSocketOptionPosix(socket_fd, posix.IPPROTO.IPV6, posix.IPV6.V6ONLY, @intFromBool(ip6_only));
1241312413 }
1241412414
1241512415 return socket_fd;
......@@ -14496,7 +14496,7 @@ fn lookupDns(
1449614496 var socket = s: {
1449714497 if (any_ip6) ip6: {
1449814498 const ip6_addr: IpAddress = .{ .ip6 = .unspecified(0) };
14499 const socket = ip6_addr.bind(t_io, .{ .ip6_only = true, .mode = .dgram }) catch |err| switch (err) {
14499 const socket = ip6_addr.bind(t_io, .{ .ip6_only = false, .mode = .dgram }) catch |err| switch (err) {
1450014500 error.AddressFamilyUnsupported => break :ip6,
1450114501 else => |e| return e,
1450214502 };
lib/std/Io/Uring.zig+2-2
......@@ -5984,9 +5984,9 @@ fn socket(
59845984 };
59855985 errdefer ev.closeAsync(socket_fd);
59865986
5987 if (options.ip6_only) {
5987 if (options.ip6_only) |ip6_only| {
59885988 if (linux.IPV6 == void) return error.OptionUnsupported;
5989 try ev.setsockopt(cancel_region, socket_fd, linux.IPPROTO.IPV6, linux.IPV6.V6ONLY, 1);
5989 try ev.setsockopt(cancel_region, socket_fd, linux.IPPROTO.IPV6, linux.IPV6.V6ONLY, @intFromBool(ip6_only));
59905990 }
59915991
59925992 return socket_fd;
lib/std/Io/net.zig+3-1
......@@ -281,7 +281,9 @@ pub const IpAddress = union(enum) {
281281 /// The socket is restricted to sending and receiving IPv6 packets only.
282282 /// In this case, an IPv4 and an IPv6 application can bind to a single port
283283 /// at the same time.
284 ip6_only: bool = false,
284 ///
285 /// The default is determined by system configuration.
286 ip6_only: ?bool = null,
285287 /// Allow the socket to send datagrams to broadcast addresses.
286288 /// When not enabled any attempt to send datagrams to a broadcast address
287289 /// will fail with `error.AccessDenied`