use std::net::SocketAddr;
use super::{Connection, Error, Identity};
use crate::udp;
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct Config {
pub peer: SocketAddr,
pub server_name: String,
pub alpn: Vec<String>,
pub verify: bool,
pub roots: Vec<std::path::PathBuf>,
pub system_roots: bool,
pub identity: Option<Identity>,
pub transport: super::Transport,
}
impl Config {
pub fn new(peer: SocketAddr, server_name: impl Into<String>) -> Self {
Self {
peer,
server_name: server_name.into(),
alpn: Vec::new(),
verify: true,
roots: Vec::new(),
system_roots: true,
identity: None,
transport: super::Transport::default(),
}
}
}
pub async fn connect(socket: udp::Socket, config: &Config) -> Result<Connection, Error> {
let endpoint = super::Endpoint::new(socket, super::endpoint::Config::default())?;
endpoint.connect(config).await
}