| author | |
| committer | |
| log | a0aba69c1143073aa06f19f759dabe4aa58454d1 |
| tree | 0ba99c424b8e9b441d0732d1c4a42029a2f33a44 |
| parent | 908970df1c9a509c73d24a566292db2fba049498 |
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( | ... | @@ -1401,9 +1401,9 @@ fn openSocketPosix( |
| 1401 | }; | 1401 | }; |
| 1402 | errdefer closeFd(socket_fd); | 1402 | errdefer closeFd(socket_fd); |
| 1403 | 1403 | ||
| 1404 | if (options.ip6_only) { | 1404 | if (options.ip6_only) |ip6_only| { |
| 1405 | if (posix.IPV6 == void) return error.OptionUnsupported; | 1405 | 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)); |
| 1407 | } | 1407 | } |
| 1408 | 1408 | ||
| 1409 | return socket_fd; | 1409 | return socket_fd; |
lib/std/Io/Threaded.zig+3-3| ... | @@ -12407,9 +12407,9 @@ fn openSocketPosix( | ... | @@ -12407,9 +12407,9 @@ fn openSocketPosix( |
| 12407 | }; | 12407 | }; |
| 12408 | errdefer closeFd(socket_fd); | 12408 | errdefer closeFd(socket_fd); |
| 12409 | 12409 | ||
| 12410 | if (options.ip6_only) { | 12410 | if (options.ip6_only) |ip6_only| { |
| 12411 | if (posix.IPV6 == void) return error.OptionUnsupported; | 12411 | 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)); |
| 12413 | } | 12413 | } |
| 12414 | 12414 | ||
| 12415 | return socket_fd; | 12415 | return socket_fd; |
| ... | @@ -14496,7 +14496,7 @@ fn lookupDns( | ... | @@ -14496,7 +14496,7 @@ fn lookupDns( |
| 14496 | var socket = s: { | 14496 | var socket = s: { |
| 14497 | if (any_ip6) ip6: { | 14497 | if (any_ip6) ip6: { |
| 14498 | const ip6_addr: IpAddress = .{ .ip6 = .unspecified(0) }; | 14498 | 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) { |
| 14500 | error.AddressFamilyUnsupported => break :ip6, | 14500 | error.AddressFamilyUnsupported => break :ip6, |
| 14501 | else => |e| return e, | 14501 | else => |e| return e, |
| 14502 | }; | 14502 | }; |
lib/std/Io/Uring.zig+2-2| ... | @@ -5984,9 +5984,9 @@ fn socket( | ... | @@ -5984,9 +5984,9 @@ fn socket( |
| 5984 | }; | 5984 | }; |
| 5985 | errdefer ev.closeAsync(socket_fd); | 5985 | errdefer ev.closeAsync(socket_fd); |
| 5986 | 5986 | ||
| 5987 | if (options.ip6_only) { | 5987 | if (options.ip6_only) |ip6_only| { |
| 5988 | if (linux.IPV6 == void) return error.OptionUnsupported; | 5988 | 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)); |
| 5990 | } | 5990 | } |
| 5991 | 5991 | ||
| 5992 | return socket_fd; | 5992 | return socket_fd; |
lib/std/Io/net.zig+3-1| ... | @@ -281,7 +281,9 @@ pub const IpAddress = union(enum) { | ... | @@ -281,7 +281,9 @@ pub const IpAddress = union(enum) { |
| 281 | /// The socket is restricted to sending and receiving IPv6 packets only. | 281 | /// The socket is restricted to sending and receiving IPv6 packets only. |
| 282 | /// In this case, an IPv4 and an IPv6 application can bind to a single port | 282 | /// In this case, an IPv4 and an IPv6 application can bind to a single port |
| 283 | /// at the same time. | 283 | /// at the same time. |
| 284 | ip6_only: bool = false, | 284 | /// |
| 285 | /// The default is determined by system configuration. | ||
| 286 | ip6_only: ?bool = null, | ||
| 285 | /// Allow the socket to send datagrams to broadcast addresses. | 287 | /// Allow the socket to send datagrams to broadcast addresses. |
| 286 | /// When not enabled any attempt to send datagrams to a broadcast address | 288 | /// When not enabled any attempt to send datagrams to a broadcast address |
| 287 | /// will fail with `error.AccessDenied` | 289 | /// will fail with `error.AccessDenied` |