pub struct Connector { /* private fields */ }Expand description
Opens game connections, directly or through a SOCKS5 proxy.
Cheap to clone; one connector can serve many bots.
Implementations§
Source§impl Connector
impl Connector
Sourcepub fn new() -> Connector
pub fn new() -> Connector
A connector without a proxy, with ProxyPolicy::PreferProxy, default Timeouts and
the SystemResolver.
Sourcepub fn with_proxy(self, proxy: Socks5Proxy) -> Connector
pub fn with_proxy(self, proxy: Socks5Proxy) -> Connector
Sets the SOCKS5 proxy.
Sourcepub fn with_optional_proxy(self, proxy: Option<Socks5Proxy>) -> Connector
pub fn with_optional_proxy(self, proxy: Option<Socks5Proxy>) -> Connector
Sets or clears the SOCKS5 proxy.
Sourcepub fn with_policy(self, policy: ProxyPolicy) -> Connector
pub fn with_policy(self, policy: ProxyPolicy) -> Connector
Sets the routing policy.
Sourcepub fn with_timeouts(self, timeouts: Timeouts) -> Connector
pub fn with_timeouts(self, timeouts: Timeouts) -> Connector
Sets the timeouts.
Sourcepub fn with_resolver(self, resolver: Arc<dyn Resolve>) -> Connector
pub fn with_resolver(self, resolver: Arc<dyn Resolve>) -> Connector
Replaces the local resolver.
Sourcepub fn proxy(&self) -> Option<&Socks5Proxy>
pub fn proxy(&self) -> Option<&Socks5Proxy>
The configured proxy, if any.
Sourcepub fn policy(&self) -> &ProxyPolicy
pub fn policy(&self) -> &ProxyPolicy
The routing policy.
Sourcepub fn plan(&self, target: &TargetAddr) -> Option<bool>
pub fn plan(&self, target: &TargetAddr) -> Option<bool>
The route Connector::connect would take for target: Some(true) through the
proxy, Some(false) directly, None if the policy forbids connecting at all.
Sourcepub async fn connect(
&self,
target: &TargetAddr,
) -> Result<TcpStream, ConnectError>
pub async fn connect( &self, target: &TargetAddr, ) -> Result<TcpStream, ConnectError>
Connects to target according to the policy and returns a stream with TCP_NODELAY set.
Through a proxy the stream is positioned right after the SOCKS5 CONNECT reply, so the first bytes written are the game’s handshake packet.