diff --git a/src/config.rs b/src/config.rs index 3f00f53..669bbe9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -42,7 +42,7 @@ pub struct ServerConfig { pub enum Upstream { Ban, Echo, - Custom(CustomUpstream), + Proxy(ProxyToUpstream), } #[derive(Debug)] @@ -61,7 +61,7 @@ impl Clone for Addr { } #[derive(Debug, Clone, Deserialize)] -pub struct CustomUpstream { +pub struct ProxyToUpstream { pub name: String, pub addr: String, pub protocol: String, @@ -69,14 +69,14 @@ pub struct CustomUpstream { addresses: Addr, } -impl CustomUpstream { +impl ProxyToUpstream { pub async fn resolve_addresses(&self) -> std::io::Result> { let mut addr = self.addresses.0.lock().await; addr.resolve((*self.protocol).into()).await } } -impl Default for CustomUpstream { +impl Default for ProxyToUpstream { fn default() -> Self { Self { name: Default::default(), @@ -169,7 +169,7 @@ fn load_config(path: &str) -> Result { parsed_upstream.insert( name.to_string(), - Upstream::Custom(CustomUpstream { + Upstream::Proxy(ProxyToUpstream { name: name.to_string(), addr: format!("{}:{}", upstream_host, upstream_port), protocol: upstream_url.scheme().to_string(), diff --git a/src/servers/protocol/tcp.rs b/src/servers/protocol/tcp.rs index e193a4a..f20929a 100644 --- a/src/servers/protocol/tcp.rs +++ b/src/servers/protocol/tcp.rs @@ -94,13 +94,13 @@ async fn process( let bytes_tx = inbound_to_inbound.await; debug!("Bytes read: {:?}", bytes_tx); } - Upstream::Custom(custom) => { - let outbound = match custom.protocol.as_ref() { + Upstream::Proxy(config) => { + let outbound = match config.protocol.as_ref() { "tcp4" | "tcp6" | "tcp" => { - TcpStream::connect(custom.resolve_addresses().await?.as_slice()).await? + TcpStream::connect(config.resolve_addresses().await?.as_slice()).await? } _ => { - error!("Reached unknown protocol: {:?}", custom.protocol); + error!("Reached unknown protocol: {:?}", config.protocol); return Err("Reached unknown protocol".into()); } };