mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
feat: separate zstd and faketcp into features (#1861)
* feat: separate faketcp into a feature * fix: no need to initialize out_len * feat: separate zstd into a feature * clippy: remove unnecessary cast, because for unix size_t always equals usize
This commit is contained in:
@@ -716,7 +716,7 @@ fn open_bpf_device() -> io::Result<OwnedFd> {
|
||||
|
||||
fn set_ifreq_name(ifr: &mut libc::ifreq, interface_name: &str) -> io::Result<()> {
|
||||
let bytes = interface_name.as_bytes();
|
||||
let ifnamsiz = libc::IFNAMSIZ as usize;
|
||||
let ifnamsiz = libc::IFNAMSIZ;
|
||||
if bytes.len() >= ifnamsiz {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidInput,
|
||||
@@ -932,7 +932,7 @@ impl MacosBpfTun {
|
||||
|
||||
let pkt_start = off + pkt_range.start;
|
||||
let pkt_end = off + pkt_range.end;
|
||||
let shift = (pkt_range.start as usize).saturating_sub(hdr_len as usize);
|
||||
let shift = pkt_range.start.saturating_sub(hdr_len as usize);
|
||||
if shift != 0 && shifted_record_logs_left > 0 {
|
||||
shifted_record_logs_left -= 1;
|
||||
warn!(
|
||||
@@ -1039,7 +1039,7 @@ impl stack::Tun for MacosBpfTun {
|
||||
Ok(())
|
||||
};
|
||||
|
||||
let mut out_len = 0usize;
|
||||
let mut out_len: usize;
|
||||
let res = match self.link_type {
|
||||
LinkType::En10Mb => {
|
||||
out_len = packet.len();
|
||||
|
||||
@@ -15,7 +15,6 @@ use self::packet_def::ZCPacket;
|
||||
|
||||
pub mod buf;
|
||||
pub mod common;
|
||||
pub mod fake_tcp;
|
||||
pub mod filter;
|
||||
pub mod mpsc;
|
||||
pub mod packet_def;
|
||||
@@ -33,6 +32,9 @@ pub const PROTO_PORT_OFFSET: &[(&str, u16)] = &[
|
||||
("faketcp", 3),
|
||||
];
|
||||
|
||||
#[cfg(feature = "faketcp")]
|
||||
pub mod fake_tcp;
|
||||
|
||||
#[cfg(feature = "wireguard")]
|
||||
pub mod wireguard;
|
||||
|
||||
|
||||
@@ -288,6 +288,7 @@ pub const AES_GCM_ENCRYPTION_RESERVED: usize = std::mem::size_of::<AesGcmTail>()
|
||||
#[repr(u8)]
|
||||
pub enum CompressorAlgo {
|
||||
None = 0,
|
||||
#[cfg(feature = "zstd")]
|
||||
ZstdDefault = 1,
|
||||
}
|
||||
|
||||
@@ -301,6 +302,7 @@ pub const COMPRESSOR_TAIL_SIZE: usize = std::mem::size_of::<CompressorTail>();
|
||||
impl CompressorTail {
|
||||
pub fn get_algo(&self) -> Option<CompressorAlgo> {
|
||||
match self.algo {
|
||||
#[cfg(feature = "zstd")]
|
||||
1 => Some(CompressorAlgo::ZstdDefault),
|
||||
_ => None,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user