mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-15 22:27:26 +08:00
support mapping subnet proxy (#978)
- **support mapping subproxy network cidr** - **add command line option for proxy network mapping** - **fix Instance leak in tests.
This commit is contained in:
@@ -1101,9 +1101,16 @@ impl PeerManager {
|
||||
.unwrap_or_default(),
|
||||
proxy_cidrs: self
|
||||
.global_ctx
|
||||
.config
|
||||
.get_proxy_cidrs()
|
||||
.into_iter()
|
||||
.map(|x| x.to_string())
|
||||
.map(|x| {
|
||||
if x.mapped_cidr.is_none() {
|
||||
x.cidr.to_string()
|
||||
} else {
|
||||
format!("{}->{}", x.cidr, x.mapped_cidr.unwrap())
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
hostname: self.global_ctx.get_hostname(),
|
||||
stun_info: Some(self.global_ctx.get_stun_info_collector().get_stun_info()),
|
||||
@@ -1133,6 +1140,15 @@ impl PeerManager {
|
||||
.map(|x| x.clone())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub async fn clear_resources(&self) {
|
||||
let mut peer_pipeline = self.peer_packet_process_pipeline.write().await;
|
||||
peer_pipeline.clear();
|
||||
let mut nic_pipeline = self.nic_packet_process_pipeline.write().await;
|
||||
nic_pipeline.clear();
|
||||
|
||||
self.peer_rpc_mgr.rpc_server().registry().unregister_all();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -139,10 +139,12 @@ impl RoutePeerInfo {
|
||||
cost: 0,
|
||||
ipv4_addr: global_ctx.get_ipv4().map(|x| x.address().into()),
|
||||
proxy_cidrs: global_ctx
|
||||
.config
|
||||
.get_proxy_cidrs()
|
||||
.iter()
|
||||
.map(|x| x.mapped_cidr.unwrap_or(x.cidr))
|
||||
.chain(global_ctx.get_vpn_portal_cidr())
|
||||
.map(|x| x.to_string())
|
||||
.chain(global_ctx.get_vpn_portal_cidr().map(|x| x.to_string()))
|
||||
.collect(),
|
||||
hostname: Some(global_ctx.get_hostname()),
|
||||
udp_stun_info: global_ctx
|
||||
|
||||
Reference in New Issue
Block a user