skip REGISTER SUPER and REGISTER from self

This commit is contained in:
asxalex 2024-10-26 10:53:58 +08:00
parent e32c640466
commit 2b8a536151
3 changed files with 11 additions and 7 deletions

View File

@ -391,6 +391,12 @@ async fn handle_packet_register_ack(
return Ok(());
};
let via_multicast = is_multi_broadcast(&dst_mac);
if via_multicast && src_mac == eee.device_config.get_mac() {
debug!("skipping register ack from self");
return Ok(());
}
debug!(
"Rx REGISTER ACK from {} [{}] to {} via {}",
mac_to_string(&src_mac),
@ -661,11 +667,8 @@ async fn register_with_new_peer(
}
async fn register_with_local_peers(eee: &Node) {
if eee.config.allow_p2p {
debug!("send register to multicast sock");
send_register(eee, &eee.multicast_sock, NULL_MAC, &None).await;
}
}
async fn send_register(eee: &Node, sock: &SdlanSock, mac: Mac, _v6_info: &Option<V6Info>) {
if !eee.config.allow_p2p {

View File

@ -352,8 +352,8 @@ impl TunTapPacketHandler for Iface {
}
}
println!("got ip packet");
println!("got data: {:?}", rest);
// println!("got ip packet");
// println!("got data: {:?}", rest);
match edge.device.send(rest) {
Ok(size) => {
debug!("send to tun {} bytes", size);

View File

@ -5,7 +5,7 @@ use etherparse::Ethernet2Header;
use once_cell::sync::OnceCell;
use sdlan_sn_rs::{
config::SDLAN_DEFAULT_TTL,
utils::{aes_encrypt, get_current_timestamp, ip_to_string, mac_to_string, Mac},
utils::{aes_encrypt, get_current_timestamp, ip_to_string, Mac},
};
use tracing::error;
@ -14,6 +14,7 @@ use crate::{
network::{form_ethernet_packet, send_packet_to_net},
pb::{encode_to_udp_message, SdlData},
tcp::PacketType,
utils::mac_to_string,
};
use super::get_edge;