fix ipv6 packet routing and avoid route looping

properly handle ipv6 link local address and exit node.
This commit is contained in:
sijie.sun
2025-08-03 16:54:03 +08:00
committed by Sijie.Sun
parent 84bfac144c
commit d0a6c93c2c
6 changed files with 49 additions and 27 deletions
+15 -3
View File
@@ -627,7 +627,7 @@ impl NetworkConfig {
}
if self.exit_nodes.len() > 0 {
let mut exit_nodes = Vec::<std::net::Ipv4Addr>::with_capacity(self.exit_nodes.len());
let mut exit_nodes = Vec::<std::net::IpAddr>::with_capacity(self.exit_nodes.len());
for node in self.exit_nodes.iter() {
exit_nodes.push(
node.parse()
@@ -891,7 +891,7 @@ impl NetworkConfig {
mod tests {
use crate::common::config::ConfigLoader;
use rand::Rng;
use std::net::Ipv4Addr;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
fn gen_default_config() -> crate::common::config::TomlConfigLoader {
let config = crate::common::config::TomlConfigLoader::default();
@@ -1073,7 +1073,19 @@ mod tests {
rng.gen_range(0..255),
rng.gen_range(1..254),
);
nodes.push(ip);
nodes.push(IpAddr::V4(ip));
// gen ipv6
let ip = Ipv6Addr::new(
rng.gen_range(0..65535),
rng.gen_range(0..65535),
rng.gen_range(0..65535),
rng.gen_range(0..65535),
rng.gen_range(0..65535),
rng.gen_range(0..65535),
rng.gen_range(0..65535),
rng.gen_range(0..65535),
);
nodes.push(IpAddr::V6(ip));
}
config.set_exit_nodes(nodes);
}