@@ -4,7 +4,7 @@ use std::collections::HashSet;
44use std:: io;
55use std:: net:: { TcpListener , TcpStream } ;
66
7- use ktls:: setup:: { SetupError , TlsCryptoInfoTx } ;
7+ use ktls:: setup:: { setup_ulp , SetupError , TlsCryptoInfoTx } ;
88use rustls:: { CipherSuite , SupportedCipherSuite , SupportedProtocolVersion } ;
99
1010#[ derive( Debug , Clone ) ]
@@ -17,17 +17,22 @@ pub struct CompatibleCipherSuites {
1717}
1818
1919impl CompatibleCipherSuites {
20- /// Probes the current kernel for kTLS cipher suite compatibility.
20+ /// Probes the current Linux kernel for kTLS cipher suite compatibility.
2121 ///
22- /// - If the current kernel does not support kTLS at all, returns None.
23- /// - Otherwise, returns a `CompatibleCipherSuites` instance containing the
24- /// supported cipher suites and protocol versions.
22+ /// Returns `None` if the kernel does not support kTLS, otherwise returns
23+ /// a `CompatibleCipherSuites` containing supported cipher suites and
24+ /// protocol versions.
2525 ///
26- /// The caller may cache the result of this function.
26+ /// # Notes
27+ ///
28+ /// - The caller may enable feature `rustls/tls12` to include TLS 1.2
29+ /// support, or the protocol versions may be empty if only TLS 1.2 is
30+ /// supported by current Linux kernel.
31+ /// - The caller may cache the result, as probing is expensive.
2732 ///
2833 /// ## Errors
2934 ///
30- /// If an I/O error occurs while probing, an `io::Error` is returned .
35+ /// [ `io::Error`] .
3136 pub fn probe ( ) -> io:: Result < Option < Self > > {
3237 let listener = TcpListener :: bind ( "127.0.0.0:0" ) ?;
3338
@@ -40,10 +45,10 @@ impl CompatibleCipherSuites {
4045
4146 macro_rules! test_param {
4247 ( $method: ident, $data: ident, $version: expr, $cipher_type: expr) => { {
43- let stream = match ktls :: setup :: setup_ulp( TcpStream :: connect( local_addr) ?) {
48+ let stream = match setup_ulp( TcpStream :: connect( local_addr) ?) {
4449 Ok ( stream) => stream,
4550 Err ( SetupError {
46- stream : Some ( _) , ..
51+ socket : Some ( _) , ..
4752 } ) => {
4853 // kTLS is not supported
4954 return Ok ( None ) ;
@@ -147,7 +152,8 @@ impl CompatibleCipherSuites {
147152 ( true , true ) => rustls:: DEFAULT_VERSIONS ,
148153 // The first element is TLS 1.3
149154 ( false , true ) => & rustls:: DEFAULT_VERSIONS [ ..1 ] ,
150- // The first element is TLS 1.2 (maybe, but empty slice is OK)
155+ // The first element is TLS 1.2 (maybe, but empty slice is OK, let the caller handle
156+ // it)
151157 ( true , false ) => & rustls:: DEFAULT_VERSIONS [ 1 ..] ,
152158 // No supported versions
153159 ( false , false ) => return Ok ( None ) ,
@@ -156,9 +162,9 @@ impl CompatibleCipherSuites {
156162 }
157163
158164 /// Filters the provided cipher suites list in place, removing suites
159- /// incompatible with kTLS on the current kernel .
165+ /// which is incompatible .
160166 ///
161- /// # Examples
167+ /// ## Examples
162168 ///
163169 /// ```no_run
164170 /// use std::sync::Arc;
0 commit comments