Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dc/s2n-quic-dc/src/stream/recv/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl fmt::Display for Error {
}
}

impl std::error::Error for Error {}
impl core::error::Error for Error {}

impl IntoEvent<Error> for Error {
fn into_event(self) -> Error {
Expand Down
2 changes: 1 addition & 1 deletion dc/s2n-quic-dc/src/stream/send/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl fmt::Display for Error {
}
}

impl std::error::Error for Error {}
impl core::error::Error for Error {}

impl IntoEvent<Error> for Error {
fn into_event(self) -> Error {
Expand Down
1 change: 1 addition & 0 deletions quic/s2n-quic-core/events/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ struct TlsExporterReady<'a> {
#[event("connectivity:tls_handshake_failed")]
struct TlsHandshakeFailed<'a> {
session: crate::event::TlsSession<'a>,
error: &'a (dyn core::error::Error + Send + Sync + 'static),
}

#[event("connectivity:path_challenge_updated")]
Expand Down
3 changes: 1 addition & 2 deletions quic/s2n-quic-core/src/application/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ use core::{fmt, ops};
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Error(VarInt);

#[cfg(feature = "std")]
impl std::error::Error for Error {}
impl core::error::Error for Error {}

impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down
3 changes: 1 addition & 2 deletions quic/s2n-quic-core/src/buffer/deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ impl fmt::Display for FillError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for FillError {}
impl core::error::Error for FillError {}

#[cfg(feature = "std")]
impl From<FillError> for std::io::Error {
Expand Down
3 changes: 1 addition & 2 deletions quic/s2n-quic-core/src/connection/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ pub enum Error {
},
}

#[cfg(feature = "std")]
impl std::error::Error for Error {}
impl core::error::Error for Error {}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
1 change: 1 addition & 0 deletions quic/s2n-quic-core/src/crypto/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ pub trait Context<Crypto: crate::crypto::CryptoSuite> {
fn on_tls_handshake_failed(
&mut self,
session: &impl TlsSession,
error: &(dyn core::error::Error + Send + Sync + 'static),
) -> Result<(), crate::transport::Error>;

/// Receives data from the initial packet space
Expand Down
10 changes: 8 additions & 2 deletions quic/s2n-quic-core/src/crypto/tls/offload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ pub trait Executor {

/// Allows access to the TlsSession on handshake failure and when the exporter secret is ready.
pub trait ExporterHandler {
fn on_tls_handshake_failed(&self, session: &impl TlsSession) -> Option<Box<dyn Any + Send>>;
fn on_tls_handshake_failed(
&self,
session: &impl TlsSession,
e: &(dyn core::error::Error + Send + Sync + 'static),
) -> Option<Box<dyn Any + Send>>;
fn on_tls_exporter_ready(&self, session: &impl TlsSession) -> Option<Box<dyn Any + Send>>;
}

Expand All @@ -30,6 +34,7 @@ impl ExporterHandler for () {
fn on_tls_handshake_failed(
&self,
_session: &impl TlsSession,
_e: &(dyn core::error::Error + Send + Sync + 'static),
) -> Option<Box<dyn std::any::Any + Send>> {
None
}
Expand Down Expand Up @@ -559,8 +564,9 @@ impl<S: CryptoSuite, H: ExporterHandler> tls::Context<S> for RemoteContext<'_, R
fn on_tls_handshake_failed(
&mut self,
session: &impl tls::TlsSession,
e: &(dyn core::error::Error + Send + Sync + 'static),
) -> Result<(), crate::transport::Error> {
if let Some(context) = self.exporter_handler.on_tls_handshake_failed(session) {
if let Some(context) = self.exporter_handler.on_tls_handshake_failed(session, e) {
match self.send_to_quic.push(Request::TlsContext(context)) {
Ok(_) => (),
Err(_) => self.error = Some(SLICE_ERROR),
Expand Down
3 changes: 2 additions & 1 deletion quic/s2n-quic-core/src/crypto/tls/slow_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ where
fn on_tls_handshake_failed(
&mut self,
session: &impl tls::TlsSession,
e: &(dyn core::error::Error + Send + Sync + 'static),
) -> Result<(), transport::Error> {
self.0.on_tls_exporter_ready(session)
self.0.on_tls_handshake_failed(session, e)
}

fn receive_initial(&mut self, max_len: Option<usize>) -> Option<tls::Bytes> {
Expand Down
1 change: 1 addition & 0 deletions quic/s2n-quic-core/src/crypto/tls/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ where
fn on_tls_handshake_failed(
&mut self,
_: &impl super::TlsSession,
_: &(dyn std::error::Error + Send + Sync),
) -> Result<(), crate::transport::Error> {
Ok(())
}
Expand Down
3 changes: 1 addition & 2 deletions quic/s2n-quic-core/src/datagram/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ pub enum BuilderError {
ZeroCapacity,
}

#[cfg(feature = "std")]
impl std::error::Error for BuilderError {}
impl core::error::Error for BuilderError {}

impl fmt::Display for BuilderError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
9 changes: 8 additions & 1 deletion quic/s2n-quic-core/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ ident_into_event!(
connection::Error,
endpoint::Location,
);
borrowed_into_event!([u8; 4], [u8; 16], [u8], [u32], [&'a [u8]]);
borrowed_into_event!(
[u8; 4],
[u8; 16],
[u8],
[u32],
[&'a [u8]],
(dyn core::error::Error + Send + Sync + 'static)
);

impl<T: IntoEvent<U>, U> IntoEvent<Option<U>> for Option<T> {
#[inline]
Expand Down
10 changes: 7 additions & 3 deletions quic/s2n-quic-core/src/event/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2468,12 +2468,14 @@ pub mod api {
#[non_exhaustive]
pub struct TlsHandshakeFailed<'a> {
pub session: crate::event::TlsSession<'a>,
pub error: &'a (dyn core::error::Error + Send + Sync + 'static),
}
#[cfg(any(test, feature = "testing"))]
impl<'a> crate::event::snapshot::Fmt for TlsHandshakeFailed<'a> {
fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
let mut fmt = fmt.debug_struct("TlsHandshakeFailed");
fmt.field("session", &self.session);
fmt.field("error", &self.error);
fmt.finish()
}
}
Expand Down Expand Up @@ -4132,8 +4134,8 @@ pub mod tracing {
event: &api::TlsHandshakeFailed,
) {
let id = context.id();
let api::TlsHandshakeFailed { session } = event;
tracing :: event ! (target : "tls_handshake_failed" , parent : id , tracing :: Level :: DEBUG , { session = tracing :: field :: debug (session) });
let api::TlsHandshakeFailed { session, error } = event;
tracing :: event ! (target : "tls_handshake_failed" , parent : id , tracing :: Level :: DEBUG , { session = tracing :: field :: debug (session) , error = tracing :: field :: debug (error) });
}
#[inline]
fn on_path_challenge_updated(
Expand Down Expand Up @@ -6300,13 +6302,15 @@ pub mod builder {
#[derive(Clone, Debug)]
pub struct TlsHandshakeFailed<'a> {
pub session: crate::event::TlsSession<'a>,
pub error: &'a (dyn core::error::Error + Send + Sync + 'static),
}
impl<'a> IntoEvent<api::TlsHandshakeFailed<'a>> for TlsHandshakeFailed<'a> {
#[inline]
fn into_event(self) -> api::TlsHandshakeFailed<'a> {
let TlsHandshakeFailed { session } = self;
let TlsHandshakeFailed { session, error } = self;
api::TlsHandshakeFailed {
session: session.into_event(),
error: error.into_event(),
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions quic/s2n-quic-core/src/path/mtu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ impl Display for MtuError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for MtuError {}
impl core::error::Error for MtuError {}

/// Information about the path that may be used when generating MTU configuration.
#[non_exhaustive]
Expand Down
3 changes: 1 addition & 2 deletions quic/s2n-quic-core/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,4 @@ impl core::fmt::Display for Error {
}
}

#[cfg(feature = "std")]
impl std::error::Error for Error {}
impl core::error::Error for Error {}
3 changes: 1 addition & 2 deletions quic/s2n-quic-core/src/stream/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ pub enum StreamError {
},
}

#[cfg(feature = "std")]
impl std::error::Error for StreamError {}
impl core::error::Error for StreamError {}

impl fmt::Display for StreamError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
3 changes: 1 addition & 2 deletions quic/s2n-quic-core/src/transport/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ pub struct Error {
pub reason: &'static str,
}

#[cfg(feature = "std")]
impl std::error::Error for Error {}
impl core::error::Error for Error {}

impl Error {
/// Creates a new `Error`
Expand Down
3 changes: 1 addition & 2 deletions quic/s2n-quic-core/src/transport/parameters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,7 @@ impl From<core::convert::Infallible> for ValidationError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for ValidationError {}
impl core::error::Error for ValidationError {}

/// Creates a transport parameter struct with the inner codec type
macro_rules! transport_parameter {
Expand Down
3 changes: 1 addition & 2 deletions quic/s2n-quic-core/src/varint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ impl fmt::Display for VarIntError {
}
}

#[cfg(feature = "std")]
impl std::error::Error for VarIntError {}
impl core::error::Error for VarIntError {}

// === API ===

Expand Down
4 changes: 2 additions & 2 deletions quic/s2n-quic-rustls/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ impl tls::Session for Session {
context: &mut C,
) -> Poll<Result<(), transport::Error>> {
let result = self.poll_impl(context);
if let Poll::Ready(Err(_)) = &result {
context.on_tls_handshake_failed(self)?;
if let Poll::Ready(Err(e)) = &result {
context.on_tls_handshake_failed(self, e)?;
}
// attempt to emit server_name and application_protocol events prior to possibly
// returning with an error
Expand Down
1 change: 1 addition & 0 deletions quic/s2n-quic-tests/src/tests/offload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ impl ExporterHandler for Exporter {
fn on_tls_handshake_failed(
&self,
_session: &impl s2n_quic_core::crypto::tls::TlsSession,
_e: &(dyn core::error::Error + Send + Sync + 'static),
) -> Option<Box<dyn std::any::Any + Send>> {
None
}
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-tls/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl tls::Session for Session {
Poll::Ready(Ok(()))
}
Poll::Ready(Err(e)) => {
context.on_tls_handshake_failed(self)?;
context.on_tls_handshake_failed(self, &e)?;

Poll::Ready(Err(e
.alert()
Expand Down
2 changes: 2 additions & 0 deletions quic/s2n-quic-transport/src/space/session_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,12 @@ impl<Config: endpoint::Config, Pub: event::ConnectionPublisher>
fn on_tls_handshake_failed(
&mut self,
session: &impl tls::TlsSession,
e: &(dyn std::error::Error + Send + Sync + 'static),
) -> Result<(), transport::Error> {
self.publisher
.on_tls_handshake_failed(event::builder::TlsHandshakeFailed {
session: s2n_quic_core::event::TlsSession::new(session),
error: e,
});
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ cfg_if!(
/// An error indicating a failure to start an endpoint
pub struct StartError(Box<dyn 'static + fmt::Display + Send + Sync>);

impl std::error::Error for StartError {}
impl core::error::Error for StartError {}

impl StartError {
pub(crate) fn new<T: 'static + fmt::Display + Send + Sync>(error: T) -> Self {
Expand Down
Loading