Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Mar 12, 2024
1 parent 880621e commit 114f117
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ pub(crate) async fn create_ws_stream<S: AsyncRead + AsyncWrite + Unpin>(
mut stream: S,
) -> Result<WebSocketStream<S>> {
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));

Expand Down
6 changes: 3 additions & 3 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ impl TunnelPath {
}
}

pub fn extract(&self) -> Vec<String> {
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(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ where
Ok(())
}

fn check_uri_path(buf: &[u8], path: &[String]) -> Result<bool> {
fn check_uri_path(buf: &[u8], path: &[&str]) -> Result<bool> {
let mut headers = [httparse::EMPTY_HEADER; 512];
let mut req = httparse::Request::new(&mut headers);
req.parse(buf)?;
Expand Down

0 comments on commit 114f117

Please sign in to comment.