From 1278cd73989a848520e265f32ec4d3c53a359165 Mon Sep 17 00:00:00 2001 From: EAimTY Date: Sat, 20 May 2023 20:46:09 +0900 Subject: [PATCH] `reset` on `Connect` to immediately close streams --- tuic-quinn/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tuic-quinn/src/lib.rs b/tuic-quinn/src/lib.rs index ea61e23..a507eaa 100644 --- a/tuic-quinn/src/lib.rs +++ b/tuic-quinn/src/lib.rs @@ -5,6 +5,7 @@ use bytes::{BufMut, Bytes}; use futures_util::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; use quinn::{ Connection as QuinnConnection, ConnectionError, RecvStream, SendDatagramError, SendStream, + UnknownStream, VarInt, }; use std::{ fmt::{Debug, Formatter, Result as FmtResult}, @@ -411,6 +412,15 @@ impl Connect { Side::Server(model) => model.addr(), } } + + pub fn reset( + &mut self, + error_code: VarInt, + ) -> (Result<(), UnknownStream>, Result<(), UnknownStream>) { + let send_res = self.send.reset(error_code); + let recv_res = self.recv.stop(error_code); + (send_res, recv_res) + } } impl AsyncRead for Connect {