avoid packets sending to non-exist peer causing route loop (#1378)

This commit is contained in:
Sijie.Sun
2025-09-17 09:52:53 +08:00
committed by GitHub
parent 9fff5e4fec
commit 215db09925
3 changed files with 34 additions and 4 deletions
+8
View File
@@ -1,4 +1,5 @@
use std::collections::hash_map::DefaultHasher;
use std::net::IpAddr;
use std::{
hash::Hasher,
sync::{Arc, Mutex},
@@ -239,6 +240,13 @@ impl GlobalCtx {
self.config.get_id()
}
pub fn is_ip_in_same_network(&self, ip: &IpAddr) -> bool {
match ip {
IpAddr::V4(v4) => self.get_ipv4().map(|x| x.contains(v4)).unwrap_or(false),
IpAddr::V6(v6) => self.get_ipv6().map(|x| x.contains(v6)).unwrap_or(false),
}
}
pub fn get_network_identity(&self) -> NetworkIdentity {
self.config.get_network_identity()
}