Skip to content

Commit 56e0cff

Browse files
committed
temp buf for msrv
1 parent cf3c983 commit 56e0cff

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

src/client/legacy/connect/proxy/socks/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ where
4141
T: Read + Unpin,
4242
M: for<'a> TryFrom<&'a mut BytesMut, Error = ParsingError>,
4343
{
44+
let mut tmp = [0; 513];
45+
println!();
4446
loop {
45-
let n = unsafe {
46-
let spare = &mut *(buf.spare_capacity_mut() as *mut _ as *mut [u8]);
47-
let n = crate::rt::read(&mut conn, spare).await?;
48-
buf.set_len(buf.len() + n);
49-
n
50-
};
47+
let n = crate::rt::read(&mut conn, &mut tmp).await?;
48+
buf.extend_from_slice(&tmp[..n]);
49+
50+
println!("{tmp:?}");
51+
println!("{buf:?}");
5152

5253
match M::try_from(buf) {
5354
Err(ParsingError::Incomplete) => {

src/client/legacy/connect/proxy/socks/v4/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ use bytes::BytesMut;
1818

1919
use pin_project_lite::pin_project;
2020

21-
/// TODO
21+
/// Tunnel Proxy via SOCKSv4
22+
///
23+
/// This is a connector that can be used by the `legacy::Client`. It wraps
24+
/// another connector, and after getting an underlying connection, it established
25+
/// a TCP tunnel over it using SOCKSv4.
2226
#[derive(Debug, Clone)]
2327
pub struct SocksV4<C> {
2428
inner: C,

src/client/legacy/connect/proxy/socks/v5/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ use bytes::BytesMut;
1818

1919
use pin_project_lite::pin_project;
2020

21-
/// TODO
21+
/// Tunnel Proxy via SOCKSv5
22+
///
23+
/// This is a connector that can be used by the `legacy::Client`. It wraps
24+
/// another connector, and after getting an underlying connection, it established
25+
/// a TCP tunnel over it using SOCKSv5.
2226
#[derive(Debug, Clone)]
2327
pub struct SocksV5<C> {
2428
inner: C,
@@ -154,8 +158,8 @@ impl SocksConfig {
154158
AuthMethod::NoAuth
155159
};
156160

157-
let mut recv_buf = BytesMut::with_capacity(1024);
158-
let mut send_buf = BytesMut::with_capacity(1024);
161+
let mut recv_buf = BytesMut::with_capacity(513); // Max length of valid recievable message is 513 from Auth Request
162+
let mut send_buf = BytesMut::with_capacity(262); // Max length of valid sendable message is 262 from Auth Response
159163
let mut state = State::SendingNegReq;
160164

161165
loop {

tests/proxy.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@ async fn test_socks_v4_works() {
360360
let conn = connector.call(target_dst).await.expect("tunnel");
361361
let mut tcp = conn.into_inner();
362362

363-
// TODO: broken here.
364-
365363
tcp.write_all(b"Hello World!").await.expect("write 1");
366364

367365
let mut buf = [0u8; 64];

0 commit comments

Comments
 (0)