chore: prioritize http3-quinn over http3-s2n when both features are enabled (avoid compile error)
This commit is contained in:
parent
4aa149a261
commit
f7142828ac
6 changed files with 14 additions and 17 deletions
|
|
@ -15,9 +15,6 @@ use crate::{
|
|||
use hot_reload::{ReloaderReceiver, ReloaderService};
|
||||
use rpxy_lib::entrypoint;
|
||||
|
||||
#[cfg(all(feature = "http3-quinn", feature = "http3-s2n"))]
|
||||
compile_error!("feature \"http3-quinn\" and feature \"http3-s2n\" cannot be enabled at the same time");
|
||||
|
||||
fn main() {
|
||||
init_logger();
|
||||
|
||||
|
|
@ -29,8 +26,8 @@ fn main() {
|
|||
runtime.block_on(async {
|
||||
// Initially load options
|
||||
let Ok(parsed_opts) = parse_opts() else {
|
||||
error!("Invalid toml file");
|
||||
std::process::exit(1);
|
||||
error!("Invalid toml file");
|
||||
std::process::exit(1);
|
||||
};
|
||||
|
||||
if !parsed_opts.watch {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ pub struct ServerCrypto {
|
|||
// For Quic/HTTP3, only servers with no client authentication
|
||||
#[cfg(feature = "http3-quinn")]
|
||||
pub inner_global_no_client_auth: Arc<ServerConfig>,
|
||||
#[cfg(feature = "http3-s2n")]
|
||||
#[cfg(all(feature = "http3-s2n", not(feature = "http3-quinn")))]
|
||||
pub inner_global_no_client_auth: s2n_quic_rustls::Server,
|
||||
// For TLS over TCP/HTTP2 and 1.1, map of SNI to server_crypto for all given servers
|
||||
pub inner_local_map: Arc<SniServerCryptoMap>,
|
||||
|
|
@ -74,7 +74,7 @@ impl TryInto<Arc<ServerCrypto>> for &ServerCryptoBase {
|
|||
Ok(Arc::new(ServerCrypto {
|
||||
#[cfg(feature = "http3-quinn")]
|
||||
inner_global_no_client_auth: Arc::new(server_crypto_global),
|
||||
#[cfg(feature = "http3-s2n")]
|
||||
#[cfg(all(feature = "http3-s2n", not(feature = "http3-quinn")))]
|
||||
inner_global_no_client_auth: server_crypto_global,
|
||||
inner_local_map: Arc::new(server_crypto_local_map),
|
||||
}))
|
||||
|
|
@ -200,7 +200,7 @@ impl ServerCryptoBase {
|
|||
Ok(server_crypto_global)
|
||||
}
|
||||
|
||||
#[cfg(feature = "http3-s2n")]
|
||||
#[cfg(all(feature = "http3-s2n", not(feature = "http3-quinn")))]
|
||||
fn build_server_crypto_global(&self) -> Result<s2n_quic_rustls::Server, ReloaderError<ServerCryptoBase>> {
|
||||
let mut resolver_global = s2n_quic_rustls::rustls::server::ResolvesServerCertUsingSni::new();
|
||||
|
||||
|
|
@ -241,7 +241,7 @@ impl ServerCryptoBase {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "http3-s2n")]
|
||||
#[cfg(all(feature = "http3-s2n", not(feature = "http3-quinn")))]
|
||||
/// This is workaround for the version difference between rustls and s2n-quic-rustls
|
||||
fn parse_server_certs_and_keys_s2n(
|
||||
certs_and_keys: &CertsAndKeys,
|
||||
|
|
|
|||
|
|
@ -44,13 +44,13 @@ pub enum RpxyError {
|
|||
#[error("Quinn connection error: {0}")]
|
||||
QuinnConnectionFailed(#[from] quinn::ConnectionError),
|
||||
|
||||
#[cfg(feature = "http3-s2n")]
|
||||
#[cfg(all(feature = "http3-s2n", not(feature = "http3-quinn")))]
|
||||
#[error("s2n-quic validation error: {0}")]
|
||||
S2nQuicValidationError(#[from] s2n_quic_core::transport::parameters::ValidationError),
|
||||
#[cfg(feature = "http3-s2n")]
|
||||
#[cfg(all(feature = "http3-s2n", not(feature = "http3-quinn")))]
|
||||
#[error("s2n-quic connection error: {0}")]
|
||||
S2nQuicConnectionError(#[from] s2n_quic_core::connection::Error),
|
||||
#[cfg(feature = "http3-s2n")]
|
||||
#[cfg(all(feature = "http3-s2n", not(feature = "http3-quinn")))]
|
||||
#[error("s2n-quic start error: {0}")]
|
||||
S2nQuicStartError(#[from] s2n_quic::provider::StartError),
|
||||
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@ pub mod reexports {
|
|||
pub use rustls::{Certificate, PrivateKey};
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "http3-quinn", feature = "http3-s2n"))]
|
||||
compile_error!("feature \"http3-quinn\" and feature \"http3-s2n\" cannot be enabled at the same time");
|
||||
|
||||
/// Entrypoint that creates and spawns tasks of reverse proxy services
|
||||
pub async fn entrypoint<T>(
|
||||
proxy_config: &ProxyConfig,
|
||||
|
|
@ -40,6 +37,9 @@ pub async fn entrypoint<T>(
|
|||
where
|
||||
T: CryptoSource + Clone + Send + Sync + 'static,
|
||||
{
|
||||
#[cfg(all(feature = "http3-quinn", feature = "http3-s2n"))]
|
||||
warn!("Both \"http3-quinn\" and \"http3-s2n\" features are enabled. \"http3-quinn\" will be used");
|
||||
|
||||
// For initial message logging
|
||||
if proxy_config.listen_sockets.iter().any(|addr| addr.is_ipv6()) {
|
||||
info!("Listen both IPv4 and IPv6")
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ mod proxy_h3;
|
|||
mod proxy_main;
|
||||
#[cfg(feature = "http3-quinn")]
|
||||
mod proxy_quic_quinn;
|
||||
#[cfg(feature = "http3-s2n")]
|
||||
#[cfg(all(feature = "http3-s2n", not(feature = "http3-quinn")))]
|
||||
mod proxy_quic_s2n;
|
||||
mod socket;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use tokio::time::timeout;
|
|||
|
||||
#[cfg(feature = "http3-quinn")]
|
||||
use h3::{quic::BidiStream, quic::Connection as ConnectionQuic, server::RequestStream};
|
||||
#[cfg(feature = "http3-s2n")]
|
||||
#[cfg(all(feature = "http3-s2n", not(feature = "http3-quinn")))]
|
||||
use s2n_quic_h3::h3::{self, quic::BidiStream, quic::Connection as ConnectionQuic, server::RequestStream};
|
||||
|
||||
impl<U, T> Proxy<U, T>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue