#[cfg(feature = "http")]
pub mod http;
#[cfg(feature = "http")]
pub mod sse;
pub mod tcp;
pub mod unix;
#[cfg(feature = "websocket")]
pub mod websocket;
use crate::error::ProxyResult;
use crate::types::{ProxyRequest, ProxyResponse};
use tokio::sync::{mpsc, oneshot};
pub type InboundConnection = (ProxyRequest, oneshot::Sender<ProxyResponse>);
#[derive(Debug, Clone)]
pub enum ListenAddr {
Tcp(std::net::SocketAddr),
Unix(std::path::PathBuf),
}
#[derive(Debug, Clone)]
pub enum UpstreamTarget {
Url(url::Url),
Tcp { host: String, port: u16 },
Unix(std::path::PathBuf),
}
#[async_trait::async_trait]
pub trait TransportListener: Send + Sync {
async fn listen(
&self,
tx: mpsc::Sender<InboundConnection>,
shutdown: tokio::sync::watch::Receiver<bool>,
) -> ProxyResult<()>;
fn transport_name(&self) -> &str;
}
#[async_trait::async_trait]
pub trait TransportConnector: Send + Sync {
async fn forward(&self, request: ProxyRequest) -> ProxyResult<ProxyResponse>;
fn connector_name(&self) -> &str;
}