Skip to content

Commit

Permalink
修复不加密不能打洞的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
vnt-dev committed Aug 27, 2023
1 parent e611d69 commit 2e507f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vnt/src/handle/punch_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ async fn start_punch_(
if count > 2 {
break;
}
let buf = punch_packet(client_cipher, current_device.virtual_ip(), &nat_info, info.virtual_ip)?;
let _ = sender.send_main(&buf, current_device.connect_server).await;
let packet = punch_packet(client_cipher, current_device.virtual_ip(), &nat_info, info.virtual_ip)?;
let _ = sender.send_main(packet.buffer(), current_device.connect_server).await;
}
tokio::time::sleep(sleep_time).await;
Ok(())
Expand All @@ -125,7 +125,7 @@ pub fn punch_packet(
virtual_ip: Ipv4Addr,
nat_info: &NatInfo,
dest: Ipv4Addr,
) -> crate::Result<Vec<u8>> {
) -> crate::Result<NetPacket<Vec<u8>>> {
let mut punch_reply = PunchInfo::new();
punch_reply.reply = false;
punch_reply.public_ip_list = nat_info
Expand All @@ -148,5 +148,5 @@ pub fn punch_packet(
net_packet.set_destination(dest);
net_packet.set_payload(&bytes)?;
client_cipher.encrypt_ipv4(&mut net_packet)?;
Ok(net_packet.into_buffer())
Ok(net_packet)
}

0 comments on commit 2e507f1

Please sign in to comment.