Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e29b020e0 | ||
|
|
20132861e9 | ||
|
|
a1e9b3c133 |
@@ -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是必须的
|
||||
|
||||
@@ -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(())
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user