v icon indicating copy to clipboard operation
v copied to clipboard

vlib: fix tcp_test.v

Open hholst80 opened this issue 1 year ago • 6 comments

The listen_tcp method should not accept .unix address family.

Test that it indeed fails when invoked.

Also, remove the flaky flag on tcp_test.v as none of the tests here has any real reason to be flaky.

Tested on Linux 6.6 (amd64) and FreeBSD 13.2 (amd64).

hholst80 avatar Jan 04 '24 19:01 hholst80

Panics on Windows... maybe part of why it was marked flaky...

JalonSolov avatar Jan 04 '24 22:01 JalonSolov

0.0.0.0:45123: net: op timed out; code: 9

Why is it trying to dial to an ipv4 address when an ipv6 address is given? Seems like a bug in the address resolve code to me

Casper64 avatar Jan 04 '24 23:01 Casper64

0.0.0.0:45123: net: op timed out; code: 9

Why is it trying to dial to an ipv4 address when an ipv6 address is given? Seems like a bug in the address resolve code to me

I found some funky looking code in tcp.c.v that I removed. It was responsible for replacing ::: with localhost which resolved to an IP4 address. Having a generic resolve which magically figures out the address family is probably not very safe, but yet common. I've ran into a similar issue with Node.js too.

hholst80 avatar Jan 04 '24 23:01 hholst80

OK. That leads into a rabbit hole. What does not work on Windows is to open a connection to 0.0.0.0. That is only a valid IP address to bind to for accept. If we know for sure that the server is listening on all devices on a specific port, then we know for sure that it is listening on 127.0.0.1 (within reason). The fix should be to not use ${server.addr} but 127.0.0.1 in the fetch in server_test.v:

image

hholst80 avatar Jan 05 '24 00:01 hholst80

The failing Docker tests were really good! It showed me that the tcp_test.v IPv6 tests actually uses IPv6 now. ;-)

(The reason why I did not catch it myself first, was because I have a habit of using --network=host and there I have IPv6.)

I want to disable to IPv6 tests on environments where there is known not to exist IPv6 stack, or validate that the test fails. Any ideas on how to do that? I know this PR is getting out of hand but first I will fix it then I will chop it up into reasonable commit.

hholst80 avatar Jan 06 '24 00:01 hholst80

This also seems related with this: https://github.com/vlang/v/issues/20441

esquerbatua avatar Jan 13 '24 15:01 esquerbatua