From 273063ec28da659b5f74fe657b559c657352d230 Mon Sep 17 00:00:00 2001 From: Toshit Chawda Date: Mon, 27 May 2024 17:08:21 -0700 Subject: [PATCH] add wisp v1 flag --- server/src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/src/main.rs b/server/src/main.rs index 6e5803e..be3a5b4 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -68,6 +68,9 @@ struct Cli { /// `user` cannot contain `:`. Whitespace will be trimmed. #[arg(long)] auth: Option, + /// Use Wisp V1. + #[arg(long)] + wisp_v1: bool, } #[derive(Clone)] @@ -77,6 +80,7 @@ struct MuxOptions { pub block_non_http: bool, pub enforce_auth: bool, pub auth: Arc>>, + pub wisp_v1: bool, } #[cfg(not(unix))] @@ -191,6 +195,7 @@ async fn main() -> Result<(), Error> { Box::new(pw_ext), ]), enforce_auth, + wisp_v1: opt.wisp_v1, }; println!("listening on `{}` with prefix `{}`", addr, prefix); @@ -315,8 +320,12 @@ async fn accept_ws( println!("{:?}: connected", addr); // to prevent memory ""leaks"" because users are sending in packets way too fast the buffer - // size is set to 512 - let (mux, fut) = if mux_options.enforce_auth { + // size is set to 512 + let (mux, fut) = if mux_options.wisp_v1 { + ServerMux::create(rx, tx, 512, None) + .await? + .with_no_required_extensions() + } else if mux_options.enforce_auth { ServerMux::create(rx, tx, 512, Some(mux_options.auth.as_slice())) .await? .with_required_extensions(&[PasswordProtocolExtension::ID])