1. traffic stats not work.
2. magisk zip malformat
This commit is contained in:
Sijie.Sun
2025-05-27 09:28:28 +08:00
committed by GitHub
parent d7c3179c6e
commit f9c24bc205
21 changed files with 151 additions and 59 deletions

View File

@@ -3,7 +3,7 @@ name = "easytier"
description = "A full meshed p2p VPN, connecting all your devices in one network with one command."
homepage = "https://github.com/EasyTier/EasyTier"
repository = "https://github.com/EasyTier/EasyTier"
version = "2.3.0"
version = "2.3.1"
edition = "2021"
authors = ["kkrainbow"]
keywords = ["vpn", "p2p", "network", "easytier"]

View File

@@ -109,6 +109,9 @@ pub fn get_machine_id() -> uuid::Uuid {
))]
let gen_mid = machine_uid::get()
.map(|x| {
if x.is_empty() {
return uuid::Uuid::new_v4();
}
let mut b = [0u8; 16];
crate::tunnel::generate_digest_from_str("", x.as_str(), &mut b);
uuid::Uuid::from_bytes(b)

View File

@@ -55,7 +55,7 @@ impl std::fmt::Debug for PingIntervalController {
impl PingIntervalController {
fn new(throughput: Arc<Throughput>, loss_counter: Arc<AtomicU32>) -> Self {
let last_throughput = *throughput;
let last_throughput = (*throughput).clone();
Self {
throughput,
@@ -92,7 +92,7 @@ impl PingIntervalController {
self.backoff_idx = 0;
}
self.last_throughput = *self.throughput;
self.last_throughput = (*self.throughput).clone();
if (self.logic_time - self.last_send_logic_time) < (1 << self.backoff_idx) {
return false;

View File

@@ -1,4 +1,7 @@
use std::sync::atomic::{AtomicU32, Ordering::Relaxed};
use std::{
cell::UnsafeCell,
sync::atomic::{AtomicU32, Ordering::Relaxed},
};
pub struct WindowLatency {
latency_us_window: Vec<AtomicU32>,
@@ -58,13 +61,38 @@ impl WindowLatency {
}
}
#[derive(Default, Copy, Clone, Debug)]
#[derive(Debug)]
pub struct Throughput {
tx_bytes: u64,
rx_bytes: u64,
tx_bytes: UnsafeCell<u64>,
rx_bytes: UnsafeCell<u64>,
tx_packets: UnsafeCell<u64>,
rx_packets: UnsafeCell<u64>,
}
tx_packets: u64,
rx_packets: u64,
impl Clone for Throughput {
fn clone(&self) -> Self {
Self {
tx_bytes: UnsafeCell::new(unsafe { *self.tx_bytes.get() }),
rx_bytes: UnsafeCell::new(unsafe { *self.rx_bytes.get() }),
tx_packets: UnsafeCell::new(unsafe { *self.tx_packets.get() }),
rx_packets: UnsafeCell::new(unsafe { *self.rx_packets.get() }),
}
}
}
// add sync::Send and sync::Sync traits to Throughput
unsafe impl Send for Throughput {}
unsafe impl Sync for Throughput {}
impl Default for Throughput {
fn default() -> Self {
Self {
tx_bytes: UnsafeCell::new(0),
rx_bytes: UnsafeCell::new(0),
tx_packets: UnsafeCell::new(0),
rx_packets: UnsafeCell::new(0),
}
}
}
impl Throughput {
@@ -73,34 +101,32 @@ impl Throughput {
}
pub fn tx_bytes(&self) -> u64 {
self.tx_bytes
unsafe { *self.tx_bytes.get() }
}
pub fn rx_bytes(&self) -> u64 {
self.rx_bytes
unsafe { *self.rx_bytes.get() }
}
pub fn tx_packets(&self) -> u64 {
self.tx_packets
unsafe { *self.tx_packets.get() }
}
pub fn rx_packets(&self) -> u64 {
self.rx_packets
unsafe { *self.rx_packets.get() }
}
pub fn record_tx_bytes(&self, bytes: u64) {
#[allow(invalid_reference_casting)]
unsafe {
*(&self.tx_bytes as *const u64 as *mut u64) += bytes;
*(&self.tx_packets as *const u64 as *mut u64) += 1;
*self.tx_bytes.get() += bytes;
*self.tx_packets.get() += 1;
}
}
pub fn record_rx_bytes(&self, bytes: u64) {
#[allow(invalid_reference_casting)]
unsafe {
*(&self.rx_bytes as *const u64 as *mut u64) += bytes;
*(&self.rx_packets as *const u64 as *mut u64) += 1;
*self.rx_bytes.get() += bytes;
*self.rx_packets.get() += 1;
}
}
}