Skip to content

Commit

Permalink
fix: regression for L7-based chain proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
XOR-op committed Feb 10, 2024
1 parent de6b370 commit 62d2eba
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 27 deletions.
11 changes: 7 additions & 4 deletions boltconn/src/adapter/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ impl Outbound for HttpOutbound {
tracing::error!("Invalid HTTP proxy tcp spawn");
return Err(io::ErrorKind::InvalidData.into());
}
self.clone()
.run_tcp(inbound, tcp_outbound.unwrap(), abort_handle)
.await
.map_err(|e| io_err(e.to_string().as_str()))?;
let self_clone = self.clone();
tokio::spawn(async move {
self_clone
.run_tcp(inbound, tcp_outbound.unwrap(), abort_handle)
.await
.map_err(|e| io_err(e.to_string().as_str()))
});
Ok(true)
}

Expand Down
34 changes: 20 additions & 14 deletions boltconn/src/adapter/shadowsocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,13 @@ impl Outbound for SSOutbound {
tracing::error!("Invalid Shadowsocks tcp spawn");
return Err(io::ErrorKind::InvalidData.into());
}
let server_addr = self.get_server_addr().await?;
self.clone()
.run_tcp(inbound, tcp_outbound.unwrap(), server_addr, abort_handle)
.await?;
let self_clone = self.clone();
tokio::spawn(async move {
let server_addr = self_clone.get_server_addr().await?;
self_clone
.run_tcp(inbound, tcp_outbound.unwrap(), server_addr, abort_handle)
.await
});
Ok(true)
}

Expand Down Expand Up @@ -213,16 +216,19 @@ impl Outbound for SSOutbound {
return Err(io::ErrorKind::InvalidData.into());
}
let udp_outbound = udp_outbound.unwrap();
let server_addr = self.get_server_addr().await?;
self.clone()
.run_udp(
AdapterOrSocket::Adapter(Arc::from(udp_outbound)),
inbound,
server_addr,
abort_handle,
tunnel_only,
)
.await?;
let self_clone = self.clone();
tokio::spawn(async move {
let server_addr = self_clone.get_server_addr().await?;
self_clone
.run_udp(
AdapterOrSocket::Adapter(Arc::from(udp_outbound)),
inbound,
server_addr,
abort_handle,
tunnel_only,
)
.await
});
Ok(true)
}
}
Expand Down
9 changes: 6 additions & 3 deletions boltconn/src/adapter/socks5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,12 @@ impl Outbound for Socks5Outbound {
tracing::error!("Invalid Socks5 tcp spawn");
return Err(io::ErrorKind::InvalidData.into());
}
self.clone()
.run_tcp(inbound, tcp_outbound.unwrap(), abort_handle)
.await?;
let self_clone = self.clone();
tokio::spawn(async move {
self_clone
.run_tcp(inbound, tcp_outbound.unwrap(), abort_handle)
.await
});
Ok(true)
}

Expand Down
18 changes: 12 additions & 6 deletions boltconn/src/adapter/trojan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,12 @@ impl Outbound for TrojanOutbound {
tracing::error!("Invalid Trojan UDP outbound ancestor");
return Err(io::ErrorKind::InvalidData.into());
}
self.clone()
.run_tcp(inbound, tcp_outbound.unwrap(), abort_handle)
.await?;
let self_clone = self.clone();
tokio::spawn(async move {
self_clone
.run_tcp(inbound, tcp_outbound.unwrap(), abort_handle)
.await
});
Ok(true)
}

Expand Down Expand Up @@ -237,9 +240,12 @@ impl Outbound for TrojanOutbound {
return Err(io::ErrorKind::InvalidData.into());
}
let tcp_outbound = tcp_outbound.unwrap();
self.clone()
.run_udp(inbound, tcp_outbound, abort_handle, tunnel_only)
.await?;
let self_clone = self.clone();
tokio::spawn(async move {
self_clone
.run_udp(inbound, tcp_outbound, abort_handle, tunnel_only)
.await
});
Ok(true)
}
}
Expand Down

0 comments on commit 62d2eba

Please sign in to comment.