diff --git a/Cargo.toml b/Cargo.toml index 0f321a6..248eef9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "socks-hub" -version = "0.1.10" +version = "0.1.11" license = "MIT" repository = "https://github.com/ssrlive/socks-hub" homepage = "https://github.com/ssrlive/socks-hub" @@ -13,29 +13,66 @@ edition = "2021" crate-type = ["staticlib", "cdylib", "lib"] [features] -default = ["acl"] -acl = ["idna", "ipnet", "iprange", "once_cell", "regex"] +default = ["sockshub", "acl"] +acl = [ + "idna", + "ipnet", + "iprange", + "once_cell", + "regex", + "socks5-impl", + "tokio", + "log", +] +base64 = ["dep:base64"] +sockshub = [ + "base64", + "socks5-impl", + "tokio", + "ctrlc2", + "env_logger", + "serde", + "serde_derive", + "serde_json", + "clap", + "chrono", + "http-body-util", + "hyper", + "dotenvy", + "as-any", + "bytes", + "pin-project-lite", + "log", +] [dependencies] -as-any = "0.3" -base64 = "0.22" -bytes = "1.5" -chrono = "0.4" -clap = { version = "4.5", features = ["derive"] } -ctrlc2 = { version = "3.5", features = ["termination", "tokio"] } -dotenvy = "0.15" -env_logger = "0.11" -http-body-util = "0.1" -hyper = { version = "1.1", features = ["full"] } +as-any = { version = "0.3", optional = true } +base64 = { version = "0.22", optional = true } +bytes = { version = "1.5", optional = true } +cfg-if = "1.0" +chrono = { version = "0.4", optional = true } +clap = { version = "4.5", features = ["derive"], optional = true } +ctrlc2 = { version = "3.5", features = [ + "termination", + "tokio", +], optional = true } +dotenvy = { version = "0.15", optional = true } +env_logger = { version = "0.11", optional = true } +http-body-util = { version = "0.1", optional = true } +hyper = { version = "1.1", features = ["full"], optional = true } idna = { version = "0.5", optional = true } ipnet = { version = "2.9", optional = true } iprange = { version = "0.6", optional = true } -log = "0.4" +log = { version = "0.4", optional = true } once_cell = { version = "1.19", optional = true } -pin-project-lite = { version = "0.2" } +pin-project-lite = { version = "0.2", optional = true } regex = { version = "1.10", optional = true } -serde = "1.0" -serde_derive = "1.0" -serde_json = "1.0" -socks5-impl = "0.5" -tokio = { version = "1", features = ["full"] } +serde = { version = "1.0", optional = true } +serde_derive = { version = "1.0", optional = true } +serde_json = { version = "1.0", optional = true } +socks5-impl = { version = "0.5", optional = true } +tokio = { version = "1", features = ["full"], optional = true } + +[[bin]] +name = "socks-hub" +required-features = ["sockshub", "acl"] diff --git a/src/lib.rs b/src/lib.rs index 98c06d9..33c76c5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,22 @@ -pub mod config; -pub use config::{ArgVerbosity, Config, Credentials, ProxyType}; +cfg_if::cfg_if! { + if #[cfg(feature = "base64")] { + mod base64_wrapper; + pub use base64_wrapper::{base64_decode, base64_encode, Base64Engine}; + } +} + +cfg_if::cfg_if! { + if #[cfg(feature = "acl")] { + mod acl; + pub use acl::AccessControl; + } +} -pub mod base64_wrapper; -pub use base64_wrapper::{base64_decode, base64_encode, Base64Engine}; +cfg_if::cfg_if! { + if #[cfg(feature = "sockshub")] { + +mod config; +pub use config::{ArgVerbosity, Config, Credentials, ProxyType}; mod tokiort; use tokiort::TokioIo; @@ -10,8 +24,6 @@ use tokiort::TokioIo; mod http2socks; mod socks2socks; -#[cfg(feature = "acl")] -pub mod acl; mod api; mod dump_logger; mod ffi; @@ -54,3 +66,6 @@ pub(crate) async fn create_s5_connect( pub(crate) fn std_io_error_other>(err: E) -> std::io::Error { std::io::Error::new(std::io::ErrorKind::Other, err) } + + } +}