mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-10-14 08:26:14 -08:00
Accept a boolean or an IPv6 CIDR in dhcpv6 and --dhcpv6, using fd6b:8c2d:91e4::/64 when no initial subnet is supplied. Keep IPv4 configuration serialization compatible and DHCPv6 disabled by default. Share the DHCP lifecycle and host update between both address families, with typed allocation state, peer subnet selection, conflict recovery, and bounded IPv6 probing. Preserve static addresses of the other family and prevent static config patches from replacing DHCP-owned leases. Carry IPv6 settings, leases, and events through management, web config, and mobile VPN setup. Reuse the shared NIC registry and mobile address list for IPv6-only and dual-stack operation without extra FD owners. Cover config round trips, allocation and recovery, mobile reconciliation, three-node IPv6 and dual-stack connectivity, and shared TUN member exit. Validate with workspace clippy, Docker TUN tests, frontend tests/builds, WASI and Android Rust checks, and Android VPN Kotlin compilation.
82 lines
2.6 KiB
Rust
82 lines
2.6 KiB
Rust
use easytier_proto::api::{
|
|
instance::{PeerInfo, list_peer_route_pair},
|
|
manage::{MyNodeInfo, NetworkInstanceRunningInfo},
|
|
};
|
|
|
|
use crate::{
|
|
config::toml::ConfigLoader as _,
|
|
instance::{CoreInstance, CoreInstanceHost, CoreInstanceState},
|
|
};
|
|
|
|
/// Builds the process-level running snapshot directly from one core Instance.
|
|
#[allow(deprecated)]
|
|
pub async fn network_instance_running_info<H>(
|
|
instance: &CoreInstance<H>,
|
|
) -> anyhow::Result<NetworkInstanceRunningInfo>
|
|
where
|
|
H: CoreInstanceHost,
|
|
{
|
|
let running = !matches!(
|
|
instance.state(),
|
|
CoreInstanceState::Created | CoreInstanceState::Stopped
|
|
);
|
|
if !instance.is_ready() {
|
|
return Ok(NetworkInstanceRunningInfo {
|
|
running,
|
|
error_msg: instance.latest_error(),
|
|
..Default::default()
|
|
});
|
|
}
|
|
|
|
let peers = instance
|
|
.peer_snapshots()
|
|
.await
|
|
.into_iter()
|
|
.map(|snapshot| PeerInfo {
|
|
peer_id: snapshot.peer_id,
|
|
default_conn_id: snapshot.default_conn_id.map(Into::into),
|
|
directly_connected_conns: snapshot
|
|
.directly_connected_conns
|
|
.into_iter()
|
|
.map(Into::into)
|
|
.collect(),
|
|
conns: snapshot.conns.into_iter().map(Into::into).collect(),
|
|
})
|
|
.collect::<Vec<_>>();
|
|
let node = instance.node_snapshot().await;
|
|
let routes = instance
|
|
.route_snapshots()
|
|
.await
|
|
.into_iter()
|
|
.map(Into::into)
|
|
.collect::<Vec<_>>();
|
|
let peer_route_pairs = list_peer_route_pair(peers.clone(), routes.clone());
|
|
let dev_name = instance
|
|
.toml_config()
|
|
.map(|config| config.get_flags().dev_name)
|
|
.unwrap_or_default();
|
|
|
|
Ok(NetworkInstanceRunningInfo {
|
|
dev_name,
|
|
my_node_info: Some(MyNodeInfo {
|
|
virtual_ipv4: node.ipv4_addr.map(Into::into),
|
|
virtual_ipv6: node.ipv6_addr.map(Into::into),
|
|
hostname: node.hostname,
|
|
version: node.version,
|
|
ips: Some(node.ip_list),
|
|
stun_info: Some(node.stun_info),
|
|
listeners: node.listeners.into_iter().map(Into::into).collect(),
|
|
// Client private keys are returned only by the explicit portal RPC.
|
|
vpn_portal_cfg: None,
|
|
peer_id: node.peer_id,
|
|
}),
|
|
events: instance.management_events(),
|
|
routes,
|
|
peers,
|
|
peer_route_pairs,
|
|
running,
|
|
error_msg: instance.latest_error(),
|
|
foreign_network_summary: Some(instance.foreign_network_route_summary().await),
|
|
})
|
|
}
|