diff --git a/src/client.rs b/src/client.rs index aa6ba19..448fe3a 100644 --- a/src/client.rs +++ b/src/client.rs @@ -245,8 +245,8 @@ pub(crate) async fn create_ws_stream( mut stream: S, ) -> Result> { let client = config.client.as_ref().ok_or("client not exist")?; - let tunnel_path = config.tunnel_path.extract().first().ok_or("tunnel path not exist")?.clone(); - let tunnel_path = tunnel_path.as_str().trim_matches('/'); + let err = "tunnel path not exist"; + let tunnel_path = config.tunnel_path.extract().first().ok_or(err)?.trim_matches('/'); let b64_dst = dst_addr.as_ref().map(|dst_addr| addess_to_b64str(dst_addr, false)); diff --git a/src/config.rs b/src/config.rs index bed1d09..ace82dc 100644 --- a/src/config.rs +++ b/src/config.rs @@ -73,10 +73,10 @@ impl TunnelPath { } } - pub fn extract(&self) -> Vec { + pub fn extract(&self) -> Vec<&str> { match self { - TunnelPath::Single(s) => vec![s.clone()], - TunnelPath::Multiple(v) => v.clone(), + TunnelPath::Single(s) => vec![s], + TunnelPath::Multiple(v) => v.iter().map(|s| s.as_str()).collect(), } } } diff --git a/src/server.rs b/src/server.rs index 18df18a..5f8094e 100644 --- a/src/server.rs +++ b/src/server.rs @@ -158,7 +158,7 @@ where Ok(()) } -fn check_uri_path(buf: &[u8], path: &[String]) -> Result { +fn check_uri_path(buf: &[u8], path: &[&str]) -> Result { let mut headers = [httparse::EMPTY_HEADER; 512]; let mut req = httparse::Request::new(&mut headers); req.parse(buf)?;