mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-10-12 23:36:14 -08:00
Building easytier and easytier-web together enabled both ring and aws-lc through reqwest 0.13. HTTPS endpoint discovery used rustls automatic provider selection and could panic before sending a ClientHello. Use reqwest rustls-no-provider to share ring, and explicitly install the process default before starting CLI, GUI and web services. Initialize it for standalone webhook construction too, retaining any provider already selected by the host. Pass ring directly to HTTPS discovery and WebSocket TLS builders so library use is independent of application initialization order. Keep existing certificate verification, SNI and protocol settings. Add a duplex-stream regression that reproduces the original panic with both backends enabled, and run it in CI. Explain provider selection and feature-unification constraints next to the relevant code. Validation: the new regression fails before the fix and passes after it. Docker tests pass: 10 discovery, 13 webhook, 2 WebSocket, WSS three-node AES-GCM relay, and WSS credential connectivity. Clippy with warnings denied and fmt pass. GUI, browser, WASI, minimal native, endpoint-only and WebSocket-only compile checks pass. Linux and Windows release dependency trees contain only the ring runtime backend. Fixes #2607
48 lines
1.4 KiB
Rust
48 lines
1.4 KiB
Rust
pub mod buf;
|
|
#[cfg(feature = "management")]
|
|
pub mod panic;
|
|
pub mod string;
|
|
|
|
use std::net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener};
|
|
use std::sync::{Arc, Weak};
|
|
|
|
#[cfg(feature = "management")]
|
|
pub type PeerRoutePair = crate::proto::api::instance::PeerRoutePair;
|
|
|
|
/// Select the process-wide TLS backend before starting application services.
|
|
pub fn init_crypto_provider() {
|
|
#[cfg(any(
|
|
feature = "endpoint-discovery",
|
|
feature = "quic",
|
|
feature = "websocket"
|
|
))]
|
|
{
|
|
// Cargo features are additive: another dependency can enable aws-lc
|
|
// alongside ring, making rustls's automatic selection panic (#2607).
|
|
// Keep an existing provider chosen by an embedding application.
|
|
let _ = rustls::crypto::ring::default_provider().install_default();
|
|
}
|
|
}
|
|
|
|
pub fn check_tcp_available(port: u16) -> bool {
|
|
let s = SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), port);
|
|
TcpListener::bind(s).is_ok()
|
|
}
|
|
|
|
pub fn find_free_tcp_port(mut range: std::ops::Range<u16>) -> Option<u16> {
|
|
range.find(|&port| check_tcp_available(port))
|
|
}
|
|
|
|
pub fn weak_upgrade<T>(weak: &Weak<T>) -> anyhow::Result<Arc<T>> {
|
|
weak.upgrade()
|
|
.ok_or_else(|| anyhow::anyhow!("{} not available", std::any::type_name::<T>()))
|
|
}
|
|
|
|
pub trait BoxExt: Sized {
|
|
fn boxed(self) -> Box<Self> {
|
|
Box::new(self)
|
|
}
|
|
}
|
|
|
|
impl<T> BoxExt for T {}
|