random fixes

This commit is contained in:
Toshit Chawda 2024-07-22 11:34:33 -07:00
parent 76eeec87dc
commit d78e6cef0c
No known key found for this signature in database
GPG key ID: 91480ED99E2B3D9D
5 changed files with 523 additions and 235 deletions

View file

@ -1,9 +1,11 @@
use std::io::Cursor;
use anyhow::Context;
use fastwebsockets::upgrade::UpgradeFut;
use futures_util::FutureExt;
use hyper_util::rt::TokioIo;
use tokio::{
io::{AsyncBufReadExt, AsyncWriteExt, BufReader},
io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader},
net::tcp::{OwnedReadHalf, OwnedWriteHalf},
select,
task::JoinSet,
@ -162,8 +164,8 @@ pub async fn handle_wisp(fut: UpgradeFut, id: String) -> anyhow::Result<()> {
let (read, write) = ws.split(|x| {
let parts = x.into_inner().downcast::<TokioIo<ServerStream>>().unwrap();
assert_eq!(parts.read_buf.len(), 0);
parts.io.into_inner().split()
let (r, w) = parts.io.into_inner().split();
(Cursor::new(parts.read_buf).chain(r), w)
});
let (extensions, buffer_size) = CONFIG.wisp.to_opts();