pub struct ProxyConfig { /* private fields */ }Expand description
Proxy configuration attached to an McClient.
§Quick reference
| Constructor | Protocol | Auth | UDP (Bedrock) |
|---|---|---|---|
socks5 | SOCKS5 | optional | No |
socks5_with_udp | SOCKS5 | optional | Yes |
http | HTTP CONNECT | optional | No |
§Examples
use rust_mc_status::proxy::ProxyConfig;
// SOCKS5 — anonymous
let cfg = ProxyConfig::socks5("127.0.0.1:1080");
// SOCKS5 — authenticated
let cfg = ProxyConfig::socks5("proxy.example.com:1080")
.with_auth("alice", "s3cr3t");
// SOCKS5 — with UDP (Bedrock support)
let cfg = ProxyConfig::socks5_with_udp("10.0.0.1:1080");
// HTTP CONNECT — anonymous
let cfg = ProxyConfig::http("squid.example.com:3128");
// HTTP CONNECT — authenticated
let cfg = ProxyConfig::http("squid.example.com:3128")
.with_auth("user", "pass");Implementations§
Source§impl ProxyConfig
impl ProxyConfig
Sourcepub fn socks5(addr: impl AsRef<str>) -> Self
pub fn socks5(addr: impl AsRef<str>) -> Self
SOCKS5 proxy for Java Edition (TCP) only.
Bedrock pings will fail with ProxyError::UdpUnsupported.
Use socks5_with_udp if your proxy
supports UDP ASSOCIATE.
Sourcepub fn socks5_with_udp(addr: impl AsRef<str>) -> Self
pub fn socks5_with_udp(addr: impl AsRef<str>) -> Self
SOCKS5 proxy with UDP ASSOCIATE support (usable for Bedrock too).
Sourcepub fn http(addr: impl AsRef<str>) -> Self
pub fn http(addr: impl AsRef<str>) -> Self
HTTP CONNECT proxy (TCP tunnel only).
Compatible with Squid, Nginx, HAProxy, corporate HTTP proxies, and any
server that speaks the CONNECT method. UDP is not supported — Bedrock
pings will fail with ProxyError::UdpUnsupported.
Authentication is sent as a Proxy-Authorization: Basic ... header.
§Example
use rust_mc_status::proxy::ProxyConfig;
let cfg = ProxyConfig::http("squid.corp.example.com:3128");
let cfg = ProxyConfig::http("proxy.example.com:8080")
.with_auth("user", "pass");Sourcepub fn with_auth(
self,
username: impl Into<String>,
password: impl Into<String>,
) -> Self
pub fn with_auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Self
Add username/password authentication.
For SOCKS5 this uses username/password sub-negotiation (RFC 1929).
For HTTP CONNECT this sends a Proxy-Authorization: Basic header.
pub fn addr(&self) -> &ProxyAddr
pub fn auth(&self) -> Option<&ProxyAuth>
pub fn kind(&self) -> ProxyKind
pub fn udp_support(&self) -> UdpSupport
Trait Implementations§
Source§impl Clone for ProxyConfig
impl Clone for ProxyConfig
Source§fn clone(&self) -> ProxyConfig
fn clone(&self) -> ProxyConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ProxyConfig
impl RefUnwindSafe for ProxyConfig
impl Send for ProxyConfig
impl Sync for ProxyConfig
impl Unpin for ProxyConfig
impl UnsafeUnpin for ProxyConfig
impl UnwindSafe for ProxyConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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