Skip to content

Commit

Permalink
Merge pull request #38 from RoKu1/master
Browse files Browse the repository at this point in the history
Added SOCKS4 support.
  • Loading branch information
sticnarf authored Jun 18, 2024
2 parents a04d649 + 53efef4 commit f1eac4f
Show file tree
Hide file tree
Showing 22 changed files with 726 additions and 44 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ Cargo.lock
out/

# Vscode files
.vscode/**
.vscode/**

docker-compose.yml
Dockerfile
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.5.2

* Added SOCKS4 support `bind` and `connect`.

# 0.5.1

* Reduce dependencies on `futures` crate (#30)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ readme = "README.md"
categories = ["asynchronous", "network-programming"]
keywords = ["tokio", "async", "proxy", "socks", "socks5"]
license = "MIT"
version = "0.5.1"
version = "0.5.2"
authors = ["Yilin Chen <[email protected]>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Asynchronous SOCKS proxy support for Rust.
- [ ] GSSAPI authentication
- [ ] Asynchronous DNS resolution
- [X] Chain proxies ([see example](examples/chainproxy.rs))
- [ ] SOCKS4
- [X] SOCKS4

## License

Expand Down
2 changes: 1 addition & 1 deletion examples/chainproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tokio::{
net::TcpStream,
runtime::Runtime,
};
use tokio_socks::{tcp::Socks5Stream, Error};
use tokio_socks::{tcp::socks5::Socks5Stream, Error};

const PROXY_ADDR: [&str; 2] = ["184.176.166.20:4145", "90.89.205.248:1080"]; // public proxies found here : http://spys.one/en/socks-proxy-list/
const DEST_ADDR: &str = "duckduckgo.com:80";
Expand Down
2 changes: 1 addition & 1 deletion examples/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tokio::{
net::{TcpStream, UnixStream},
runtime::Runtime,
};
use tokio_socks::{tcp::Socks5Stream, Error};
use tokio_socks::{tcp::socks5::Socks5Stream, Error};

const UNIX_PROXY_ADDR: &str = "/tmp/tor/socket.s";
const TCP_PROXY_ADDR: &str = "127.0.0.1:9050";
Expand Down
2 changes: 1 addition & 1 deletion examples/tor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
runtime::Runtime,
};
use tokio_socks::{tcp::Socks5Stream, Error};
use tokio_socks::{tcp::socks5::Socks5Stream, Error};

const PROXY_ADDR: &str = "127.0.0.1:9050";
const ONION_ADDR: &str = "3g2upl4pq6kufc4m.onion:80"; // DuckDuckGo
Expand Down
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use_small_heuristics = "default"
use_small_heuristics = "Default"
hard_tabs = false
imports_layout = "HorizontalVertical"
merge_imports = true
Expand Down
6 changes: 6 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ pub enum Error {

#[error("Authorization required")]
AuthorizationRequired,

#[error("Request rejected because SOCKS server cannot connect to identd on the client")]
IdentdAuthFailure,

#[error("Request rejected because the client program and identd report different user-ids")]
InvalidUserIdAuthFailure,
}

///// Result type of `tokio-socks`
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ impl IntoTargetAddr<'static> for (String, u16) {
}

impl<'a, T> IntoTargetAddr<'a> for &'a T
where T: IntoTargetAddr<'a> + Copy
where
T: IntoTargetAddr<'a> + Copy,
{
fn into_target_addr(self) -> Result<TargetAddr<'a>> {
(*self).into_target_addr()
Expand Down Expand Up @@ -299,7 +300,9 @@ mod tests {
}

fn into_target_addr<'a, T>(t: T) -> Result<TargetAddr<'a>>
where T: IntoTargetAddr<'a> {
where
T: IntoTargetAddr<'a>,
{
t.into_target_addr()
}

Expand Down
5 changes: 5 additions & 0 deletions src/tcp/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pub mod socks4;
pub mod socks5;

pub use socks4::*;
pub use socks5::*;
Loading

0 comments on commit f1eac4f

Please sign in to comment.