mirror of
https://github.com/shadowsocks/shadowsocks-rust.git
synced 2026-11-18 16:16:52 +00:00
properly set available redir types for TCP and UDP separately
This commit is contained in:
Generated
+2
-22
@@ -1538,7 +1538,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "shadowsocks-rust"
|
||||
version = "1.11.0"
|
||||
version = "1.11.1"
|
||||
dependencies = [
|
||||
"byte_string",
|
||||
"byteorder",
|
||||
@@ -1561,7 +1561,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "shadowsocks-service"
|
||||
version = "1.11.0"
|
||||
version = "1.11.1"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"byte_string",
|
||||
@@ -1591,8 +1591,6 @@ dependencies = [
|
||||
"shadowsocks",
|
||||
"socket2 0.4.0",
|
||||
"spin 0.9.0",
|
||||
"strum",
|
||||
"strum_macros",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
@@ -1689,24 +1687,6 @@ version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7318c509b5ba57f18533982607f24070a55d353e90d4cae30c467cdb2ad5ac5c"
|
||||
|
||||
[[package]]
|
||||
name = "strum_macros"
|
||||
version = "0.20.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee8bc6b87a5112aeeab1f4a9f7ab634fe6cbefc4850006df31267f4cfb9e3149"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.72"
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "shadowsocks-rust"
|
||||
version = "1.11.0"
|
||||
version = "1.11.1"
|
||||
authors = ["Shadowsocks Contributors"]
|
||||
description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls."
|
||||
repository = "https://github.com/shadowsocks/shadowsocks-rust"
|
||||
|
||||
+2
-4
@@ -124,17 +124,15 @@ fn main() {
|
||||
|
||||
#[cfg(feature = "local-redir")]
|
||||
{
|
||||
let available_redir_types = RedirType::available_types();
|
||||
|
||||
if RedirType::tcp_default() != RedirType::NotSupported {
|
||||
app = clap_app!(@app (app)
|
||||
(@arg TCP_REDIR: --("tcp-redir") +takes_value requires[LOCAL_ADDR] possible_values(&available_redir_types) "TCP redir (transparent proxy) type")
|
||||
(@arg TCP_REDIR: --("tcp-redir") +takes_value requires[LOCAL_ADDR] possible_values(RedirType::tcp_available_types()) "TCP redir (transparent proxy) type")
|
||||
);
|
||||
}
|
||||
|
||||
if RedirType::udp_default() != RedirType::NotSupported {
|
||||
app = clap_app!(@app (app)
|
||||
(@arg UDP_REDIR: --("udp-redir") +takes_value requires[LOCAL_ADDR] possible_values(&available_redir_types) "UDP redir (transparent proxy) type")
|
||||
(@arg UDP_REDIR: --("udp-redir") +takes_value requires[LOCAL_ADDR] possible_values(RedirType::udp_available_types()) "UDP redir (transparent proxy) type")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "shadowsocks-service"
|
||||
version = "1.11.0"
|
||||
version = "1.11.1"
|
||||
authors = ["Shadowsocks Contributors"]
|
||||
description = "shadowsocks is a fast tunnel proxy that helps you bypass firewalls."
|
||||
repository = "https://github.com/shadowsocks/shadowsocks-rust"
|
||||
@@ -50,7 +50,7 @@ local-http-native-tls = ["local-http", "tokio-native-tls", "native-tls"]
|
||||
local-http-rustls = ["local-http", "tokio-rustls", "webpki-roots", "rustls-native-certs"]
|
||||
# Enable REDIR protocol for sslocal
|
||||
# (transparent proxy)
|
||||
local-redir = ["local", "strum", "strum_macros", "mio"]
|
||||
local-redir = ["local", "mio"]
|
||||
# Enable tunnel protocol for sslocal
|
||||
local-tunnel = ["local"]
|
||||
# Enable socks4 protocol for sslocal
|
||||
@@ -110,9 +110,6 @@ json5 = "0.3"
|
||||
|
||||
shadowsocks = { version = "1.10.2", path = "../shadowsocks" }
|
||||
|
||||
strum = { version = "0.20", optional = true }
|
||||
strum_macros = { version = "0.20", optional = true }
|
||||
|
||||
# Just for the ioctl call macro
|
||||
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd"))'.dependencies]
|
||||
nix = "0.20"
|
||||
|
||||
@@ -250,11 +250,8 @@ impl ConfigType {
|
||||
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "local-redir")] {
|
||||
use strum::IntoEnumIterator;
|
||||
use strum_macros::EnumIter;
|
||||
|
||||
/// Transparent Proxy type
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, EnumIter)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum RedirType {
|
||||
/// For not supported platforms
|
||||
NotSupported,
|
||||
@@ -301,44 +298,100 @@ cfg_if! {
|
||||
cfg_if! {
|
||||
if #[cfg(any(target_os = "linux", target_os = "android"))] {
|
||||
/// Default TCP transparent proxy solution on this platform
|
||||
pub fn tcp_default() -> RedirType {
|
||||
pub const fn tcp_default() -> RedirType {
|
||||
RedirType::Redirect
|
||||
}
|
||||
|
||||
/// Available TCP transparent proxy types
|
||||
#[doc(hidden)]
|
||||
pub fn tcp_available_types() -> &'static [&'static str] {
|
||||
const AVAILABLE_TYPES: &'static [&'static str] = &[RedirType::Redirect.name(), RedirType::TProxy.name()];
|
||||
AVAILABLE_TYPES
|
||||
}
|
||||
|
||||
/// Default UDP transparent proxy solution on this platform
|
||||
pub fn udp_default() -> RedirType {
|
||||
pub const fn udp_default() -> RedirType {
|
||||
RedirType::TProxy
|
||||
}
|
||||
|
||||
/// Available UDP transparent proxy types
|
||||
#[doc(hidden)]
|
||||
pub fn udp_available_types() -> &'static [&'static str] {
|
||||
const AVAILABLE_TYPES: &'static [&'static str] = &[RedirType::TProxy.name()];
|
||||
AVAILABLE_TYPES
|
||||
}
|
||||
} else if #[cfg(any(target_os = "openbsd", target_os = "freebsd"))] {
|
||||
/// Default TCP transparent proxy solution on this platform
|
||||
pub fn tcp_default() -> RedirType {
|
||||
RedirType::PacketFilter
|
||||
}
|
||||
|
||||
/// Available TCP transparent proxy types
|
||||
#[doc(hidden)]
|
||||
pub fn tcp_available_types() -> &'static [&'static str] {
|
||||
const AVAILABLE_TYPES: &'static [&'static str] = &[RedirType::PacketFilter.name(), RedirType::IpFirewall.name()];
|
||||
AVAILABLE_TYPES
|
||||
}
|
||||
|
||||
/// Default UDP transparent proxy solution on this platform
|
||||
pub fn udp_default() -> RedirType {
|
||||
RedirType::PacketFilter
|
||||
}
|
||||
|
||||
/// Available UDP transparent proxy types
|
||||
#[doc(hidden)]
|
||||
pub const fn udp_available_types() -> &'static [&'static str] {
|
||||
const AVAILABLE_TYPES: &'static [&'static str] = &[RedirType::PacketFilter.name(), RedirType::IpFirewall.name()];
|
||||
AVAILABLE_TYPES
|
||||
}
|
||||
} else if #[cfg(any(target_os = "netbsd", target_os = "solaris", target_os = "macos", target_os = "ios"))] {
|
||||
/// Default TCP transparent proxy solution on this platform
|
||||
pub fn tcp_default() -> RedirType {
|
||||
RedirType::PacketFilter
|
||||
}
|
||||
|
||||
/// Available TCP transparent proxy types
|
||||
#[doc(hidden)]
|
||||
pub const fn tcp_available_types() -> &'static [&'static str] {
|
||||
const AVAILABLE_TYPES: &'static [&'static str] = &[RedirType::PacketFilter.name(), RedirType::IpFirewall.name()];
|
||||
AVAILABLE_TYPES
|
||||
}
|
||||
|
||||
/// Default UDP transparent proxy solution on this platform
|
||||
pub fn udp_default() -> RedirType {
|
||||
RedirType::NotSupported
|
||||
}
|
||||
|
||||
/// Available UDP transparent proxy types
|
||||
#[doc(hidden)]
|
||||
pub const fn udp_available_types() -> &'static [&'static str] {
|
||||
const AVAILABLE_TYPES: &'static [&'static str] = &[];
|
||||
AVAILABLE_TYPES
|
||||
}
|
||||
} else {
|
||||
/// Default TCP transparent proxy solution on this platform
|
||||
pub fn tcp_default() -> RedirType {
|
||||
RedirType::NotSupported
|
||||
}
|
||||
|
||||
/// Available TCP transparent proxy types
|
||||
#[doc(hidden)]
|
||||
pub const fn tcp_available_types() -> &'static [&'static str] {
|
||||
const AVAILABLE_TYPES: &'static [&'static str] = &[];
|
||||
AVAILABLE_TYPES
|
||||
}
|
||||
|
||||
/// Default UDP transparent proxy solution on this platform
|
||||
pub fn udp_default() -> RedirType {
|
||||
RedirType::NotSupported
|
||||
}
|
||||
|
||||
/// Available UDP transparent proxy types
|
||||
#[doc(hidden)]
|
||||
pub const fn udp_available_types() -> &'static [&'static str] {
|
||||
const AVAILABLE_TYPES: &'static [&'static str] = &[];
|
||||
AVAILABLE_TYPES
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,7 +401,7 @@ cfg_if! {
|
||||
}
|
||||
|
||||
/// Name of redirect type (transparent proxy type)
|
||||
pub fn name(self) -> &'static str {
|
||||
pub const fn name(self) -> &'static str {
|
||||
match self {
|
||||
// Dummy, shouldn't be used in any useful situations
|
||||
RedirType::NotSupported => "not_supported",
|
||||
@@ -373,19 +426,6 @@ cfg_if! {
|
||||
RedirType::IpFirewall => "ipfw",
|
||||
}
|
||||
}
|
||||
|
||||
/// Get all available types
|
||||
pub fn available_types() -> Vec<&'static str> {
|
||||
let mut v = Vec::new();
|
||||
for e in Self::iter() {
|
||||
match e {
|
||||
RedirType::NotSupported => continue,
|
||||
#[allow(unreachable_patterns)]
|
||||
_ => v.push(e.name()),
|
||||
}
|
||||
}
|
||||
v
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for RedirType {
|
||||
|
||||
Reference in New Issue
Block a user