From 7c40a96e84d6c9fee99ffe09a3fe53e3803acd3b Mon Sep 17 00:00:00 2001 From: Jialun Cai Date: Thu, 27 Nov 2025 10:56:58 +1100 Subject: [PATCH] Fix edition --- Cargo.toml | 4 ++-- README.md | 6 +++--- src/device/handle.rs | 4 ++-- src/device/mod.rs | 2 +- src/device/peer/handle.rs | 6 +++--- src/device/peer/handshake.rs | 4 ++-- src/device/peer/mod.rs | 2 +- src/noise/crypto.rs | 2 +- src/noise/handshake/cookie.rs | 2 +- src/noise/handshake/initiation.rs | 4 ++-- src/noise/handshake/response.rs | 6 +++--- src/tun/linux/sys.rs | 4 ++-- src/tun/linux/tun.rs | 4 ++-- src/tun/macos/sys.rs | 2 +- src/uapi/connection.rs | 2 +- src/uapi/protocol.rs | 2 +- tests/support.rs | 2 +- 17 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 96173af..112a0f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,13 +2,13 @@ name = "wiretun" description = "WireGuard Library" version = "0.5.0" -authors = ["zarvd "] +authors = ["Jialun Cai "] keywords = ["wireguard", "networking"] repository = "https://github.com/clnv/wiretun" homepage = "https://github.com/clnv/wiretun" documentation = "https://docs.rs/wiretun" license = "Apache-2.0" -edition = "2024" +edition = "2021" [features] default = ["native"] diff --git a/README.md b/README.md index 19ddd38..cc94217 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # WireTun -[github](https://github.com/zarvd/wiretun) +[github](https://github.com/clnv/wiretun) [crates.io](https://crates.io/crates/wiretun) [docs.rs](https://docs.rs/wiretun) -[build status](https://github.com/zarvd/wiretun/actions?query%3Amaster) -[dependency status](https://deps.rs/repo/github/zarvd/wiretun) +[build status](https://github.com/clnv/wiretun/actions?query%3Amaster) +[dependency status](https://deps.rs/repo/github/clnv/wiretun) This library provides a cross-platform, asynchronous (with [Tokio](https://tokio.rs/)) [WireGuard](https://www.wireguard.com/) implementation. diff --git a/src/device/handle.rs b/src/device/handle.rs index ec92023..fb69a5a 100644 --- a/src/device/handle.rs +++ b/src/device/handle.rs @@ -7,14 +7,14 @@ use tokio::task::JoinHandle; use tokio_util::sync::CancellationToken; use tracing::{debug, error, warn}; -use super::DeviceInner; use super::inbound::{Endpoint, Transport}; use super::peer::InboundEvent; -use crate::Tun; +use super::DeviceInner; use crate::noise::crypto::LocalStaticSecret; use crate::noise::handshake::{Cookie, IncomingInitiation}; use crate::noise::protocol; use crate::noise::protocol::Message; +use crate::Tun; pub(super) struct DeviceHandle { token: CancellationToken, diff --git a/src/device/mod.rs b/src/device/mod.rs index b26e851..7905705 100644 --- a/src/device/mod.rs +++ b/src/device/mod.rs @@ -21,9 +21,9 @@ use tokio::sync::Mutex as AsyncMutex; use tokio_util::sync::CancellationToken; use tracing::debug; -use crate::Tun; use crate::noise::crypto::LocalStaticSecret; use crate::noise::handshake::Cookie; +use crate::Tun; use handle::DeviceHandle; use inbound::Inbound; use peer::{Peer, PeerIndex, Session}; diff --git a/src/device/peer/handle.rs b/src/device/peer/handle.rs index bb22e56..f14717a 100644 --- a/src/device/peer/handle.rs +++ b/src/device/peer/handle.rs @@ -8,13 +8,13 @@ use tokio_util::sync::CancellationToken; use tracing::{debug, info, warn}; use super::{InboundEvent, InboundRx, OutboundEvent, OutboundRx, Peer, Session}; -use crate::Tun; use crate::device::{Endpoint, Transport}; use crate::noise::handshake::IncomingInitiation; use crate::noise::protocol::{ - self, COOKIE_REPLY_PACKET_SIZE, CookieReply, HANDSHAKE_RESPONSE_PACKET_SIZE, HandshakeResponse, - TransportData, + self, CookieReply, HandshakeResponse, TransportData, COOKIE_REPLY_PACKET_SIZE, + HANDSHAKE_RESPONSE_PACKET_SIZE, }; +use crate::Tun; pub(crate) struct PeerHandle { token: CancellationToken, diff --git a/src/device/peer/handshake.rs b/src/device/peer/handshake.rs index 84ca549..06c15f4 100644 --- a/src/device/peer/handshake.rs +++ b/src/device/peer/handshake.rs @@ -1,11 +1,11 @@ use super::session::{Session, SessionIndex}; use crate::noise::protocol::HandshakeResponse; use crate::noise::{ - Error, - crypto::{PeerStaticSecret, kdf2}, + crypto::{kdf2, PeerStaticSecret}, handshake::{ IncomingInitiation, IncomingResponse, MacGenerator, OutgoingInitiation, OutgoingResponse, }, + Error, }; enum State { diff --git a/src/device/peer/mod.rs b/src/device/peer/mod.rs index 4c86631..04a1266 100644 --- a/src/device/peer/mod.rs +++ b/src/device/peer/mod.rs @@ -19,12 +19,12 @@ use std::time::Duration; use tokio::sync::mpsc; use tracing::{debug, warn}; -use crate::Tun; use crate::device::inbound::{Endpoint, Transport}; use crate::noise::crypto; use crate::noise::crypto::PeerStaticSecret; use crate::noise::handshake::IncomingInitiation; use crate::noise::protocol; +use crate::Tun; use handshake::Handshake; use monitor::PeerMonitor; use session::{ActiveSession, SessionIndex}; diff --git a/src/noise/crypto.rs b/src/noise/crypto.rs index 532509b..5b1bce5 100644 --- a/src/noise/crypto.rs +++ b/src/noise/crypto.rs @@ -1,6 +1,6 @@ use blake2::{ - Blake2s256, Blake2sMac, Digest, digest::{FixedOutput, Mac, Update}, + Blake2s256, Blake2sMac, Digest, }; use rand_core::OsRng; diff --git a/src/noise/handshake/cookie.rs b/src/noise/handshake/cookie.rs index f5e65e3..3980b04 100644 --- a/src/noise/handshake/cookie.rs +++ b/src/noise/handshake/cookie.rs @@ -6,7 +6,7 @@ use bytes::{BufMut, BytesMut}; use rand_core::{OsRng, RngCore}; use super::{LABEL_COOKIE, LABEL_MAC1}; -use crate::noise::crypto::{LocalStaticSecret, PeerStaticSecret, hash, mac, xaead_encrypt}; +use crate::noise::crypto::{hash, mac, xaead_encrypt, LocalStaticSecret, PeerStaticSecret}; const MESSAGE_TYPE_COOKIE_REPLY: u8 = 3u8; const PACKET_SIZE: usize = 64; diff --git a/src/noise/handshake/initiation.rs b/src/noise/handshake/initiation.rs index 38b69c1..e23b5f6 100644 --- a/src/noise/handshake/initiation.rs +++ b/src/noise/handshake/initiation.rs @@ -1,12 +1,12 @@ use bytes::{BufMut, BytesMut}; -use super::{CONSTRUCTION, IDENTIFIER, MacGenerator}; +use super::{MacGenerator, CONSTRUCTION, IDENTIFIER}; use crate::noise::crypto::{EphemeralPrivateKey, LocalStaticSecret, PeerStaticSecret, PublicKey}; use crate::noise::protocol::HandshakeInitiation; use crate::noise::{ - Error, crypto::{aead_decrypt, aead_encrypt, gen_ephemeral_key, hash, kdf1, kdf2}, timestamp::Timestamp, + Error, }; const MESSAGE_TYPE_HANDSHAKE_INITIATION: u8 = 1u8; diff --git a/src/noise/handshake/response.rs b/src/noise/handshake/response.rs index 5c81671..80d74c3 100644 --- a/src/noise/handshake/response.rs +++ b/src/noise/handshake/response.rs @@ -3,11 +3,11 @@ use bytes::{BufMut, BytesMut}; use super::{IncomingInitiation, MacGenerator, OutgoingInitiation}; use crate::noise::protocol::HandshakeResponse; use crate::noise::{ - Error, crypto::{ - EphemeralPrivateKey, PeerStaticSecret, PublicKey, aead_decrypt, aead_encrypt, - gen_ephemeral_key, hash, kdf1, kdf3, + aead_decrypt, aead_encrypt, gen_ephemeral_key, hash, kdf1, kdf3, EphemeralPrivateKey, + PeerStaticSecret, PublicKey, }, + Error, }; const MESSAGE_TYPE_HANDSHAKE_RESPONSE: u8 = 2u8; diff --git a/src/tun/linux/sys.rs b/src/tun/linux/sys.rs index 5603253..369edfd 100644 --- a/src/tun/linux/sys.rs +++ b/src/tun/linux/sys.rs @@ -2,8 +2,8 @@ use std::mem; use std::os::fd::{AsRawFd, RawFd}; use libc::{__c_anonymous_ifr_ifru, c_char, ifreq}; -use nix::fcntl::{FcntlArg, OFlag, fcntl}; -use nix::sys::socket::{AddressFamily, SockFlag, SockType, socket}; +use nix::fcntl::{fcntl, FcntlArg, OFlag}; +use nix::sys::socket::{socket, AddressFamily, SockFlag, SockType}; use nix::{ioctl_read_bad, ioctl_write_ptr_bad}; use crate::tun::Error; diff --git a/src/tun/linux/tun.rs b/src/tun/linux/tun.rs index ab1542d..44c4fbc 100644 --- a/src/tun/linux/tun.rs +++ b/src/tun/linux/tun.rs @@ -10,9 +10,9 @@ use nix::sys::stat::Mode; use tokio::io::unix::AsyncFd; use tracing::debug; -use crate::Tun; -use crate::tun::Error; use crate::tun::linux::sys::{self, get_mtu, ioctl_tun_set_iff, set_mtu, set_nonblocking}; +use crate::tun::Error; +use crate::Tun; const DEVICE_PATH: &str = "/dev/net/tun"; diff --git a/src/tun/macos/sys.rs b/src/tun/macos/sys.rs index e8fd814..fbd59fd 100644 --- a/src/tun/macos/sys.rs +++ b/src/tun/macos/sys.rs @@ -3,7 +3,7 @@ use std::os::fd::RawFd; use std::{io, mem, ptr}; use libc::*; -use nix::fcntl::{FcntlArg, OFlag, fcntl}; +use nix::fcntl::{fcntl, FcntlArg, OFlag}; use nix::{ioctl_read_bad, ioctl_write_ptr_bad}; use crate::tun::Error; diff --git a/src/uapi/connection.rs b/src/uapi/connection.rs index 7386c58..345c2d7 100644 --- a/src/uapi/connection.rs +++ b/src/uapi/connection.rs @@ -1,8 +1,8 @@ use bytes::Bytes; use std::collections::HashSet; use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader}; -use tokio::net::UnixStream; use tokio::net::unix::{OwnedReadHalf, OwnedWriteHalf}; +use tokio::net::UnixStream; use tracing::debug; use super::{Error, Request, Response, SetDevice, SetPeer}; diff --git a/src/uapi/protocol.rs b/src/uapi/protocol.rs index 16b26af..97a64e8 100644 --- a/src/uapi/protocol.rs +++ b/src/uapi/protocol.rs @@ -4,8 +4,8 @@ use std::time::SystemTime; use bytes::{BufMut, Bytes, BytesMut}; -use crate::Cidr; use crate::noise::crypto; +use crate::Cidr; pub enum Request { Get, diff --git a/tests/support.rs b/tests/support.rs index 89bd355..c4773b2 100644 --- a/tests/support.rs +++ b/tests/support.rs @@ -9,7 +9,7 @@ use std::sync::{Arc, Mutex as StdMutex}; use async_trait::async_trait; use rand_core::OsRng; -use tokio::sync::{Mutex, mpsc}; +use tokio::sync::{mpsc, Mutex}; use wiretun::noise::crypto::LocalStaticSecret; use wiretun::*;