mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-06 17:59:11 +00:00
avoid packets sending to non-exist peer causing route loop (#1378)
This commit is contained in:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user