Skip to content

Commit

Permalink
feat(local): redir *bsd pfvar.h bindgen
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Feb 1, 2024
1 parent 67c4863 commit 4006cde
Show file tree
Hide file tree
Showing 13 changed files with 43,931 additions and 385 deletions.
355 changes: 191 additions & 164 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/shadowsocks-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ json5 = "0.4"
shadowsocks = { version = "1.17.2", path = "../shadowsocks", default-features = false }

# 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]
[target.'cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))'.dependencies]
nix = { version = "0.27", features = ["ioctl"] }

[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.52", features = ["Win32_Networking_WinSock"] }

[dev-dependencies]
byteorder = "1.5"
env_logger = "0.10"
env_logger = "0.11"

[package.metadata.docs.rs]
features = [
Expand Down
18 changes: 4 additions & 14 deletions crates/shadowsocks-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,10 +425,7 @@ cfg_if! {
///
/// Document: <https://www.freebsd.org/doc/handbook/firewalls-pf.html>
#[cfg(any(
target_os = "openbsd",
target_os = "freebsd",
target_os = "netbsd",
target_os = "solaris",
target_os = "macos",
target_os = "ios"
))]
Expand Down Expand Up @@ -469,7 +466,7 @@ cfg_if! {
const AVAILABLE_TYPES: &[&str] = &[RedirType::TProxy.name()];
AVAILABLE_TYPES
}
} else if #[cfg(any(target_os = "openbsd", target_os = "freebsd"))] {
} else if #[cfg(any(target_os = "freebsd"))] {
/// Default TCP transparent proxy solution on this platform
pub fn tcp_default() -> RedirType {
RedirType::PacketFilter
Expand All @@ -493,7 +490,7 @@ cfg_if! {
const AVAILABLE_TYPES: &[&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"))] {
} else if #[cfg(any(target_os = "macos", target_os = "ios"))] {
/// Default TCP transparent proxy solution on this platform
pub fn tcp_default() -> RedirType {
RedirType::PacketFilter
Expand All @@ -508,13 +505,13 @@ cfg_if! {

/// Default UDP transparent proxy solution on this platform
pub fn udp_default() -> RedirType {
RedirType::NotSupported
RedirType::PacketFilter
}

/// Available UDP transparent proxy types
#[doc(hidden)]
pub const fn udp_available_types() -> &'static [&'static str] {
const AVAILABLE_TYPES: &[&str] = &[];
const AVAILABLE_TYPES: &[&str] = &[RedirType::PacketFilter.name()];
AVAILABLE_TYPES
}
} else {
Expand Down Expand Up @@ -562,10 +559,7 @@ cfg_if! {
RedirType::TProxy => "tproxy",

#[cfg(any(
target_os = "openbsd",
target_os = "freebsd",
target_os = "netbsd",
target_os = "solaris",
target_os = "macos",
target_os = "ios"
))]
Expand Down Expand Up @@ -605,10 +599,7 @@ cfg_if! {
"tproxy" => Ok(RedirType::TProxy),

#[cfg(any(
target_os = "openbsd",
target_os = "freebsd",
target_os = "netbsd",
target_os = "solaris",
target_os = "macos",
target_os = "ios",
))]
Expand All @@ -618,7 +609,6 @@ cfg_if! {
target_os = "freebsd",
target_os = "macos",
target_os = "ios",
target_os = "dragonfly"
))]
"ipfw" => Ok(RedirType::IpFirewall),

Expand Down
2 changes: 0 additions & 2 deletions crates/shadowsocks-service/src/local/net/udp/association.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,6 @@ where
target_os = "watchos",
target_os = "tvos",
target_os = "freebsd",
// target_os = "dragonfly",
// target_os = "netbsd",
target_os = "windows",
));

Expand Down
Loading

0 comments on commit 4006cde

Please sign in to comment.