Skip to content

Commit 6c0bc2e

Browse files
committed
Adds minimal impl
1 parent f13f040 commit 6c0bc2e

File tree

9 files changed

+298
-29
lines changed

9 files changed

+298
-29
lines changed

quic/s2n-quic-core/src/packet/handshake.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ pub type EncryptedHandshake<'a> =
6565
pub type CleartextHandshake<'a> = Handshake<&'a [u8], &'a [u8], PacketNumber, DecoderBufferMut<'a>>;
6666

6767
impl<'a> ProtectedHandshake<'a> {
68+
pub fn get_wire_bytes(&self) -> Vec<u8> {
69+
self.payload.buffer.encode_to_vec()
70+
}
71+
6872
#[inline]
6973
pub(crate) fn decode(
7074
_tag: Tag,

quic/s2n-quic-core/src/packet/short.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ impl<'a> ProtectedShort<'a> {
194194
.get_checked_range(&self.destination_connection_id)
195195
.into_less_safe_slice()
196196
}
197+
198+
pub fn get_wire_bytes(&self) -> Vec<u8> {
199+
self.payload.buffer.encode_to_vec()
200+
}
197201
}
198202

199203
impl<'a> EncryptedShort<'a> {

quic/s2n-quic-transport/src/connection/connection_container/tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ impl connection::Trait for TestConnection {
138138
_datagram: &mut <Self::Config as endpoint::Config>::DatagramEndpoint,
139139
_dc_endpoint: &mut <Self::Config as endpoint::Config>::DcEndpoint,
140140
_conn_limits_endpoint: &mut <Self::Config as endpoint::Config>::ConnectionLimits,
141+
_random_generator: &mut <Self::Config as endpoint::Config>::RandomGenerator,
142+
_packet_interceptor: &mut <Self::Config as endpoint::Config>::PacketInterceptor,
141143
) -> Result<(), connection::Error> {
142144
Ok(())
143145
}

quic/s2n-quic-transport/src/connection/connection_impl.rs

Lines changed: 238 additions & 24 deletions
Large diffs are not rendered by default.

quic/s2n-quic-transport/src/connection/connection_trait.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ pub trait ConnectionTrait: 'static + Send + Sized {
115115
datagram: &mut <Self::Config as endpoint::Config>::DatagramEndpoint,
116116
dc_endpoint: &mut <Self::Config as endpoint::Config>::DcEndpoint,
117117
conn_limits: &mut <Self::Config as endpoint::Config>::ConnectionLimits,
118+
random_generator: &mut <Self::Config as endpoint::Config>::RandomGenerator,
119+
packet_interceptor: &mut <Self::Config as endpoint::Config>::PacketInterceptor,
118120
) -> Result<(), connection::Error>;
119121

120122
// Packet handling

quic/s2n-quic-transport/src/connection/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,6 @@ pub struct Parameters<'a, Cfg: endpoint::Config> {
8989
pub event_subscriber: &'a mut Cfg::EventSubscriber,
9090
/// The connection limits provider
9191
pub limits_endpoint: &'a mut Cfg::ConnectionLimits,
92+
pub random_endpoint: &'a mut Cfg::RandomGenerator,
93+
pub interceptor_endpoint: &'a mut Cfg::PacketInterceptor,
9294
}

quic/s2n-quic-transport/src/endpoint/initial.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ impl<Config: endpoint::Config> endpoint::Endpoint<Config> {
316316
dc_endpoint: endpoint_context.dc,
317317
open_registry: None,
318318
limits_endpoint: endpoint_context.connection_limits,
319+
random_endpoint: endpoint_context.random_generator,
320+
interceptor_endpoint: endpoint_context.packet_interceptor,
319321
};
320322

321323
let mut connection = <Config as endpoint::Config>::Connection::new(connection_parameters)?;

quic/s2n-quic-transport/src/endpoint/mod.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,20 @@ use s2n_quic_core::{
2727
id::{ConnectionInfo, Generator},
2828
InitialId, LocalId, PeerId,
2929
},
30-
crypto::{tls, tls::Endpoint as _, CryptoSuite, InitialKey},
30+
crypto::{
31+
tls::{self, Endpoint as _},
32+
CryptoSuite, InitialKey,
33+
},
3134
datagram::{Endpoint as DatagramEndpoint, PreConnectionInfo},
32-
dc,
33-
dc::Endpoint as _,
35+
dc::{self, Endpoint as _},
3436
endpoint::{limits::Outcome, Limiter as _},
3537
event::{
3638
self, supervisor, ConnectionPublisher, EndpointPublisher as _, IntoEvent, Subscriber as _,
3739
},
3840
inet::{datagram, DatagramInfo},
3941
io::{rx, tx},
4042
packet::{initial::ProtectedInitial, interceptor::Interceptor, ProtectedPacket},
41-
path,
42-
path::{mtu, Handle as _},
43+
path::{self, mtu, Handle as _},
4344
random::Generator as _,
4445
stateless_reset::token::{Generator as _, LEN as StatelessResetTokenLen},
4546
time::{Clock, Timestamp},
@@ -215,6 +216,8 @@ impl<Cfg: Config> s2n_quic_core::endpoint::Endpoint for Endpoint<Cfg> {
215216
endpoint_context.datagram,
216217
endpoint_context.dc,
217218
endpoint_context.connection_limits,
219+
endpoint_context.random_generator,
220+
endpoint_context.packet_interceptor,
218221
) {
219222
conn.close(
220223
error,
@@ -1232,6 +1235,8 @@ impl<Cfg: Config> Endpoint<Cfg> {
12321235
dc_endpoint: endpoint_context.dc,
12331236
open_registry,
12341237
limits_endpoint: endpoint_context.connection_limits,
1238+
random_endpoint: endpoint_context.random_generator,
1239+
interceptor_endpoint: endpoint_context.packet_interceptor,
12351240
};
12361241
let connection = <Cfg as crate::endpoint::Config>::Connection::new(connection_parameters)?;
12371242
self.connections

quic/s2n-quic/src/tests/slow_tls.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,45 @@ fn slow_tls() {
3636
let client = Client::builder()
3737
.with_io(handle.builder().build().unwrap())?
3838
.with_tls(slow_client)?
39+
.with_event((tracing_events(), MyEvents))?
3940
.start()?;
4041
let addr = start_server(server)?;
4142
start_client(client, addr, Data::new(1000))?;
4243

4344
Ok(addr)
4445
})
4546
.unwrap();
47+
48+
struct MyEvents;
49+
struct MyContext;
50+
impl events::Subscriber for MyEvents {
51+
type ConnectionContext = MyContext;
52+
53+
fn create_connection_context(
54+
&mut self,
55+
_meta: &events::ConnectionMeta,
56+
_info: &events::ConnectionInfo,
57+
) -> Self::ConnectionContext {
58+
Self::ConnectionContext {}
59+
}
60+
fn on_transport_parameters_received(
61+
&mut self,
62+
_context: &mut Self::ConnectionContext,
63+
meta: &s2n_quic_core::event::api::ConnectionMeta,
64+
_event: &s2n_quic_core::event::api::TransportParametersReceived,
65+
) {
66+
// Slow TLS implementation has no affect on when transport parameters are received
67+
assert_eq!(meta.timestamp.to_string(), "0:00:00.100000");
68+
}
69+
70+
fn on_connection_closed(
71+
&mut self,
72+
_context: &mut Self::ConnectionContext,
73+
meta: &s2n_quic_core::event::api::ConnectionMeta,
74+
_event: &s2n_quic_core::event::api::ConnectionClosed,
75+
) {
76+
// Slow TLS implementation has no affect on when the connection is shut down
77+
assert_eq!(meta.timestamp.to_string(), "0:00:00.200000");
78+
}
79+
}
4680
}

0 commit comments

Comments
 (0)