mirror of
https://github.com/vlang/v.git
synced 2025-08-03 09:47:15 -04:00
net: fix resolving of ::1:48872
(pass the *should_listen_on_both_ipv4_and_ipv6_by_default_test.v
tests) (#22715)
This commit is contained in:
parent
97941b97f8
commit
a189d7f8e8
@ -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)!
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
// vtest flaky: true
|
||||
// vtest retry: 3
|
||||
import os
|
||||
import log
|
||||
import time
|
||||
|
@ -1,5 +1,3 @@
|
||||
// vtest flaky: true
|
||||
// vtest retry: 3
|
||||
import os
|
||||
import log
|
||||
import time
|
||||
|
@ -1,5 +1,3 @@
|
||||
// vtest flaky: true
|
||||
// vtest retry: 3
|
||||
import os
|
||||
import log
|
||||
import time
|
||||
|
Loading…
x
Reference in New Issue
Block a user