This commit is contained in:
azw 2024-05-12 10:22:41 +08:00
parent acb8e1a470
commit 09f31f0964
4 changed files with 9 additions and 5 deletions

View File

@ -0,0 +1,3 @@
pub mod constant;
pub use constant::*;

View File

@ -0,0 +1 @@
pub const MAX_PACKET_LEN: usize = 1024 * 64;

View File

@ -25,7 +25,7 @@ use actix_web::web::Bytes;
use futures::FutureExt;
use tokio::io::{AsyncReadExt, Interest};
use crate::app::UserApp;
use crate::{MAX_PACKET_LEN};
use crate::constant;
use tokio::net::TcpStream;
use tokio::runtime::Runtime;
use crate::app::user_app::DownStreamPack;
@ -78,8 +78,8 @@ impl WsConn {
}
while true {
let mut read_bytes = buf_len - already_read_bytes;
if read_bytes > MAX_PACKET_LEN - self.recv_buf_len {
read_bytes = MAX_PACKET_LEN - self.recv_buf_len;
if read_bytes > constant::MAX_PACKET_LEN - self.recv_buf_len {
read_bytes = constant::MAX_PACKET_LEN - self.recv_buf_len;
}
if read_bytes > 0 {
self.recv_buf[self.recv_buf_len..bin.len()].copy_from_slice(&bin);

View File

@ -5,9 +5,9 @@ mod listener;
mod upstream;
mod downstream;
mod ss;
use crate::app::UserApp;
mod constant;
const MAX_PACKET_LEN: usize = 1024 * 64;
use crate::app::UserApp;
fn main() {
App::init(UserApp::instance());