Closed Blacksmoke16 closed 3 days ago
Some networking specs do https://github.com/crystal-lang/crystal/blob/9df6760292f525d4a35c243f1d76e7ab534cec44/spec/std/openssl/ssl/server_spec.cr#L14 which ends up using "::"
as the host. These specs ultimately fail when IPv6 is disabled. Is there any meaningful difference between "::"
and "0.0.0.0"
in this context? Was thinking we could update these usages to use the IPv4 variant to avoid needing extra IPv6 checks.
Yes ::
binds to ipv6 and ipv4, while 0.0.0.0
only binds to ipv4.
We want the former behavior by default, not the latter.
I'm wondering in which context is ipv6 disabled? I mean, we're in 2024.
We want the former behavior by default, not the latter.
Yea that makes sense in the real code, but to be clear I was more so proposing just changing it in these specs. E.g.
it "don't sync_close" do
TCPServer.open(0) do |tcp_server|
context = OpenSSL::SSL::Context::Server.new
ssl_server = OpenSSL::SSL::Server.new(tcp_server, context, sync_close: false)
ssl_server.context.should eq context
ssl_server.close
tcp_server.closed?.should be_false
end
end
Does it really matter if we bind an IPv6 vs IPv4 in this context?
It appears the behaviour of ::
can vary, as previously mentioned in https://github.com/crystal-lang/crystal/pull/6711#issuecomment-421030196.
I suppose this might be the case in @Blacksmoke16's environment that ::
does not include ipv4 as well and thus the bind fails with ipv6 disabled?
Anyway, I'm wondering if using an unspecified address is even good in the first place. Shouldn't these servers bind to loopback instead?
At some point in the past while debugging something else, I ended up adding the
ipv6.disable=1
kernel parameter. This seems to break the compiler and stdlib specs due to:We are checking if IPv6 is enabled via
SocketSpecHelper.supports_ipv6?
, but we're only catchingSocket::BindError
whereas the error raised here is aSocket::Error
. Will also need to addressunused_local_port
always using IPv6 as well.