mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-18 01:05:28 +00:00
Add new Client::connect_with_tls_config() API method
This commit is contained in:
+18
-5
@@ -17,12 +17,29 @@ pub struct Client {
|
||||
}
|
||||
|
||||
impl Client {
|
||||
pub fn connect(server: &str, port: u16) -> QuicResult<ConnectFuture> {
|
||||
ConnectFuture::new(Self::new(server, port)?)
|
||||
}
|
||||
|
||||
pub fn connect_with_tls_config(
|
||||
server: &str,
|
||||
port: u16,
|
||||
config: tls::ClientConfig,
|
||||
) -> QuicResult<ConnectFuture> {
|
||||
let tls = tls::client_session(Some(config), server, &ClientTransportParameters::default())?;
|
||||
ConnectFuture::new(Self::with_state(
|
||||
server,
|
||||
port,
|
||||
ConnectionState::new(tls, None),
|
||||
)?)
|
||||
}
|
||||
|
||||
pub(crate) fn new(server: &str, port: u16) -> QuicResult<Client> {
|
||||
let tls = tls::client_session(None, server, &ClientTransportParameters::default())?;
|
||||
Self::with_state(server, port, ConnectionState::new(tls, None))
|
||||
}
|
||||
|
||||
pub fn with_state(
|
||||
pub(crate) fn with_state(
|
||||
server: &str,
|
||||
port: u16,
|
||||
conn_state: ConnectionState<tls::ClientSession>,
|
||||
@@ -45,10 +62,6 @@ impl Client {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn connect(server: &str, port: u16) -> QuicResult<ConnectFuture> {
|
||||
ConnectFuture::new(Self::new(server, port)?)
|
||||
}
|
||||
|
||||
fn poll_send(&mut self) -> Poll<(), QuicError> {
|
||||
if let Some(buf) = self.conn_state.queued()? {
|
||||
let len = try_ready!(self.socket.poll_send(&buf));
|
||||
|
||||
+3
-2
@@ -1,5 +1,5 @@
|
||||
use rustls::quic::{ClientQuicExt, ServerQuicExt};
|
||||
use rustls::{ClientConfig, KeyLogFile, NoClientAuth, ProtocolVersion, TLSError};
|
||||
use rustls::{KeyLogFile, NoClientAuth, ProtocolVersion, TLSError};
|
||||
|
||||
use std::io::Cursor;
|
||||
use std::sync::Arc;
|
||||
@@ -13,7 +13,8 @@ use types::Side;
|
||||
use webpki::{DNSNameRef, TLSServerTrustAnchors};
|
||||
use webpki_roots;
|
||||
|
||||
pub use rustls::{Certificate, ClientSession, PrivateKey, ServerConfig, ServerSession, Session};
|
||||
pub use rustls::{Certificate, PrivateKey};
|
||||
pub use rustls::{ClientConfig, ClientSession, ServerConfig, ServerSession, Session};
|
||||
|
||||
pub fn client_session(
|
||||
config: Option<ClientConfig>,
|
||||
|
||||
Reference in New Issue
Block a user