mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-15 22:27:26 +08:00
make kcp proxy compitible with old version (#585)
* fix kcp not work with smoltcp * check if dst kcp input is enabled
This commit is contained in:
@@ -10,7 +10,7 @@ use crate::{
|
||||
global_ctx::{ArcGlobalCtx, GlobalCtxEvent, NetworkIdentity},
|
||||
PeerId,
|
||||
},
|
||||
proto::cli::PeerConnInfo,
|
||||
proto::{cli::PeerConnInfo, common::PeerFeatureFlag},
|
||||
tunnel::{packet_def::ZCPacket, TunnelError},
|
||||
};
|
||||
|
||||
@@ -167,6 +167,16 @@ impl PeerMap {
|
||||
None
|
||||
}
|
||||
|
||||
pub async fn get_peer_feature_flag(&self, peer_id: PeerId) -> Option<PeerFeatureFlag> {
|
||||
for route in self.routes.read().await.iter() {
|
||||
let feature_flag = route.get_feature_flag(peer_id).await;
|
||||
if feature_flag.is_some() {
|
||||
return feature_flag;
|
||||
};
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.peer_map.is_empty()
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ use crate::{
|
||||
},
|
||||
peers::route_trait::{Route, RouteInterfaceBox},
|
||||
proto::{
|
||||
common::{Ipv4Inet, NatType, StunInfo},
|
||||
common::{Ipv4Inet, NatType, PeerFeatureFlag, StunInfo},
|
||||
peer_rpc::{
|
||||
route_foreign_network_infos, ForeignNetworkRouteInfoEntry, ForeignNetworkRouteInfoKey,
|
||||
OspfRouteRpc, OspfRouteRpcClientFactory, OspfRouteRpcServer, PeerIdVersion,
|
||||
@@ -2042,6 +2042,8 @@ impl Route for PeerRoute {
|
||||
route.cost_latency_first = next_hop_peer_latency_first.map(|x| x.path_latency);
|
||||
route.path_latency_latency_first = next_hop_peer_latency_first.map(|x| x.path_latency);
|
||||
|
||||
route.feature_flag = item.feature_flag.clone();
|
||||
|
||||
routes.push(route);
|
||||
}
|
||||
routes
|
||||
@@ -2101,6 +2103,14 @@ impl Route for PeerRoute {
|
||||
.map(|x| x.clone())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
async fn get_feature_flag(&self, peer_id: PeerId) -> Option<PeerFeatureFlag> {
|
||||
self.service_impl
|
||||
.route_table
|
||||
.peer_infos
|
||||
.get(&peer_id)
|
||||
.and_then(|x| x.feature_flag.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl PeerPacketFilter for Arc<PeerRoute> {}
|
||||
|
||||
@@ -4,8 +4,11 @@ use dashmap::DashMap;
|
||||
|
||||
use crate::{
|
||||
common::{global_ctx::NetworkIdentity, PeerId},
|
||||
proto::peer_rpc::{
|
||||
ForeignNetworkRouteInfoEntry, ForeignNetworkRouteInfoKey, RouteForeignNetworkInfos,
|
||||
proto::{
|
||||
common::PeerFeatureFlag,
|
||||
peer_rpc::{
|
||||
ForeignNetworkRouteInfoEntry, ForeignNetworkRouteInfoKey, RouteForeignNetworkInfos,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -94,6 +97,8 @@ pub trait Route {
|
||||
|
||||
async fn set_route_cost_fn(&self, _cost_fn: RouteCostCalculator) {}
|
||||
|
||||
async fn get_feature_flag(&self, peer_id: PeerId) -> Option<PeerFeatureFlag>;
|
||||
|
||||
async fn dump(&self) -> String {
|
||||
"this route implementation does not support dump".to_string()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user