pub struct StreamBuilder<'a> { /* private fields */ }
Expand description
a builder for Stream
Implementations§
Source§impl<'a> StreamBuilder<'a>
impl<'a> StreamBuilder<'a>
Sourcepub fn socks4(self, proxy: SocketAddr) -> Self
pub fn socks4(self, proxy: SocketAddr) -> Self
enable socks4 proxying
let builder = builder.socks4("127.0.0.1:9050".parse().unwrap());
Sourcepub fn socks4_with_userid(self, proxy: SocketAddr, userid: &'a str) -> Self
pub fn socks4_with_userid(self, proxy: SocketAddr, userid: &'a str) -> Self
enable socks4 proxying with a userid
let builder = builder.socks4_with_userid("127.0.0.1:9050".parse().unwrap(), "meow");
Sourcepub fn socks5(self, proxy: SocketAddr) -> Self
pub fn socks5(self, proxy: SocketAddr) -> Self
enable socks5 proxying
let builder = builder.socks5("127.0.0.1:9050".parse().unwrap());
Sourcepub fn socks5_with_password(
self,
proxy: SocketAddr,
username: &'a str,
password: &'a str,
) -> Self
pub fn socks5_with_password( self, proxy: SocketAddr, username: &'a str, password: &'a str, ) -> Self
enable socks5 proxying with password authentication
let builder =
builder.socks5_with_password("127.0.0.1:9050".parse().unwrap(), "AzureDiamond", "hunter2");
Sourcepub fn tls_danger_insecure(self, domain: Option<ServerName<'static>>) -> Self
pub fn tls_danger_insecure(self, domain: Option<ServerName<'static>>) -> Self
enable tls without any verification
use tokio_rustls::rustls::pki_types::ServerName;
let builder = builder.tls_danger_insecure(Some(ServerName::try_from("google.com").unwrap()));
Sourcepub fn tls_with_root(
self,
domain: Option<ServerName<'static>>,
root: impl Into<Arc<RootCertStore>>,
) -> Self
pub fn tls_with_root( self, domain: Option<ServerName<'static>>, root: impl Into<Arc<RootCertStore>>, ) -> Self
enable tls with root certificate verification
can also be used to pin a self-signed cert as long as it has a CA:FALSE
constraint
use tokio_rustls::rustls::RootCertStore;
use tokio_rustls::rustls::pki_types::{CertificateDer, ServerName, pem::PemObject};
let mut root = RootCertStore::empty();
root.add_parsable_certificates(
CertificateDer::pem_file_iter("/etc/ssl/cert.pem")
.unwrap()
.flatten(),
);
let builder = builder.tls_with_root(None, root);
Sourcepub fn tls_with_webpki(
self,
domain: Option<ServerName<'static>>,
webpki: Arc<WebPkiServerVerifier>,
) -> Self
pub fn tls_with_webpki( self, domain: Option<ServerName<'static>>, webpki: Arc<WebPkiServerVerifier>, ) -> Self
enable tls with a webpki verifier
Sourcepub fn client_cert(
self,
cert_chain: Vec<CertificateDer<'static>>,
key_der: PrivateKeyDer<'static>,
) -> Self
pub fn client_cert( self, cert_chain: Vec<CertificateDer<'static>>, key_der: PrivateKeyDer<'static>, ) -> Self
use a tls client certificate
requires tls to be enabled
use irc_connect::Stream;
use std::net::SocketAddr;
use tokio_rustls::rustls::pki_types::{CertificateDer, PrivateKeyDer, ServerName, pem::PemObject};
let builder = Stream::new_tcp("[::1]:6667").tls_danger_insecure(None);
let cert = CertificateDer::pem_file_iter("cert.pem")
.unwrap()
.collect::<Result<Vec<_>, _>>()
.unwrap();
let key = PrivateKeyDer::from_pem_file("cert.key").unwrap();
let builder = builder.client_cert(cert, key);
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for StreamBuilder<'a>
impl<'a> !RefUnwindSafe for StreamBuilder<'a>
impl<'a> Send for StreamBuilder<'a>
impl<'a> Sync for StreamBuilder<'a>
impl<'a> Unpin for StreamBuilder<'a>
impl<'a> !UnwindSafe for StreamBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more