mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-10-08 10:56:13 -08:00
1 parent
5477d4bca2
commit
7223677264
45 files changed
+5152
-4997
No files matched your search
+67
-60
@@ -18,76 +18,76 @@ crate-type = ["rlib", "cdylib"]
|
||||
wasm-opt = ["-Oz", "--enable-bulk-memory", "--enable-nontrapping-float-to-int"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
ariadne = { version = "0.5", optional = true }
|
||||
arc-swap = "1.7"
|
||||
async-ringbuf = "0.3.1"
|
||||
async-trait = "0.1.74"
|
||||
auto_impl = "1.1.0"
|
||||
base64 = "0.22"
|
||||
bitflags = "2.5"
|
||||
bytecodec = "0.4.15"
|
||||
bytes = "1.5.0"
|
||||
chrono = { version = "0.4.37", features = ["clock"] }
|
||||
cidr = { version = "0.3.1", features = ["serde"] }
|
||||
crossbeam = "0.8.4"
|
||||
dashmap = "6.0"
|
||||
derive_builder = "0.20.2"
|
||||
easytier-proto = { path = "../easytier-proto", default-features = false, features = ["core"] }
|
||||
futures = "0.3"
|
||||
guarden = "0.2"
|
||||
hmac = "0.12.1"
|
||||
http-body-util = { version = "0.1", optional = true }
|
||||
hyper = { version = "1", default-features = false, features = ["client", "http1"], optional = true }
|
||||
hyper-util = { version = "0.1", default-features = false, features = ["tokio"], optional = true }
|
||||
idna = "1.0"
|
||||
atomic-shim = "0.2.0"
|
||||
ordered_hash_map = "0.5.0"
|
||||
parking_lot = "0.12.1"
|
||||
percent-encoding = "2.3.1"
|
||||
petgraph = "0.8.1"
|
||||
pin-project-lite = "0.2.13"
|
||||
prefix-trie = { version = "0.7.0", features = ["cidr"] }
|
||||
prost = "0.14.3"
|
||||
prost-types = "0.14.3"
|
||||
rand = "0.8.5"
|
||||
quanta = "0.12"
|
||||
anyhow.workspace = true
|
||||
ariadne = { version = "0.6", optional = true }
|
||||
arc-swap.workspace = true
|
||||
async-ringbuf = "0.3.9"
|
||||
async-trait.workspace = true
|
||||
auto_impl.workspace = true
|
||||
base64.workspace = true
|
||||
bitflags = "2.13"
|
||||
bytecodec.workspace = true
|
||||
bytes.workspace = true
|
||||
chrono = { workspace = true, features = ["clock"] }
|
||||
cidr = { workspace = true, features = ["serde"] }
|
||||
crossbeam.workspace = true
|
||||
dashmap.workspace = true
|
||||
bon.workspace = true
|
||||
easytier-proto = { workspace = true, features = ["core"] }
|
||||
futures.workspace = true
|
||||
guarden.workspace = true
|
||||
hmac.workspace = true
|
||||
http-body-util = { workspace = true, optional = true }
|
||||
hyper = { workspace = true, features = ["client", "http1"], optional = true }
|
||||
hyper-util = { workspace = true, features = ["tokio"], optional = true }
|
||||
idna = "1.1"
|
||||
atomic-shim.workspace = true
|
||||
ordered_hash_map = "0.6.1"
|
||||
parking_lot.workspace = true
|
||||
percent-encoding.workspace = true
|
||||
petgraph = "0.8.3"
|
||||
pin-project-lite.workspace = true
|
||||
prefix-trie = { version = "0.10.1", features = ["cidr"] }
|
||||
prost.workspace = true
|
||||
prost-types.workspace = true
|
||||
rand.workspace = true
|
||||
quanta.workspace = true
|
||||
ring = { version = "0.17", optional = true }
|
||||
rustls = { version = "0.23", default-features = false, features = ["ring", "std", "tls12"], optional = true }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
sha2 = "0.10.8"
|
||||
smoltcp = { git = "https://github.com/smoltcp-rs/smoltcp.git", rev = "0a926767a68bc88d5512afefa7529c5ecdade4ea", optional = true, default-features = false }
|
||||
stun_codec = "0.3.4"
|
||||
thiserror = "1.0"
|
||||
tracing = "0.1"
|
||||
strum = { version = "0.27.2", features = ["derive"] }
|
||||
toml = "0.8.12"
|
||||
tokio = { version = "1", default-features = false, features = [
|
||||
rustls = { workspace = true, features = ["ring", "std", "tls12"], optional = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
serde_json.workspace = true
|
||||
sha2.workspace = true
|
||||
smoltcp = { workspace = true, optional = true }
|
||||
stun_codec.workspace = true
|
||||
thiserror.workspace = true
|
||||
tracing.workspace = true
|
||||
strum = { workspace = true, features = ["derive"] }
|
||||
toml.workspace = true
|
||||
tokio = { workspace = true, features = [
|
||||
"rt",
|
||||
"time",
|
||||
"sync",
|
||||
"macros",
|
||||
"io-util",
|
||||
] }
|
||||
tokio-util = { version = "0.7", features = ["io", "rt"] }
|
||||
tokio-rustls = { version = "0.26", default-features = false, optional = true }
|
||||
url = { version = "2.5", features = ["serde"] }
|
||||
wildmatch = "2.3.4"
|
||||
uuid = { version = "1.5.0", features = ["v4", "fast-rng", "serde"] }
|
||||
webpki-roots = { version = "0.26", optional = true }
|
||||
x25519-dalek = { version = "2.0", features = ["static_secrets"] }
|
||||
zerocopy = { version = "0.7.32", features = ["derive", "simd"] }
|
||||
zstd = { version = "0.13", optional = true }
|
||||
aes-gcm = { version = "0.10.3", optional = true }
|
||||
chacha20poly1305 = { version = "0.10.1", optional = true }
|
||||
tokio-util = { workspace = true, features = ["io", "rt"] }
|
||||
tokio-rustls = { workspace = true, optional = true }
|
||||
url = { workspace = true, features = ["serde"] }
|
||||
wildmatch = "2.6.1"
|
||||
uuid = { workspace = true, features = ["v4", "fast-rng", "serde"] }
|
||||
webpki-roots = { version = "1.0", optional = true }
|
||||
x25519-dalek = { workspace = true, features = ["static_secrets"] }
|
||||
zerocopy = { workspace = true, features = ["derive", "simd"] }
|
||||
zstd = { version = "0.14", optional = true }
|
||||
aes-gcm = { version = "0.11.1", optional = true }
|
||||
chacha20poly1305 = { version = "0.11.0", optional = true }
|
||||
openssl = { version = "0.10", optional = true, features = ["vendored"] }
|
||||
|
||||
[target.'cfg(all(target_arch = "wasm32", target_os = "unknown"))'.dependencies]
|
||||
getrandom-02 = { package = "getrandom", version = "0.2.15", features = ["js"] }
|
||||
getrandom-03 = { package = "getrandom", version = "0.3.2", features = ["wasm_js"] }
|
||||
getrandom-02 = { package = "getrandom", version = "0.2.17", features = ["js"] }
|
||||
getrandom-03 = { package = "getrandom", version = "0.3.4", features = ["wasm_js"] }
|
||||
snow = { version = "0.10.0", default-features = false, features = ["default-resolver", "default-resolver-crypto"] }
|
||||
uuid = { version = "1.5.0", features = ["js"] }
|
||||
uuid = { workspace = true, features = ["js"] }
|
||||
wasm-bindgen = "0.2"
|
||||
|
||||
[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies]
|
||||
@@ -153,4 +153,11 @@ tracing-log = ["tracing/log"]
|
||||
zstd = ["dep:zstd"]
|
||||
|
||||
[target.'cfg(not(target_os = "wasi"))'.dev-dependencies]
|
||||
tokio = { version = "1", default-features = false, features = ["rt-multi-thread"] }
|
||||
tokio = { workspace = true, features = ["rt-multi-thread"] }
|
||||
|
||||
[package.metadata.cargo-machete]
|
||||
ignored = [
|
||||
# Enable browser entropy backends for transitive rand/snow dependencies.
|
||||
"getrandom-02",
|
||||
"getrandom-03",
|
||||
]
|
||||
@@ -428,11 +428,11 @@ pub struct ConsoleLoggerConfig {
|
||||
pub level: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, derive_builder::Builder)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, bon::Builder)]
|
||||
pub struct LoggingConfig {
|
||||
#[builder(setter(into, strip_option), default = None)]
|
||||
#[builder(into)]
|
||||
pub file_logger: Option<FileLoggerConfig>,
|
||||
#[builder(setter(into, strip_option), default = None)]
|
||||
#[builder(into)]
|
||||
pub console_logger: Option<ConsoleLoggerConfig>,
|
||||
}
|
||||
|
||||
|
||||
@@ -474,7 +474,7 @@ mod tests {
|
||||
!try_process_wrapped_tcp_packet_from_nic(
|
||||
&mut packet,
|
||||
context(transport),
|
||||
|_| false,
|
||||
|_, _| false,
|
||||
|_| async { true },
|
||||
)
|
||||
.await
|
||||
|
||||
@@ -16,7 +16,7 @@ use easytier_proto::{
|
||||
common::{FlagsInConfig, PeerFeatureFlag, SecureModeConfig, StunInfo, TunnelInfo},
|
||||
peer_rpc::{PeerGroupInfo, TrustedCredentialPubkeyProof},
|
||||
};
|
||||
use hmac::{Hmac, Mac};
|
||||
use hmac::{Hmac, KeyInit, Mac};
|
||||
use sha2::Sha256;
|
||||
|
||||
pub use crate::config::{NetworkIdentity, NetworkSecretDigest};
|
||||
|
||||
@@ -12,7 +12,7 @@ use std::{
|
||||
|
||||
use dashmap::{DashMap, DashSet};
|
||||
use easytier_proto::common::FlagsInConfig;
|
||||
use guarden::{Guard, defer};
|
||||
use guarden::defer;
|
||||
use tokio::sync::{
|
||||
Mutex, RwLock, RwLockReadGuard,
|
||||
mpsc::{self, UnboundedReceiver, UnboundedSender},
|
||||
|
||||
@@ -702,7 +702,7 @@ impl OspfRouteTable {
|
||||
.load()
|
||||
.iter()
|
||||
.filter(|(_, pv)| pv.peer_id != peer_id)
|
||||
.map(|(cidr, _)| *cidr)
|
||||
.map(|(cidr, _)| cidr)
|
||||
.collect()
|
||||
}
|
||||
|
||||
@@ -711,7 +711,7 @@ impl OspfRouteTable {
|
||||
.load()
|
||||
.iter()
|
||||
.filter(|(_, pv)| pv.peer_id != peer_id)
|
||||
.map(|(cidr, _)| *cidr)
|
||||
.map(|(cidr, _)| cidr)
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use aes_gcm::{AeadCore, AeadInPlace, Aes128Gcm, Aes256Gcm, Key, KeyInit};
|
||||
use rand::rngs::OsRng;
|
||||
use aes_gcm::{AeadInOut, Aes128Gcm, Aes256Gcm, Key, KeyInit};
|
||||
use rand::{RngCore, rngs::OsRng};
|
||||
use zerocopy::{AsBytes, FromBytes};
|
||||
|
||||
use crate::packet::{StandardAeadTail, ZCPacket};
|
||||
@@ -54,16 +54,16 @@ impl Encryptor for AesGcmCipher {
|
||||
let tag = aes_tail.tag.into();
|
||||
|
||||
let rs = match &self.cipher {
|
||||
AesGcmEnum::AES128GCM(aes_gcm) => aes_gcm.decrypt_in_place_detached(
|
||||
AesGcmEnum::AES128GCM(aes_gcm) => aes_gcm.decrypt_inout_detached(
|
||||
&nonce,
|
||||
&[],
|
||||
&mut zc_packet.mut_payload()[..text_len],
|
||||
(&mut zc_packet.mut_payload()[..text_len]).into(),
|
||||
&tag,
|
||||
),
|
||||
AesGcmEnum::AES256GCM(aes_gcm) => aes_gcm.decrypt_in_place_detached(
|
||||
AesGcmEnum::AES256GCM(aes_gcm) => aes_gcm.decrypt_inout_detached(
|
||||
&nonce,
|
||||
&[],
|
||||
&mut zc_packet.mut_payload()[..text_len],
|
||||
(&mut zc_packet.mut_payload()[..text_len]).into(),
|
||||
&tag,
|
||||
),
|
||||
};
|
||||
@@ -107,16 +107,24 @@ impl Encryptor for AesGcmCipher {
|
||||
|
||||
let (tag, nonce) = match &self.cipher {
|
||||
AesGcmEnum::AES128GCM(aes_gcm) => {
|
||||
let nonce = nonce.unwrap_or_else(|| Aes128Gcm::generate_nonce(&mut OsRng));
|
||||
let nonce = nonce.unwrap_or_else(|| {
|
||||
let mut nonce = [0u8; StandardAeadTail::NONCE_SIZE];
|
||||
OsRng.fill_bytes(&mut nonce);
|
||||
nonce.into()
|
||||
});
|
||||
(
|
||||
aes_gcm.encrypt_in_place_detached(&nonce, &[], zc_packet.mut_payload()),
|
||||
aes_gcm.encrypt_inout_detached(&nonce, &[], zc_packet.mut_payload().into()),
|
||||
nonce,
|
||||
)
|
||||
}
|
||||
AesGcmEnum::AES256GCM(aes_gcm) => {
|
||||
let nonce = nonce.unwrap_or_else(|| Aes256Gcm::generate_nonce(&mut OsRng));
|
||||
let nonce = nonce.unwrap_or_else(|| {
|
||||
let mut nonce = [0u8; StandardAeadTail::NONCE_SIZE];
|
||||
OsRng.fill_bytes(&mut nonce);
|
||||
nonce.into()
|
||||
});
|
||||
(
|
||||
aes_gcm.encrypt_in_place_detached(&nonce, &[], zc_packet.mut_payload()),
|
||||
aes_gcm.encrypt_inout_detached(&nonce, &[], zc_packet.mut_payload().into()),
|
||||
nonce,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use chacha20poly1305::{AeadCore, AeadInPlace, ChaCha20Poly1305, Key, KeyInit};
|
||||
use rand::rngs::OsRng;
|
||||
use chacha20poly1305::{AeadInOut, ChaCha20Poly1305, Key, KeyInit};
|
||||
use rand::{RngCore, rngs::OsRng};
|
||||
use zerocopy::{AsBytes, FromBytes};
|
||||
|
||||
use crate::packet::{StandardAeadTail, ZCPacket};
|
||||
@@ -42,7 +42,12 @@ impl Encryptor for ChaCha20Cipher {
|
||||
let tag = tail.tag.into();
|
||||
|
||||
self.cipher
|
||||
.decrypt_in_place_detached(&nonce, &[], &mut zc_packet.mut_payload()[..text_len], &tag)
|
||||
.decrypt_inout_detached(
|
||||
&nonce,
|
||||
&[],
|
||||
(&mut zc_packet.mut_payload()[..text_len]).into(),
|
||||
&tag,
|
||||
)
|
||||
.map_err(|_| Error::DecryptionFailed)?;
|
||||
|
||||
let pm_header = zc_packet.mut_peer_manager_header().unwrap();
|
||||
@@ -76,11 +81,15 @@ impl Encryptor for ChaCha20Cipher {
|
||||
.map_err(|_| Error::EncryptionFailed)
|
||||
})
|
||||
.transpose()?
|
||||
.unwrap_or_else(|| ChaCha20Poly1305::generate_nonce(&mut OsRng));
|
||||
.unwrap_or_else(|| {
|
||||
let mut nonce = [0u8; StandardAeadTail::NONCE_SIZE];
|
||||
OsRng.fill_bytes(&mut nonce);
|
||||
nonce.into()
|
||||
});
|
||||
|
||||
let tag = self
|
||||
.cipher
|
||||
.encrypt_in_place_detached(&nonce, &[], zc_packet.mut_payload())
|
||||
.encrypt_inout_detached(&nonce, &[], zc_packet.mut_payload().into())
|
||||
.map_err(|_| Error::EncryptionFailed)?;
|
||||
|
||||
let tail = StandardAeadTail {
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::{
|
||||
|
||||
use anyhow::anyhow;
|
||||
use atomic_shim::AtomicU64;
|
||||
use hmac::{Hmac, Mac as _};
|
||||
use hmac::{Hmac, KeyInit as _, Mac as _};
|
||||
use rand::RngCore as _;
|
||||
use sha2::Sha256;
|
||||
use zerocopy::FromBytes;
|
||||
|
||||
Reference in new issue
Block a user