minor fixed (#120)

1. fix mtu, always set by ourselves and use smaller value
2. wireguard connector should return tunnel after receive packet
This commit is contained in:
Sijie.Sun
2024-05-18 18:04:06 +08:00
committed by GitHub
parent 0ead308392
commit 6efbb5cb3d
4 changed files with 79 additions and 58 deletions
+13 -8
View File
@@ -295,14 +295,6 @@ impl VirtualNic {
todo!("queue_num != 1")
}
config.queues(self.queue_num);
let flags = self.global_ctx.config.get_flags();
let mut mtu_in_config = flags.mtu;
if flags.enable_encryption {
mtu_in_config -= 20;
}
config.mtu(mtu_in_config as i32);
config.up();
let dev = {
@@ -313,6 +305,19 @@ impl VirtualNic {
let ifname = dev.get_ref().name()?;
self.ifcfg.wait_interface_show(ifname.as_str()).await?;
let flags = self.global_ctx.config.get_flags();
let mut mtu_in_config = flags.mtu;
if flags.enable_encryption {
mtu_in_config -= 20;
}
{
// set mtu by ourselves, rust-tun does not handle it correctly on windows
let _g = self.global_ctx.net_ns.guard();
self.ifcfg
.set_mtu(ifname.as_str(), mtu_in_config as u32)
.await?;
}
let (a, b) = BiLock::new(dev);
let ft = TunnelWrapper::new(