mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-16 06:37:23 +08:00
optimize the condition of enabling kcp (#1210)
This commit is contained in:
@@ -1360,6 +1360,38 @@ impl PeerManager {
|
||||
tracing::info!("close_peer_conn in foreign network manager done: {:?}", ret);
|
||||
ret
|
||||
}
|
||||
|
||||
pub async fn check_allow_kcp_to_dst(&self, dst_ip: &IpAddr) -> bool {
|
||||
let route = self.get_route();
|
||||
let Some(dst_peer_id) = route.get_peer_id_by_ip(dst_ip).await else {
|
||||
return false;
|
||||
};
|
||||
let Some(peer_info) = route.get_peer_info(dst_peer_id).await else {
|
||||
return false;
|
||||
};
|
||||
|
||||
// check dst allow kcp input
|
||||
if !peer_info.feature_flag.map(|x| x.kcp_input).unwrap_or(false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let next_hop_policy = Self::get_next_hop_policy( self.global_ctx.get_flags().latency_first);
|
||||
// check relay node allow relay kcp.
|
||||
let Some(next_hop_id) = route.get_next_hop_with_policy(dst_peer_id, next_hop_policy).await else {
|
||||
return false;
|
||||
};
|
||||
|
||||
let Some(next_hop_info) = route.get_peer_info(next_hop_id).await else {
|
||||
return false;
|
||||
};
|
||||
|
||||
// check next hop allow kcp relay
|
||||
if next_hop_info.feature_flag.map(|x| x.no_relay_kcp).unwrap_or(false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user