fix: filter overlapped proxy cidrs in ProxyCidrsMonitor (#2079)

* feat(route): add async methods to list proxy CIDRs for IPv4 and IPv6
* refactor(ProxyCidrsMonitor): get proxy cidrs from list_proxy_cidrs
This commit is contained in:
Luna Yao
2026-04-12 16:18:54 +02:00
committed by GitHub
parent 6f3e708679
commit ec7ddd3bad
4 changed files with 66 additions and 30 deletions
+19 -2
View File
@@ -1,10 +1,11 @@
use cidr::{Ipv4Cidr, Ipv6Cidr};
use dashmap::DashMap;
use std::{
collections::BTreeSet,
net::{Ipv4Addr, Ipv6Addr},
sync::Arc,
};
use dashmap::DashMap;
use crate::{
common::{PeerId, global_ctx::NetworkIdentity},
proto::peer_rpc::{
@@ -86,6 +87,12 @@ pub trait Route {
async fn list_routes(&self) -> Vec<crate::proto::api::instance::Route>;
// TODO: rewrite route management, remove this
async fn list_proxy_cidrs(&self) -> BTreeSet<Ipv4Cidr>;
// TODO: rewrite route management, remove this
async fn list_proxy_cidrs_v6(&self) -> BTreeSet<Ipv6Cidr>;
async fn get_peer_id_by_ipv4(&self, _ipv4: &Ipv4Addr) -> Option<PeerId> {
None
}
@@ -175,6 +182,16 @@ impl Route for MockRoute {
panic!("mock route")
}
// TODO: rewrite route management, remove this
async fn list_proxy_cidrs(&self) -> BTreeSet<Ipv4Cidr> {
unimplemented!()
}
// TODO: rewrite route management, remove this
async fn list_proxy_cidrs_v6(&self) -> BTreeSet<Ipv6Cidr> {
unimplemented!()
}
async fn get_peer_info(&self, _peer_id: PeerId) -> Option<RoutePeerInfo> {
panic!("mock route")
}