pub mod http;
pub mod https;
pub mod raw;
pub mod socks4;
pub mod socks5;
use std::{fmt, net::IpAddr};
use tokio::io::{AsyncRead, AsyncWrite};
pub trait AsyncStream: AsyncRead + AsyncWrite + Send + Unpin {}
impl<T: AsyncRead + AsyncWrite + Send + Unpin> AsyncStream for T {}
pub type BoxStream = Box<dyn AsyncStream>;
#[derive(Debug, Clone)]
pub enum Target {
Ip(IpAddr, u16),
Host(String, u16),
}
impl Target {
pub fn port(&self) -> u16 {
match self {
Target::Ip(_, p) | Target::Host(_, p) => *p,
}
}
}
impl fmt::Display for Target {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Target::Ip(ip, port) => write!(f, "{ip}:{port}"),
Target::Host(host, port) => write!(f, "{host}:{port}"),
}
}
}