From a189d7f8e8300f7fd999384769952e0ed5f02df4 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 31 Oct 2024 18:22:25 +0200 Subject: [PATCH] net: fix resolving of `::1:48872` (pass the `*should_listen_on_both_ipv4_and_ipv6_by_default_test.v` tests) (#22715) --- vlib/net/util.v | 6 +++--- vlib/net/utils_test.v | 6 ++++++ ...eb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v | 2 -- ...eb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v | 2 -- ...eb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v | 2 -- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/vlib/net/util.v b/vlib/net/util.v index e4bdfd6adb398a..2d08a23a148960 100644 --- a/vlib/net/util.v +++ b/vlib/net/util.v @@ -22,11 +22,11 @@ pub fn split_address(addr string) !(string, u16) { p := validate_port(port)! return address, p } else if _ := addr.index('::') { - // ipv6 host only ::1 - if addr.all_before_last('::') == '' { + if addr.count(':') == 2 && addr.all_before_last('::') == '' { + // ipv6 host only `::1` return addr, 0 } else { - // addr:port + // addr:port, or `::addr:port` address := addr.all_before_last(':') port := addr.all_after_last(':').int() p := validate_port(port)! diff --git a/vlib/net/utils_test.v b/vlib/net/utils_test.v index e80ebd6e35aee4..4e9f1c64a35b2d 100644 --- a/vlib/net/utils_test.v +++ b/vlib/net/utils_test.v @@ -23,3 +23,9 @@ fn test_resolve() { assert x[0].str() == '[::1]:10093' assert x[0].port()! == 10093 } + +fn test_resolve_port_without_brackets() { + x := net.resolve_addrs_fuzzy('::1:48872', .udp)! + assert x.len > 0 + assert x[0].port()! == 48872 +} diff --git a/vlib/veb/tests/veb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v b/vlib/veb/tests/veb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v index d64060d73b20d6..e1acd0bc23c38a 100644 --- a/vlib/veb/tests/veb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v +++ b/vlib/veb/tests/veb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v @@ -1,5 +1,3 @@ -// vtest flaky: true -// vtest retry: 3 import os import log import time diff --git a/vlib/vweb/tests/vweb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v b/vlib/vweb/tests/vweb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v index 234b3d5b98c460..9bebaa3a52e1c4 100644 --- a/vlib/vweb/tests/vweb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v +++ b/vlib/vweb/tests/vweb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v @@ -1,5 +1,3 @@ -// vtest flaky: true -// vtest retry: 3 import os import log import time diff --git a/vlib/x/vweb/tests/vweb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v b/vlib/x/vweb/tests/vweb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v index 3b820dc9bf1d7e..47c898ec062784 100644 --- a/vlib/x/vweb/tests/vweb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v +++ b/vlib/x/vweb/tests/vweb_should_listen_on_both_ipv4_and_ipv6_by_default_test.v @@ -1,5 +1,3 @@ -// vtest flaky: true -// vtest retry: 3 import os import log import time