removed println

This commit is contained in:
asxalex 2024-07-16 23:41:30 +08:00
parent 23a12e66f6
commit 733f93fe16
6 changed files with 21 additions and 34 deletions

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
*.so
.id
.client
.output
.output
sdlan

View File

@ -494,7 +494,6 @@ async fn edge_send_packet_to_net(eee: &Node, data: &[u8]) {
error!("failed to encode to udp message");
return;
};
println!("send packet to net");
send_packet_to_net(eee, dstip, &flow, msg_size).await;
}
Err(e) => {
@ -504,7 +503,6 @@ async fn edge_send_packet_to_net(eee: &Node, data: &[u8]) {
}
async fn send_packet_to_net(eee: &Node, dst_ip: u32, pkt: &[u8], size: u64) {
println!("find peer destination");
let (dest_sock, is_p2p) = find_peer_destination(eee, dst_ip).await;
if is_p2p {
eee.stats.tx_p2p.fetch_add(size, Ordering::Relaxed);
@ -548,7 +546,7 @@ async fn find_peer_destination(eee: &Node, dst_ip: u32) -> (SdlanSock, bool) {
[eee.config.super_node_index.load(Ordering::Relaxed) as usize]
.deepcopy();
}
println!("find peer_destination: {}", is_p2p);
// println!("find peer_destination: {}", is_p2p);
if !is_p2p {
debug!("check_query_peer_info");
super::packet::check_query_peer_info(eee, dst_ip).await;

View File

@ -61,12 +61,14 @@ pub async fn read_and_parse_packet(
Ok((size, from)) => {
// size > 0
/*
if is_multicast_sock {
println!(
"xxxx got packet from multicast sock from {}",
from.to_string()
);
}
*/
buf.truncate(size);
match handle_packet(eee, from, &buf).await {
@ -118,7 +120,6 @@ pub async fn handle_packet(eee: &Node, addr: SocketAddr, buf: &[u8]) -> Result<(
handle_tun_packet(eee, !data.is_p2p, data).await;
}
PacketType::StunProbeReply => {
println!("got stunprobeReply");
let Ok(reply) = SdlStunProbeReply::decode(&buf[1..]) else {
error!("failed to decode SdlStunReply");
return Ok(());
@ -348,7 +349,7 @@ async fn handle_packet_register_ack(
sender_sock: &SdlanSock,
) -> Result<()> {
let Ok(ack) = SdlRegisterAck::decode(body) else {
println!("failed to decode REGISTER_ACK");
error!("failed to decode REGISTER_ACK");
return Ok(());
};
@ -538,7 +539,6 @@ async fn register_with_new_peer(
let now = get_current_timestamp();
let mut scan = eee.pending_peers.get_peer(&ip);
if let None = scan {
println!("pending peers not found");
// such ip not found in pending
let temp = Arc::new(EdgePeer::new(
ip,
@ -556,13 +556,7 @@ async fn register_with_new_peer(
scan = Some(temp);
debug!("Pending size: {}", eee.pending_peers.peers.len());
println!(
"Pending size: {}, from_sn: {}",
eee.pending_peers.peers.len(),
from_sn
);
if from_sn {
println!("from_sn");
// should send register to peer
if eee.config.register_ttl == 1 {
/* We are DMZ host or port is directly accessible. Just let peer to send back the ack */
@ -593,14 +587,11 @@ async fn register_with_new_peer(
)
.await;
} else {
println!("not from sn");
// P2P register, send directly
send_register(eee, peersock, v6_info).await;
}
println!("register with local peers");
register_with_local_peers(eee).await;
} else {
println!("pending peers is found");
if let Some(ref s) = scan {
*(s.sock.write().unwrap()) = peersock.deepcopy();
}
@ -612,9 +603,8 @@ async fn register_with_new_peer(
}
async fn register_with_local_peers(eee: &Node) {
println!("register_with_local_peers");
if eee.config.allow_p2p {
println!("send register to multicast sock");
debug!("send register to multicast sock");
send_register(eee, &eee.multicast_sock, &None).await;
}
}
@ -638,7 +628,6 @@ async fn send_register(eee: &Node, sock: &SdlanSock, _v6_info: &Option<V6Info>)
let msg = encode_to_udp_message(Some(register), PacketType::Register as u8).unwrap();
println!("send register to {}", sock.to_string());
let _ = send_to_sock(eee, &msg, sock).await;
/*
let key = eee.get_header_key();
@ -794,7 +783,6 @@ pub async fn check_query_peer_info(eee: &Node, dst_ip: u32) {
now,
));
debug!("insert peer {} to pending", ip_to_string(&dst_ip));
println!("insert peer {} to pending", ip_to_string(&dst_ip));
eee.pending_peers.insert_peer(peer.clone());
scan = peer;
}

View File

@ -70,22 +70,22 @@ impl ReadWriteActor {
loop {
self.connected.store(false, Ordering::Relaxed);
if !started {
println!("waiting for start");
// println!("waiting for start");
while let Some(m) = start_stop_chan.recv().await {
if m {
println!("start received");
// println!("start received");
started = true;
break;
} else {
println!("stop received");
// println!("stop received");
}
}
}
println!("try connecting...");
debug!("try connecting...");
let Ok(mut stream) = TcpStream::connect(&self.remote).await else {
self.connected.store(false, Ordering::Relaxed);
if keep_reconnect {
/*
/*
tokio::select! {
_ = tokio::time::sleep(Duration::from_secs(3)) => {
continue;
@ -132,7 +132,7 @@ impl ReadWriteActor {
}
}
}
println!("to_tcp recv None");
error!("to_tcp recv None");
};
let check_pong = async {
@ -161,7 +161,7 @@ impl ReadWriteActor {
}
}
on_disconnected().await;
println!("connect retrying");
debug!("connect retrying");
tokio::time::sleep(Duration::from_secs(1)).await;
// future::select(read_from_tcp, write_to_tcp).await;
}
@ -180,7 +180,7 @@ impl ReadWriterHandle {
if self.connected.load(Ordering::Relaxed) {
// connected, send to it
if let Err(e) = self.send_to_tcp.send(Vec::from(data)).await {
println!("failed to send to send_to_tcp: {}", e.to_string());
error!("failed to send to send_to_tcp: {}", e.to_string());
return Err(SDLanError::NormalError("failed to send"));
};
debug!("tcp info sent");
@ -222,7 +222,7 @@ impl ReadWriterHandle {
if let Some(msg) = data_from_tcp.recv().await {
on_message(msg).await;
} else {
println!("data from tcp exited");
eprintln!("data from tcp exited");
return;
}
}

View File

@ -19,7 +19,7 @@ impl PidRecorder {
.expect("failed to write");
}
Err(e) => {
println!("failed to open pid file: {}", e);
eprintln!("failed to open pid file: {}", e);
}
}
@ -30,7 +30,7 @@ impl PidRecorder {
impl Drop for PidRecorder {
fn drop(&mut self) {
if let Err(e) = fs::remove_file(&self.0) {
println!("failed to remove pid file: {}", e);
eprintln!("failed to remove pid file: {}", e);
}
}
}

View File

@ -4,7 +4,7 @@ use sdlan_sn_rs::{
};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4};
use tokio::net::ToSocketAddrs;
use tracing::error;
use tracing::{debug, error};
use sdlan_sn_rs::peer::SdlanSock;
use tokio::net::UdpSocket;
@ -55,7 +55,7 @@ impl Socket {
{
error!("failed to join multicast: {}", e.to_string());
} else {
println!("{} joined multicast ok", addr);
debug!("{} joined multicast ok", addr);
}
}
if tos != 0 {
@ -106,7 +106,7 @@ pub async fn send_to_sock(
AF_INET => {
// sockv4
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::from(sock.v4)), sock.port);
println!("udp sock v4 send to {}", addr);
// println!("udp sock v4 send to {}", addr);
eee.udp_sock_v4.send_to(content, addr).await?;
return Ok(());
}