Updating tun package

modified:   Cargo.lock
	modified:   Cargo.toml
	modified:   src/client.rs
	modified:   src/server.rs
This commit is contained in:
Michael Wain 2024-12-07 20:26:35 +03:00
parent 7f216bc176
commit ad76216fff
4 changed files with 68 additions and 49 deletions

104
Cargo.lock generated
View File

@ -135,7 +135,7 @@ dependencies = [
"ndk-context",
"ndk-sys 0.6.0+11769913",
"num_enum",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -604,18 +604,18 @@ checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3"
[[package]]
name = "c2rust-bitfields"
version = "0.18.0"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b43c3f07ab0ef604fa6f595aa46ec2f8a22172c975e186f6f5bf9829a3b72c41"
checksum = "367e5d1b30f28be590b6b3868da1578361d29d9bfac516d22f497d28ed7c9055"
dependencies = [
"c2rust-bitfields-derive",
]
[[package]]
name = "c2rust-bitfields-derive"
version = "0.18.0"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3cbc102e2597c9744c8bd8c15915d554300601c91a079430d309816b0912545"
checksum = "a279db9c50c4024eeca1a763b6e0f033848ce74e83e47454bcf8a8a98f7b0b56"
dependencies = [
"proc-macro2",
"quote",
@ -633,7 +633,7 @@ dependencies = [
"polling",
"rustix",
"slab",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -766,7 +766,7 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4274ea815e013e0f9f04a2633423e14194e408a0576c943ce3d14ca56c50031c"
dependencies = [
"thiserror",
"thiserror 1.0.64",
"x11rb",
]
@ -1583,7 +1583,7 @@ dependencies = [
"tokio",
"tokio-util",
"tray-item",
"tun2",
"tun",
"x25519-dalek",
]
@ -1802,7 +1802,7 @@ checksum = "6f56f6318968d03c18e1bcf4857ff88c61157e9da8e47c5f29055d60e1228884"
dependencies = [
"log",
"presser",
"thiserror",
"thiserror 1.0.64",
"winapi",
"windows",
]
@ -1901,7 +1901,7 @@ dependencies = [
"com",
"libc",
"libloading 0.8.5",
"thiserror",
"thiserror 1.0.64",
"widestring",
"winapi",
]
@ -2100,7 +2100,7 @@ dependencies = [
"iced_renderer",
"iced_widget",
"iced_winit",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -2119,7 +2119,7 @@ dependencies = [
"palette",
"rustc-hash 2.0.0",
"smol_str",
"thiserror",
"thiserror 1.0.64",
"web-time",
]
@ -2167,7 +2167,7 @@ dependencies = [
"once_cell",
"raw-window-handle",
"rustc-hash 2.0.0",
"thiserror",
"thiserror 1.0.64",
"unicode-segmentation",
]
@ -2181,7 +2181,7 @@ dependencies = [
"iced_tiny_skia",
"iced_wgpu",
"log",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -2194,7 +2194,7 @@ dependencies = [
"iced_core",
"iced_futures",
"raw-window-handle",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -2229,7 +2229,7 @@ dependencies = [
"log",
"once_cell",
"rustc-hash 2.0.0",
"thiserror",
"thiserror 1.0.64",
"wgpu",
]
@ -2244,7 +2244,7 @@ dependencies = [
"num-traits",
"once_cell",
"rustc-hash 2.0.0",
"thiserror",
"thiserror 1.0.64",
"unicode-segmentation",
]
@ -2259,7 +2259,7 @@ dependencies = [
"iced_runtime",
"log",
"rustc-hash 2.0.0",
"thiserror",
"thiserror 1.0.64",
"tracing",
"wasm-bindgen-futures",
"web-sys",
@ -2343,7 +2343,7 @@ dependencies = [
"combine",
"jni-sys",
"log",
"thiserror",
"thiserror 1.0.64",
"walkdir",
]
@ -2357,7 +2357,7 @@ dependencies = [
"combine",
"jni-sys",
"log",
"thiserror",
"thiserror 1.0.64",
"walkdir",
]
@ -2372,7 +2372,7 @@ dependencies = [
"combine",
"jni-sys",
"log",
"thiserror",
"thiserror 1.0.64",
"walkdir",
"windows-sys 0.45.0",
]
@ -2536,7 +2536,7 @@ dependencies = [
"serde-value",
"serde_json",
"serde_yaml",
"thiserror",
"thiserror 1.0.64",
"thread-id",
"typemap-ors",
"winapi",
@ -2661,7 +2661,7 @@ dependencies = [
"rustc-hash 1.1.0",
"spirv",
"termcolor",
"thiserror",
"thiserror 1.0.64",
"unicode-xid",
]
@ -2677,7 +2677,7 @@ dependencies = [
"ndk-sys 0.6.0+11769913",
"num_enum",
"raw-window-handle",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -2712,7 +2712,7 @@ checksum = "433419f898328beca4f2c6c73a1b52540658d92b0a99f0269330457e0fd998d5"
dependencies = [
"cc",
"libc",
"thiserror",
"thiserror 1.0.64",
"winapi",
]
@ -3113,7 +3113,7 @@ dependencies = [
"bitflags 1.3.2",
"byteorder",
"hwaddr",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -3586,7 +3586,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
dependencies = [
"getrandom",
"libredox",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -3967,7 +3967,7 @@ dependencies = [
"log",
"memmap2",
"rustix",
"thiserror",
"thiserror 1.0.64",
"wayland-backend",
"wayland-client",
"wayland-csd-frame",
@ -4176,7 +4176,16 @@ version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
dependencies = [
"thiserror-impl",
"thiserror-impl 1.0.64",
]
[[package]]
name = "thiserror"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "643caef17e3128658ff44d85923ef2d28af81bb71e0d67bbfe1d76f19a73e053"
dependencies = [
"thiserror-impl 2.0.5",
]
[[package]]
@ -4190,6 +4199,17 @@ dependencies = [
"syn 2.0.87",
]
[[package]]
name = "thiserror-impl"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "995d0bbc9995d1f19d28b7215a9352b0fc3cd3a2d2ec95c2cadc485cdedbcdde"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]]
name = "thread-id"
version = "4.2.2"
@ -4516,21 +4536,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5902c5d130972a0000f60860bfbf46f7ca3db5391eddfedd1b8728bd9dc96c0e"
[[package]]
name = "tun2"
version = "2.0.9"
name = "tun"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b139b40733b3e81560335ccad94948916c4d03ed1ded505a8675428879075b4"
checksum = "f3c3f82bccbec181c56278683da7d915cf875a6cf8a450b3bcf1367de222775e"
dependencies = [
"bytes",
"cfg-if",
"futures",
"futures-core",
"ipnet",
"libc",
"libloading 0.8.5",
"log",
"nix",
"rustversion",
"thiserror",
"thiserror 2.0.5",
"tokio",
"tokio-util",
"windows-sys 0.59.0",
@ -4967,7 +4986,7 @@ dependencies = [
"raw-window-handle",
"rustc-hash 1.1.0",
"smallvec",
"thiserror",
"thiserror 1.0.64",
"web-sys",
"wgpu-hal",
"wgpu-types",
@ -5011,7 +5030,7 @@ dependencies = [
"renderdoc-sys",
"rustc-hash 1.1.0",
"smallvec",
"thiserror",
"thiserror 1.0.64",
"wasm-bindgen",
"web-sys",
"wgpu-types",
@ -5077,7 +5096,7 @@ dependencies = [
"clipboard_wayland",
"clipboard_x11",
"raw-window-handle",
"thiserror",
"thiserror 1.0.64",
]
[[package]]
@ -5395,15 +5414,18 @@ dependencies = [
[[package]]
name = "wintun-bindings"
version = "0.6.4"
version = "0.7.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3af47a132f449a64ff858f9ad876a3d1812df30e9500cddfdcabb2266ab68c0d"
checksum = "50da04a12b4acd77944c4e3501a61e754dc798dadcab063c9bf1d7c40081ec41"
dependencies = [
"blocking",
"c2rust-bitfields",
"futures",
"libloading 0.8.5",
"log",
"thiserror",
"thiserror 2.0.5",
"windows-sys 0.59.0",
"winreg 0.52.0",
]
[[package]]

View File

@ -45,7 +45,7 @@ base64 = "0.22.1"
chrono = "0.4.38"
console-subscriber = "0.4.0"
network-interface = "2.0.0"
tun2 = { version = "2", features = ["async"] }
tun = { version = "0.7.5", features = ["async"] }
[target.'cfg(target_os="windows")'.dependencies]
iced = { version = "0.13.1", features = ["tokio"] }

View File

@ -16,7 +16,7 @@ pub mod general {
use x25519_dalek::{PublicKey, StaticSecret};
use crate::udp::{UDPVpnPacket, UDPVpnHandshake, UDPSerializable};
use tun2::{ AsyncDevice, DeviceReader, DeviceWriter, TunPacketCodec };
use tun::{ AsyncDevice, DeviceReader, DeviceWriter, TunPacketCodec };
pub trait ReadWrapper {
async fn read(&mut self, buf: &mut Vec<u8>) -> Result<usize, ()>;
@ -74,10 +74,6 @@ pub mod general {
Ok(()) => Ok(l),
Err(e) => Err(e.to_string())
};
/* if let Ok(()) = self.dr.send(buf).await {
return Ok(l);
}
Err(()) */
},
// this thing should be abolished later
WriterMessage::Gateway(_addr) => {
@ -162,6 +158,7 @@ pub mod general {
rr = rx.recv() => {
if let Some(bytes) = rr {
info!("Write to tun. len={:?}", bytes.len());
if let Err(e) = self.dev_writer.write(WriterMessage::Plain(bytes)).await {
error!("Writing error: {:?}", e);
}
@ -286,7 +283,7 @@ pub mod desktop {
#[cfg(target_os = "linux")]
use network_interface::{NetworkInterface, NetworkInterfaceConfig};
use tun2::{ Configuration, create_as_async };
use tun::{ Configuration, create_as_async };
#[cfg(target_os = "linux")]

View File

@ -9,7 +9,7 @@ use std::net::{ SocketAddr, Ipv4Addr, IpAddr };
use std::collections::HashMap;
use aes_gcm::{ aead::{Aead, AeadCore, KeyInit, OsRng},
Aes256Gcm, Nonce };
use tun2::{Configuration, create_as_async};
use tun::{Configuration, create_as_async};
#[cfg(target_os = "linux")]
use network_interface::{NetworkInterface, NetworkInterfaceConfig};