pub enum Address {
SocketAddress(SocketAddr),
DomainAddress(Box<str>, u16),
}Expand description
SOCKS5 Address Format
+------+----------+----------+
| ATYP | DST.ADDR | DST.PORT |
+------+----------+----------+
| 1 | Variable | 2 |
+------+----------+----------+Variants§
SocketAddress(SocketAddr)
Represents an IPv4 or IPv6 socket address.
DomainAddress(Box<str>, u16)
Represents a domain name and a port.
Implementations§
Source§impl Address
impl Address
Sourcepub fn unspecified() -> Self
👎Deprecated since 0.10.3: Use ‘unspecified_v4’ instead
pub fn unspecified() -> Self
Use ‘unspecified_v4’ instead
Returns an unspecified IPv4 address (0.0.0.0:0).
Sourcepub fn unspecified_v4() -> Self
pub fn unspecified_v4() -> Self
Returns an unspecified IPv4 address (0.0.0.0:0).
Sourcepub fn unspecified_v6() -> Self
pub fn unspecified_v6() -> Self
Returns an unspecified IPv6 address (::0:0).
Sourcepub fn get_type(&self) -> AddressType
pub fn get_type(&self) -> AddressType
Returns the type of the address (IPv4, IPv6, or Domain).
Sourcepub fn domain(&self) -> String
👎Deprecated: use host() instead
pub fn domain(&self) -> String
use host() instead
Returns the host name or IP address as a string.
Sourcepub const fn max_serialized_len() -> usize
pub const fn max_serialized_len() -> usize
Returns the maximum possible serialized length of a SOCKS5 address.
Sourcepub async fn resolve_using_tokio(&self) -> Result<IntoIter<SocketAddr>>
pub async fn resolve_using_tokio(&self) -> Result<IntoIter<SocketAddr>>
Resolves the address using Tokio’s asynchronous DNS resolution. Returns an iterator over the resolved socket addresses.
pub async fn resolve_tokio(&self) -> Result<IntoIter<SocketAddr>>
Use ‘resolve_using_tokio’ instead.
Sourcepub fn resolve(&self) -> Result<IntoIter<SocketAddr>>
pub fn resolve(&self) -> Result<IntoIter<SocketAddr>>
Resolves the address using the standard library’s DNS resolution. Returns an iterator over the resolved socket addresses.
§Errors
Returns an std::io::Error if address resolution fails.
§Examples
let addr = socks5_impl::Address::from(("www.qq.com", 80));
for socket_addr in addr.resolve().unwrap() {
println!("Resolved address: {}", socket_addr);
}
let addr = socks5_impl::Address::from(("127.0.0.1", 8080));
for socket_addr in addr.resolve().unwrap() {
println!("Resolved address: {}", socket_addr);
}Trait Implementations§
Source§impl AsyncStreamOperation for Address
impl AsyncStreamOperation for Address
fn retrieve_from_async_stream<'life0, 'async_trait, R>( stream: &'life0 mut R, ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
fn write_to_async_stream<'life0, 'life1, 'async_trait, W>(
&'life0 self,
writer: &'life1 mut W,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
W: AsyncWrite + Unpin + Send + ?Sized + 'async_trait,
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Address
Source§impl From<&SocketAddr> for Address
impl From<&SocketAddr> for Address
Source§fn from(addr: &SocketAddr) -> Self
fn from(addr: &SocketAddr) -> Self
Source§impl From<SocketAddr> for Address
impl From<SocketAddr> for Address
Source§fn from(addr: SocketAddr) -> Self
fn from(addr: SocketAddr) -> Self
Source§impl Ord for Address
impl Ord for Address
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Address
impl PartialOrd for Address
Source§impl StreamOperation for Address
impl StreamOperation for Address
impl StructuralPartialEq for Address
Source§impl ToSocketAddrs for Address
impl ToSocketAddrs for Address
Source§type Iter = IntoIter<SocketAddr>
type Iter = IntoIter<SocketAddr>
Source§fn to_socket_addrs(&self) -> Result<Self::Iter>
fn to_socket_addrs(&self) -> Result<Self::Iter>
SocketAddrs. Read more