Skip to content

Commit

Permalink
net: fix resolving of ::1:48872 (pass the `*should_listen_on_both_i…
Browse files Browse the repository at this point in the history
…pv4_and_ipv6_by_default_test.v` tests) (#22715)
  • Loading branch information
spytheman authored Oct 31, 2024
1 parent 97941b9 commit a189d7f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions vlib/net/util.v
Original file line number Diff line number Diff line change
Expand Up @@ -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)!
Expand Down
6 changes: 6 additions & 0 deletions vlib/net/utils_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// vtest flaky: true
// vtest retry: 3
import os
import log
import time
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// vtest flaky: true
// vtest retry: 3
import os
import log
import time
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// vtest flaky: true
// vtest retry: 3
import os
import log
import time
Expand Down

0 comments on commit a189d7f

Please sign in to comment.