Files
MeshPort/crates/meshport-socks/tests/unified_fixture.rs
T
shenleiandClaude Haiku 5.5 2f185f914d Snapshot uncommitted work: proxy UI, sing-box integration, socks bridge
- Lab app: proxy panel, node editor, configuration and detail pages,
  responsive layout, and related tests
- Add meshport-socks crate and sing-box bridge scripts/docs
- Add singbox_flutter binding and meshport_client_core package
- FFI, VPN helper (unified mac path), and Android/macOS runner updates
- Docs for architecture, client runtime, UI design, and validation
- UI design output artifacts under outputs/ui

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-12 10:06:15 +09:00

58 lines
2.2 KiB
Rust

use easytier::instance::factory::create_native_instance;
use easytier_core::config::toml::TomlConfig;
use meshport::Network;
use std::time::Duration;
use tokio::net::UdpSocket;
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn udp_through_adjacent_mapped_subnet() {
let port = UdpSocket::bind("127.0.0.1:0")
.await
.unwrap()
.local_addr()
.unwrap()
.port();
let identity =
"[network_identity]\nnetwork_name='unified-udp-fixture'\nnetwork_secret='test-only'\n";
let server_config = TomlConfig::new_from_str(&format!(
"ipv4='10.253.88.2/25'\nlisteners=['udp://127.0.0.1:{port}']\nstun_servers=[]\nstun_servers_v6=[]\n[[proxy_network]]\ncidr='127.0.0.0/25'\nmapped_cidr='10.253.88.128/25'\n{identity}[flags]\nno_tun=true\nuse_smoltcp=true"
)).unwrap();
let server = create_native_instance(server_config).unwrap();
server.start().await.unwrap();
let network = Network::start(&format!(
"ipv4='10.253.88.11/25'\nlisteners=[]\nstun_servers=[]\nstun_servers_v6=[]\n[[peer]]\nuri='udp://127.0.0.1:{port}'\n{identity}[flags]\nno_tun=true\nuse_smoltcp=true"
)).await.unwrap();
tokio::time::timeout(Duration::from_secs(15), async {
loop {
if network.snapshot().await["platform_network"]["subnet_routes"]
.as_array()
.is_some_and(|v| v.iter().any(|r| r == "10.253.88.128/25"))
{
break;
}
tokio::time::sleep(Duration::from_millis(100)).await;
}
})
.await
.unwrap();
let udp = UdpSocket::bind("127.0.0.1:0").await.unwrap();
let target = format!("10.253.88.129:{}", udp.local_addr().unwrap().port())
.parse()
.unwrap();
let echo = tokio::spawn(async move {
let mut buffer = [0; 128];
let (n, source) = udp.recv_from(&mut buffer).await.unwrap();
udp.send_to(&buffer[..n], source).await.unwrap();
});
let result = network
.probe(target, true, true, Duration::from_secs(3))
.await;
echo.abort();
network.stop().await;
server.stop().await;
assert!(
result.is_ok(),
"adjacent mapped subnet UDP failed: {result:?}"
);
}