Skip to content

Commit

Permalink
feat: allow_no_auth, for scenario where we could auth the client vi…
Browse files Browse the repository at this point in the history
…a other parameters such as headers

feat: credentials can be fetch once the socket has been successfully upgraded to socks5 (hence successfully authenticated)
  • Loading branch information
dizda committed Jun 23, 2023
1 parent 2f72c59 commit 83bdf3f
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 65 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tokio = { version = "1.25.0", features = ["io-util", "net", "time", "macros"] }
anyhow = "1.0"
thiserror = "1.0"
tokio-stream = "0.1.9"
futures = "0.3"
async-trait = "0.1.68"

# Dependencies for examples and tests
[dev-dependencies]
Expand Down
11 changes: 7 additions & 4 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::read_exact;
use crate::util::target_addr::{read_address, TargetAddr, ToTargetAddr};
use crate::util::stream::{tcp_connect, tcp_connect_with_timeout};
use crate::util::target_addr::{read_address, TargetAddr, ToTargetAddr};
use crate::{
consts, new_udp_header, parse_udp_request, AuthenticationMethod, ReplyError, Result,
Socks5Command, SocksError,
Expand All @@ -27,7 +27,10 @@ pub struct Config {

impl Default for Config {
fn default() -> Self {
Config { connect_timeout: None, skip_auth: false }
Config {
connect_timeout: None,
skip_auth: false,
}
}
}

Expand Down Expand Up @@ -185,7 +188,7 @@ where
_ => {
debug!("Don't support this auth method, reply with (0xff)");
self.socket
.write(&[
.write_all(&[
consts::SOCKS5_VERSION,
consts::SOCKS5_AUTH_METHOD_NOT_ACCEPTABLE,
])
Expand All @@ -209,7 +212,7 @@ where
}) => Ok((username, password)),
None => Err(SocksError::AuthenticationRejected(format!(
"Authentication rejected, missing user pass"
)))
))),
}?;

let user_bytes = username.as_bytes();
Expand Down
Loading

0 comments on commit 83bdf3f

Please sign in to comment.