Compare commits

..
3 Commits
Author SHA1 Message Date
lubeilin 8e29b020e0 Merge branch 'main' into mio 2024-03-14 12:06:47 +08:00
lubeilin 20132861e9 完善日志,修复已知问题 2024-03-14 12:05:35 +08:00
lubeilin a1e9b3c133 增加参数说明 2024-03-13 23:24:36 +08:00
3 changed files with 7 additions and 4 deletions
+3
View File
@@ -118,6 +118,9 @@ ports:
cmd: false #关闭控制台输入
no_proxy: false #是否关闭内置代理,true为关闭
first_latency: false #是否优先低延迟通道,默认为false,表示优先使用p2p通道
device_name: vnt-tun #网卡名称
packet_loss: 0 #指定丢包率 取值0~1之间的数 用于模拟弱网
packet_delay: 0 #指定延迟 单位毫秒 用于模拟弱网
```
或者需要哪个配置就加哪个,当然token是必须的
+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);
}
}