maybe working channels size
This commit is contained in:
@@ -3,6 +3,7 @@ use std::time::Duration;
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use netrunner_core::protocol::codec::frame::FrameType;
|
use netrunner_core::protocol::codec::frame::FrameType;
|
||||||
use netrunner_core::protocol::codec::socks::TargetAddress;
|
use netrunner_core::protocol::codec::socks::TargetAddress;
|
||||||
|
use netrunner_core::proxy::connection::BUF_SIZE;
|
||||||
use netrunner_core::proxy::connection::muxer::{MuxMessage, Muxer};
|
use netrunner_core::proxy::connection::muxer::{MuxMessage, Muxer};
|
||||||
use smoltcp::iface::SocketHandle;
|
use smoltcp::iface::SocketHandle;
|
||||||
use smoltcp::socket::tcp;
|
use smoltcp::socket::tcp;
|
||||||
@@ -44,7 +45,7 @@ impl TcpConnection {
|
|||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
// ИСПРАВЛЕНИЕ: Даем Муксеру ограниченный канал, как он и просит (тип mpsc::Sender)
|
// ИСПРАВЛЕНИЕ: Даем Муксеру ограниченный канал, как он и просит (тип mpsc::Sender)
|
||||||
// Делаем его достаточно вместительным (1024)
|
// Делаем его достаточно вместительным (1024)
|
||||||
let (v_tx, mut v_rx) = mpsc::channel::<Bytes>(1024);
|
let (v_tx, mut v_rx) = mpsc::channel::<Bytes>(BUF_SIZE);
|
||||||
muxer.register_stream(stream_id, v_tx);
|
muxer.register_stream(stream_id, v_tx);
|
||||||
|
|
||||||
let connect_payload = target_addr.to_string();
|
let connect_payload = target_addr.to_string();
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ impl ConnectionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn setup_sockets(n_icmp: usize) -> SocketSet<'static> {
|
pub fn setup_sockets(n_icmp: usize) -> SocketSet<'static> {
|
||||||
let mut sockets = SocketSet::new(Vec::with_capacity(1024));
|
let mut sockets = SocketSet::new(Vec::with_capacity(48));
|
||||||
|
|
||||||
for _ in 0..n_icmp {
|
for _ in 0..n_icmp {
|
||||||
sockets.add(Self::create_icmp_socket());
|
sockets.add(Self::create_icmp_socket());
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ impl Engine {
|
|||||||
let (mut device, to_smoltcp_tx, from_smoltcp_rx, avail) = VirtTunDevice::new(caps);
|
let (mut device, to_smoltcp_tx, from_smoltcp_rx, avail) = VirtTunDevice::new(caps);
|
||||||
let interface = Interface::new(config, &mut device, now);
|
let interface = Interface::new(config, &mut device, now);
|
||||||
|
|
||||||
let socket_set = ConnectionManager::setup_sockets(4);
|
let socket_set = ConnectionManager::setup_sockets(2);
|
||||||
let manager = ConnectionManager::new(dns_handler, muxer);
|
let manager = ConnectionManager::new(dns_handler, muxer);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::protocol::codec::frame::FrameType;
|
use crate::protocol::codec::frame::FrameType;
|
||||||
use crate::proxy::connection::connection::BUF_SIZE;
|
|
||||||
use crate::proxy::connection::muxer::{MuxMessage, Muxer};
|
use crate::proxy::connection::muxer::{MuxMessage, Muxer};
|
||||||
|
use crate::proxy::connection::BUF_SIZE;
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use netrunner_logger::{debug, error};
|
use netrunner_logger::{debug, error};
|
||||||
use tokio::net::UdpSocket;
|
use tokio::net::UdpSocket;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ use crate::{
|
|||||||
engine::TunnelEngine,
|
engine::TunnelEngine,
|
||||||
handler::StreamHandler,
|
handler::StreamHandler,
|
||||||
muxer::{MuxMessage, Muxer},
|
muxer::{MuxMessage, Muxer},
|
||||||
|
BUF_SIZE, CHANNEL_SIZE,
|
||||||
},
|
},
|
||||||
tlseng::profile::BrowserProfile,
|
tlseng::profile::BrowserProfile,
|
||||||
};
|
};
|
||||||
@@ -28,9 +29,6 @@ use tokio::{
|
|||||||
};
|
};
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
|
|
||||||
pub const BUF_SIZE: usize = 65536;
|
|
||||||
pub const CHANNEL_SIZE: usize = 256;
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
pub enum ConnectionRole {
|
pub enum ConnectionRole {
|
||||||
Client,
|
Client,
|
||||||
@@ -205,7 +203,7 @@ impl TunnelHandler for ClientHandler {
|
|||||||
target,
|
target,
|
||||||
} => {
|
} => {
|
||||||
let stream_id = self.muxer.next_id();
|
let stream_id = self.muxer.next_id();
|
||||||
let (v_tx, mut v_rx) = mpsc::channel::<bytes::Bytes>(1024);
|
let (v_tx, mut v_rx) = mpsc::channel::<bytes::Bytes>(BUF_SIZE);
|
||||||
self.muxer.register_stream(stream_id, v_tx);
|
self.muxer.register_stream(stream_id, v_tx);
|
||||||
|
|
||||||
self.muxer
|
self.muxer
|
||||||
|
|||||||
@@ -3,3 +3,6 @@ pub mod connection;
|
|||||||
pub mod engine;
|
pub mod engine;
|
||||||
pub mod handler;
|
pub mod handler;
|
||||||
pub mod muxer;
|
pub mod muxer;
|
||||||
|
|
||||||
|
pub const BUF_SIZE: usize = 65536;
|
||||||
|
pub const CHANNEL_SIZE: usize = 16;
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
protocol::errors::ErrorAction,
|
protocol::errors::ErrorAction,
|
||||||
proxy::connection::{
|
proxy::connection::{
|
||||||
connection::{
|
connection::{ClientHandler, Connection, ConnectionRole, ServerHandler, TunnelHandler},
|
||||||
ClientHandler, Connection, ConnectionRole, ServerHandler, TunnelHandler, CHANNEL_SIZE,
|
|
||||||
},
|
|
||||||
engine::TunnelEngine,
|
engine::TunnelEngine,
|
||||||
muxer::Muxer,
|
muxer::Muxer,
|
||||||
|
CHANNEL_SIZE,
|
||||||
},
|
},
|
||||||
tlseng::profile::BrowserProfile,
|
tlseng::profile::BrowserProfile,
|
||||||
};
|
};
|
||||||
@@ -132,7 +131,7 @@ impl Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (mux_tx, mux_rx) = tokio::sync::mpsc::channel(CHANNEL_SIZE);
|
let (mux_tx, mux_rx) = tokio::sync::mpsc::channel(CHANNEL_SIZE * 48);
|
||||||
let muxer = Muxer::new(mux_tx, true);
|
let muxer = Muxer::new(mux_tx, true);
|
||||||
|
|
||||||
let handler = std::sync::Arc::new(crate::proxy::connection::handler::StreamHandler::new(
|
let handler = std::sync::Arc::new(crate::proxy::connection::handler::StreamHandler::new(
|
||||||
|
|||||||
Reference in New Issue
Block a user