Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simplify the method of stream forward in dispatch_stream #206

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions clash_lib/src/app/dispatcher/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::proxy::AnyInboundDatagram;
use crate::session::Session;
use futures::SinkExt;
use futures::StreamExt;

use std::collections::HashMap;
use std::fmt::{Debug, Formatter};
use std::net::SocketAddr;
Expand Down Expand Up @@ -77,7 +78,7 @@ impl Dispatcher {
#[instrument(skip(lhs))]
pub async fn dispatch_stream<S>(&self, sess: Session, mut lhs: S)
where
S: AsyncRead + AsyncWrite + Unpin + Send,
S: AsyncRead + AsyncWrite + Unpin + Send +'static,
{
let sess = if self.resolver.fake_ip_enabled() {
match sess.destination {
Expand Down Expand Up @@ -133,11 +134,11 @@ impl Dispatcher {
{
Ok(rhs) => {
debug!("remote connection established {}", sess);
let mut rhs =
let rhs =
TrackedStream::new(rhs, self.manager.clone(), sess.clone(), rule).await;
match copy_buf_bidirectional_with_timeout(
&mut lhs,
&mut rhs,
lhs,
rhs,
4096,
Duration::from_secs(10),
Duration::from_secs(10),
Expand Down
Loading
Loading