Skip to content

Commit

Permalink
Introduce more features to make the crate cleaner.
Browse files Browse the repository at this point in the history
  • Loading branch information
ssrlive committed Dec 14, 2024
1 parent 3515a3f commit 9bc86c3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
27 changes: 18 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ license = "GPL-3.0-or-later"
repository = "https://github.com/ssrlive/socks5-impl"

[features]
default = ["tokio"]
default = []
client = ["tokio"]
serde = ["dep:serde"]
server = ["tokio"]
tokio = ["dep:tokio"]

[dependencies]
Expand All @@ -20,25 +23,31 @@ async-trait = "0.1"
byteorder = "1"
bytes = "1"
percent-encoding = "2"
serde = { version = "1", features = ["derive"] }
serde = { version = "1", features = ["derive"], optional = true }
thiserror = "2"
tokio = { version = "1", features = ["full"], optional = true }
tokio = { version = "1", default-features = false, features = [
"net",
"io-util",
"time",
"macros",
"rt",
], optional = true }

[dev-dependencies]
clap = { version = "4", features = ["derive"] }
ctrlc2 = { version = "3", features = ["tokio", "termination"] }
dotenvy = "0.15"
env_logger = "0.11"
hickory-proto = "0.24"
log = "0.4"
moka = { version = "0.12", features = ["future"] }
rand = "0.8"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
hickory-proto = "0.24"
tokio = { version = "1", features = ["rt-multi-thread"] }

[[example]]
name = "demo-client"
path = "examples/demo-client.rs"
required-features = ["tokio"]
required-features = ["client"]

[[example]]
name = "demo-server"
Expand All @@ -48,14 +57,14 @@ required-features = ["tokio"]
[[example]]
name = "dns-query"
path = "examples/dns-query.rs"
required-features = ["tokio"]
required-features = ["client"]

[[example]]
name = "s5-server"
path = "examples/s5-server.rs"
required-features = ["tokio"]
required-features = ["server"]

[[example]]
name = "udp-client"
path = "examples/udp-client.rs"
required-features = ["tokio"]
required-features = ["client"]
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![doc = include_str!("../README.md")]

#[cfg(feature = "tokio")]
#[cfg(feature = "client")]
pub mod client;
pub(crate) mod error;
pub mod protocol;
#[cfg(feature = "tokio")]
#[cfg(feature = "server")]
pub mod server;

pub use crate::error::{Error, Result};
5 changes: 2 additions & 3 deletions src/protocol/handshake/password_method/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
mod request;
mod response;

use serde::{Deserialize, Serialize};

pub use self::{
request::Request,
response::{Response, Status},
Expand All @@ -11,7 +9,8 @@ pub use self::{
pub const SUBNEGOTIATION_VERSION: u8 = 0x01;

/// Required for a username + password authentication.
#[derive(Default, Debug, Eq, PartialEq, Clone, Hash, Deserialize, Serialize)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[derive(Default, Debug, Eq, PartialEq, Clone, Hash)]
pub struct UserKey {
pub username: String,
pub password: String,
Expand Down

0 comments on commit 9bc86c3

Please sign in to comment.