完善日志,修复已知问题

This commit is contained in:
lubeilin
2024-03-14 12:05:35 +08:00
parent 8a4d21849e
commit 20132861e9
2 changed files with 4 additions and 4 deletions
+2
View File
@@ -27,6 +27,7 @@ pub struct PunchSender {
}
impl PunchSender {
pub fn send(&self, src_peer: bool, ip: Ipv4Addr, info: NatInfo) -> bool {
log::info!("发送打洞协商消息,是否对端发起:{},ip:{},info:{:?}",src_peer,ip, info);
if src_peer {
self.sender_peer.send((ip, info)).is_ok()
} else {
@@ -198,6 +199,7 @@ fn punch0(
&nat_info,
info.virtual_ip,
)?;
log::info!("发起打洞协商请求,目标:{:?},{:?}", info.virtual_ip, nat_info);
context.send_default(packet.buffer(), current_device.connect_server)?;
}
Ok(())
+2 -4
View File
@@ -176,8 +176,8 @@ impl ClientPacketHandler {
net_packet.first_set_ttl(MAX_TTL);
self.client_cipher.encrypt_ipv4(&mut net_packet)?;
context.send_by_key(net_packet.buffer(), route_key)?;
// let route = Route::from_default_rt(route_key, metric);
// context.route_table.add_route_if_absent(source, route);
let route = Route::from_default_rt(route_key, metric);
context.route_table.add_route_if_absent(source, route);
}
ControlPacket::PongPacket(pong_packet) => {
let current_time = crate::handle::now_time() as u16;
@@ -320,13 +320,11 @@ impl ClientPacketHandler {
punch_packet.set_source(current_device.virtual_ip());
punch_packet.set_destination(source);
punch_packet.set_payload(&bytes)?;
log::info!("接收打洞请求={:?}", peer_nat_info);
if self.punch_sender.send(true, source, peer_nat_info) {
self.client_cipher.encrypt_ipv4(&mut punch_packet)?;
context.send_by_key(punch_packet.buffer(), route_key)?;
}
} else {
log::info!("接收打洞请求回复={:?}", peer_nat_info);
self.punch_sender.send(false, source, peer_nat_info);
}
}