diff options
author | 2024-02-18 17:17:17 +0800 | |
---|---|---|
committer | 2024-02-18 17:17:17 +0800 | |
commit | 4ac53a5a39e74d5eb12bee22d0fd4783acaae670 (patch) | |
tree | ca442e698e6870b7f6c5053b54fff82e2a95626e /src/client.rs | |
parent | 7251759bdaf4b7d170575bdd6d2062bbd9f338bb (diff) | |
download | rathole-4ac53a5a39e74d5eb12bee22d0fd4783acaae670.tar.gz rathole-4ac53a5a39e74d5eb12bee22d0fd4783acaae670.tar.zst rathole-4ac53a5a39e74d5eb12bee22d0fd4783acaae670.zip |
feat: optional rustls support (#330)
* initial implementation of rustls support
* Refactor create_self_signed_cert.sh script
* resolve lint errors
* Fix handling of Option in tls.rs
* Update cargo-hack check command and feature dependencies
* fix missing point
* Add conditional check to skip test if client or server is not enabled
* clean up things
* fix for windows CI
* try fixing Windows CI
* Update src/main.rs
* Update src/transport/websocket.rs
* add missing messages
* split the tls mod
Co-authored-by: Ning Sun <n@sunng.info>
Diffstat (limited to 'src/client.rs')
-rw-r--r-- | src/client.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/client.rs b/src/client.rs index 95a5a74..2564869 100644 --- a/src/client.rs +++ b/src/client.rs @@ -8,8 +8,9 @@ use crate::protocol::{ }; use crate::transport::{AddrMaybeCached, SocketOpts, TcpTransport, Transport}; use anyhow::{anyhow, bail, Context, Result}; +use backoff::backoff::Backoff; +use backoff::future::retry_notify; use backoff::ExponentialBackoff; -use backoff::{backoff::Backoff, future::retry_notify}; use bytes::{Bytes, BytesMut}; use std::collections::HashMap; use std::net::SocketAddr; @@ -22,9 +23,9 @@ use tracing::{debug, error, info, instrument, trace, warn, Instrument, Span}; #[cfg(feature = "noise")] use crate::transport::NoiseTransport; -#[cfg(feature = "tls")] +#[cfg(any(feature = "native-tls", feature = "rustls"))] use crate::transport::TlsTransport; -#[cfg(feature = "websocket")] +#[cfg(any(feature = "websocket-native-tls", feature = "websocket-rustls"))] use crate::transport::WebsocketTransport; use crate::constants::{run_control_chan_backoff, UDP_BUFFER_SIZE, UDP_SENDQ_SIZE, UDP_TIMEOUT}; @@ -47,13 +48,13 @@ pub async fn run_client( client.run(shutdown_rx, update_rx).await } TransportType::Tls => { - #[cfg(feature = "tls")] + #[cfg(any(feature = "native-tls", feature = "rustls"))] { let mut client = Client::<TlsTransport>::from(config).await?; client.run(shutdown_rx, update_rx).await } - #[cfg(not(feature = "tls"))] - crate::helper::feature_not_compile("tls") + #[cfg(not(any(feature = "native-tls", feature = "rustls")))] + crate::helper::feature_neither_compile("native-tls", "rustls") } TransportType::Noise => { #[cfg(feature = "noise")] @@ -65,13 +66,13 @@ pub async fn run_client( crate::helper::feature_not_compile("noise") } TransportType::Websocket => { - #[cfg(feature = "websocket")] + #[cfg(any(feature = "websocket-native-tls", feature = "websocket-rustls"))] { let mut client = Client::<WebsocketTransport>::from(config).await?; client.run(shutdown_rx, update_rx).await } - #[cfg(not(feature = "websocket"))] - crate::helper::feature_not_compile("websocket") + #[cfg(not(any(feature = "websocket-native-tls", feature = "websocket-rustls")))] + crate::helper::feature_neither_compile("websocket-native-tls", "websocket-rustls") } } } |