encapsulation of net logic in core
This commit is contained in:
@@ -6,7 +6,7 @@ use netrunner_logger::{debug, error};
|
||||
use tokio::net::UdpSocket;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
pub async fn run_tcp_bridge<R, W>(
|
||||
pub(crate) async fn run_tcp_bridge<R, W>(
|
||||
stream_id: u32,
|
||||
mut reader: R,
|
||||
mut writer: W,
|
||||
@@ -72,7 +72,7 @@ pub async fn run_tcp_bridge<R, W>(
|
||||
muxer.remove_stream(stream_id);
|
||||
}
|
||||
|
||||
pub async fn run_udp_bridge(
|
||||
pub(crate) async fn run_udp_bridge(
|
||||
stream_id: u32,
|
||||
socket: UdpSocket,
|
||||
muxer: Muxer,
|
||||
|
||||
@@ -38,10 +38,10 @@ pub trait TunnelHandler {
|
||||
}
|
||||
|
||||
pub struct Connection {
|
||||
pub inbound: OwnedReadHalf,
|
||||
pub outbound: OwnedWriteHalf,
|
||||
pub read_buf: BytesMut,
|
||||
pub codec: Codec,
|
||||
pub(crate) inbound: OwnedReadHalf,
|
||||
pub(crate) outbound: OwnedWriteHalf,
|
||||
pub(crate) read_buf: BytesMut,
|
||||
pub(crate) codec: Codec,
|
||||
}
|
||||
|
||||
impl Connection {
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::{
|
||||
nrxp::{codec::Codec, errors::ErrorAction, frame::FrameType},
|
||||
};
|
||||
|
||||
pub struct TunnelEngine {
|
||||
pub(crate) struct TunnelEngine {
|
||||
pub inbound: OwnedReadHalf,
|
||||
pub outbound: OwnedWriteHalf,
|
||||
pub codec: Codec,
|
||||
|
||||
@@ -16,17 +16,17 @@ use crate::{
|
||||
},
|
||||
};
|
||||
|
||||
pub struct StreamHandler {
|
||||
pub(crate) struct StreamHandler {
|
||||
muxer: Muxer,
|
||||
role: ConnectionRole,
|
||||
}
|
||||
|
||||
impl StreamHandler {
|
||||
pub fn new(muxer: Muxer, role: ConnectionRole) -> Self {
|
||||
pub(crate) fn new(muxer: Muxer, role: ConnectionRole) -> Self {
|
||||
Self { muxer, role }
|
||||
}
|
||||
|
||||
pub async fn handle(&self, frame: Frame) {
|
||||
pub(crate) async fn handle(&self, frame: Frame) {
|
||||
let stream_id = frame.header.stream_id;
|
||||
|
||||
match frame.header.frame_type {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
mod bridge;
|
||||
pub mod connection;
|
||||
pub mod engine;
|
||||
pub mod handler;
|
||||
pub mod muxer;
|
||||
mod bridge; // Все модули делаем приватными
|
||||
mod connection;
|
||||
mod engine;
|
||||
mod handler;
|
||||
mod muxer;
|
||||
|
||||
pub use connection::{ClientHandler, Connection, ConnectionRole, ServerHandler, TunnelHandler};
|
||||
|
||||
@@ -6,7 +6,7 @@ use tokio::sync::mpsc::{error::SendError, Sender};
|
||||
|
||||
use crate::nrxp::frame::FrameType;
|
||||
|
||||
pub struct IdGenerator {
|
||||
struct IdGenerator {
|
||||
counter: AtomicU32,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user