diff --git a/scripts/run_local_test.py b/scripts/run_local_test.py index da59fa4c..e0ce3717 100755 --- a/scripts/run_local_test.py +++ b/scripts/run_local_test.py @@ -52,7 +52,7 @@ def tee(prefix, infile, *files): def read_until_interface_dial_info(proc, proto): - interface_dial_info_str = b"Interface Dial Info: " + interface_dial_info_str = b"Local Dial Info: " for ln in iter(proc.stdout.readline, ""): sys.stdout.buffer.write(ln) sys.stdout.flush() diff --git a/veilid-core/src/network_manager.rs b/veilid-core/src/network_manager.rs index 3c92d96c..5bbe2e1f 100644 --- a/veilid-core/src/network_manager.rs +++ b/veilid-core/src/network_manager.rs @@ -1257,7 +1257,8 @@ impl NetworkManager { let inner = self.inner.lock(); let mut inconsistencies = 0; let mut changed = false; - for (p, a) in &inner.public_address_check_cache { + // Iteration goes from most recent to least recent node/address pair + for (_, a) in &inner.public_address_check_cache { if !current_addresses.contains(a) { inconsistencies += 1; if inconsistencies >= GLOBAL_ADDRESS_CHANGE_DETECTION_COUNT { @@ -1276,7 +1277,8 @@ impl NetworkManager { let mut consistencies = 0; let mut consistent = false; let mut current_address = Option::::None; - for (p, a) in &inner.public_address_check_cache { + // Iteration goes from most recent to least recent node/address pair + for (_, a) in &inner.public_address_check_cache { if let Some(current_address) = current_address { if current_address == *a { consistencies += 1; diff --git a/veilid-core/src/tests/common/test_host_interface.rs b/veilid-core/src/tests/common/test_host_interface.rs index 200a1a8c..1e9741cf 100644 --- a/veilid-core/src/tests/common/test_host_interface.rs +++ b/veilid-core/src/tests/common/test_host_interface.rs @@ -386,6 +386,13 @@ pub async fn test_split_url() { assert_split_url!("http://foo/", "http", host("foo"), None, ""); assert_split_url!("http://11.2.3.144/", "http", ip("11.2.3.144"), None, ""); assert_split_url!("http://[1111::2222]/", "http", ip("1111::2222"), None, ""); + assert_split_url!( + "http://[1111::2222]:123/", + "http", + ip("1111::2222"), + Some(123), + "" + ); assert_split_url!( "http://foo/asdf/qwer", @@ -433,6 +440,8 @@ pub async fn test_split_url() { assert_err!(SplitUrl::from_str("a:///qwer:")); assert_err!(SplitUrl::from_str("a:///qwer://")); assert_err!(SplitUrl::from_str("a://qwer://")); + assert_err!(SplitUrl::from_str("a://[1111::2222]:/")); + assert_err!(SplitUrl::from_str("a://[1111::2222]:")); assert_split_url_parse!("sch://foo:bar@baz.com:1234/fnord#qux?zuz"); assert_split_url_parse!("sch://foo:bar@baz.com:1234/fnord#qux"); diff --git a/veilid-core/src/xx/split_url.rs b/veilid-core/src/xx/split_url.rs index 8c638ba4..b6fa3026 100644 --- a/veilid-core/src/xx/split_url.rs +++ b/veilid-core/src/xx/split_url.rs @@ -296,6 +296,20 @@ impl SplitUrl { } } +fn split_host_with_port(s: &str) -> Option<(&str, &str)> { + // special case for ipv6 colons + if s.len() > 2 && s[0..1] == *"[" { + if let Some(end) = s.find(']') { + if end < (s.len() - 2) && s[end + 1..end + 2] == *":" { + return Some((&s[0..end + 1], &s[end + 2..])); + } + } + None + } else { + s.split_once(':') + } +} + impl FromStr for SplitUrl { type Err = String; fn from_str(s: &str) -> Result { @@ -311,7 +325,7 @@ impl FromStr for SplitUrl { None } }; - if let Some((host, rest)) = rest.rsplit_once(':') { + if let Some((host, rest)) = split_host_with_port(rest) { let host = SplitUrlHost::from_str(host)?; if let Some((portstr, path)) = rest.split_once('/') { let port = convert_port(portstr)?;