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, target: impl IntoTargetAddr<'a>) -> Self
👎Deprecated: the current behavior is unintentional and will be replaced for v0.2.0
pub fn socks4(self, target: impl IntoTargetAddr<'a>) -> Self
enable socks4 proxying
let addr = "127.0.0.1:9050".parse().unwrap();
let builder = Stream::new_tcp(&addr);
let builder = builder.socks4("irc.example.com:6667");Sourcepub fn socks4_with_userid(
self,
target: impl IntoTargetAddr<'a>,
userid: &'a str,
) -> Self
👎Deprecated: the current behavior is unintentional and will be replaced for v0.2.0
pub fn socks4_with_userid( self, target: impl IntoTargetAddr<'a>, userid: &'a str, ) -> Self
enable socks4 proxying with a userid
let addr = "127.0.0.1:9050".parse().unwrap();
let builder = Stream::new_tcp(&addr);
let builder = builder.socks4_with_userid("irc.example.com:6667", "meow");Sourcepub fn socks5(self, target: impl IntoTargetAddr<'a>) -> Self
👎Deprecated: the current behavior is unintentional and will be replaced for v0.2.0
pub fn socks5(self, target: impl IntoTargetAddr<'a>) -> Self
enable socks5 proxying
let addr = "127.0.0.1:9050".parse().unwrap();
let builder = Stream::new_tcp(&addr);
let builder = builder.socks5("irc.example.com:6667");Sourcepub fn socks5_with_password(
self,
target: impl IntoTargetAddr<'a>,
username: &'a str,
password: &'a str,
) -> Self
👎Deprecated: the current behavior is unintentional and will be replaced for v0.2.0
pub fn socks5_with_password( self, target: impl IntoTargetAddr<'a>, username: &'a str, password: &'a str, ) -> Self
enable socks5 proxying with password authentication
let addr = "127.0.0.1:9050".parse().unwrap();
let builder = Stream::new_tcp(&addr);
let builder = builder.socks5_with_password("irc.example.com:6667", "AzureDiamond", "hunter2");Sourcepub fn tls_danger_insecure(self, domain: ServerName<'static>) -> Self
pub fn tls_danger_insecure(self, domain: ServerName<'static>) -> Self
enable tls without any verification
use tokio_rustls::rustls::pki_types::ServerName;
let builder = builder.tls_danger_insecure(ServerName::try_from("google.com").unwrap());Sourcepub fn tls_with_root(
self,
domain: ServerName<'static>,
root: impl Into<Arc<RootCertStore>>,
) -> Self
pub fn tls_with_root( self, domain: 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(ServerName::try_from("google.com").unwrap(), root);Sourcepub fn tls_with_webpki(
self,
domain: ServerName<'static>,
webpki: Arc<WebPkiServerVerifier>,
) -> Self
pub fn tls_with_webpki( self, domain: 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 tokio_rustls::rustls::pki_types::{CertificateDer, PrivateKeyDer, ServerName, pem::PemObject};
let addr = "[::1]:6667".parse().unwrap();
let builder = Stream::new_tcp(&addr).tls_danger_insecure(ServerName::from(addr.ip()));
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