mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-12 14:00:01 -04:00
fix twisp and fix wispnet throttling
This commit is contained in:
parent
19fb49a4cc
commit
31df4aefc6
5 changed files with 34 additions and 17 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -727,7 +727,6 @@ dependencies = [
|
|||
"bytes",
|
||||
"cfg-if",
|
||||
"clap",
|
||||
"console-subscriber",
|
||||
"ed25519-dalek",
|
||||
"env_logger",
|
||||
"event-listener",
|
||||
|
|
|
@ -14,7 +14,6 @@ base64 = "0.22.1"
|
|||
bytes = "1.7.1"
|
||||
cfg-if = "1.0.0"
|
||||
clap = { version = "4.5.16", features = ["cargo", "derive"] }
|
||||
console-subscriber = { version = "0.4.1", optional = true }
|
||||
ed25519-dalek = { version = "2.1.1", features = ["pem"] }
|
||||
env_logger = "0.11.5"
|
||||
event-listener = "5.3.1"
|
||||
|
@ -54,7 +53,6 @@ toml = ["dep:toml"]
|
|||
|
||||
twisp = ["dep:pty-process", "dep:libc", "dep:shell-words"]
|
||||
speed-limit = ["dep:async-speed-limit"]
|
||||
tokio-console = ["dep:console-subscriber", "tokio/tracing"]
|
||||
|
||||
[build-dependencies]
|
||||
vergen-git2 = { version = "1.0.0", features = ["rustc"] }
|
||||
|
|
|
@ -224,7 +224,18 @@ async fn handle_stream(
|
|||
}
|
||||
}
|
||||
ClientStream::Wispnet(stream, mux_id) => {
|
||||
wispnet::handle_stream(muxstream, stream, mux_id, uuid, resolved_stream).await
|
||||
wispnet::handle_stream(
|
||||
muxstream,
|
||||
stream,
|
||||
mux_id,
|
||||
uuid,
|
||||
resolved_stream,
|
||||
#[cfg(feature = "speed-limit")]
|
||||
read_limit,
|
||||
#[cfg(feature = "speed-limit")]
|
||||
write_limit,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
ClientStream::NoResolvedAddrs => {
|
||||
let _ = muxstream.close(CloseReason::ServerStreamUnreachable).await;
|
||||
|
|
|
@ -14,7 +14,7 @@ use wisp_mux::{
|
|||
AnyProtocolExtension, AnyProtocolExtensionBuilder, ProtocolExtension,
|
||||
ProtocolExtensionBuilder,
|
||||
},
|
||||
ws::{LockedWebSocketWrite, WebSocketRead},
|
||||
ws::{DynWebSocketRead, LockingWebSocketWrite},
|
||||
MuxStreamAsyncRead, MuxStreamAsyncWrite, WispError,
|
||||
};
|
||||
|
||||
|
@ -50,18 +50,20 @@ impl ProtocolExtension for TWispServerProtocolExtension {
|
|||
|
||||
async fn handle_handshake(
|
||||
&mut self,
|
||||
_: &mut dyn WebSocketRead,
|
||||
_: &LockedWebSocketWrite,
|
||||
_: &mut DynWebSocketRead,
|
||||
_: &dyn LockingWebSocketWrite,
|
||||
) -> std::result::Result<(), WispError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_packet(
|
||||
&mut self,
|
||||
packet_type: u8,
|
||||
mut packet: Bytes,
|
||||
_: &mut dyn WebSocketRead,
|
||||
_: &LockedWebSocketWrite,
|
||||
_: &mut DynWebSocketRead,
|
||||
_: &dyn LockingWebSocketWrite,
|
||||
) -> std::result::Result<(), WispError> {
|
||||
if packet_type == 0xF0 {
|
||||
if packet.remaining() < 4 + 2 + 2 {
|
||||
return Err(WispError::PacketTooSmall);
|
||||
}
|
||||
|
@ -72,6 +74,7 @@ impl ProtocolExtension for TWispServerProtocolExtension {
|
|||
if let Some(pty) = self.0.lock().await.get(&stream_id) {
|
||||
let _ = set_term_size(*pty, Size::new(row, col));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -179,6 +179,12 @@ pub async fn handle_stream(
|
|||
mux_id: String,
|
||||
uuid: Uuid,
|
||||
resolved_stream: ConnectPacket,
|
||||
#[cfg(feature = "speed-limit")] read_limit: async_speed_limit::Limiter<
|
||||
async_speed_limit::clock::StandardClock,
|
||||
>,
|
||||
#[cfg(feature = "speed-limit")] write_limit: async_speed_limit::Limiter<
|
||||
async_speed_limit::clock::StandardClock,
|
||||
>,
|
||||
) {
|
||||
if let Some(client) = CLIENTS.lock().await.get(&mux_id) {
|
||||
client
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue