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 805a8d9
Show file tree
Hide file tree
Showing 13 changed files with 50,174 additions and 400 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
27 changes: 5 additions & 22 deletions crates/shadowsocks-service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@ use serde::{Deserialize, Serialize};
use shadowsocks::relay::socks5::Address;
use shadowsocks::{
config::{
ManagerAddr,
Mode,
ReplayAttackPolicy,
ServerAddr,
ServerConfig,
ServerUser,
ServerUserManager,
ServerWeight,
ManagerAddr, Mode, ReplayAttackPolicy, ServerAddr, ServerConfig, ServerUser, ServerUserManager, ServerWeight,
},
crypto::CipherKind,
plugin::PluginConfig,
Expand Down Expand Up @@ -425,10 +418,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 +459,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 +483,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 +498,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 +552,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 +592,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 +602,6 @@ cfg_if! {
target_os = "freebsd",
target_os = "macos",
target_os = "ios",
target_os = "dragonfly"
))]
"ipfw" => Ok(RedirType::IpFirewall),

Expand Down
6 changes: 1 addition & 5 deletions crates/shadowsocks-service/src/local/net/udp/association.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ use shadowsocks::{
use crate::{
local::{context::ServiceContext, loadbalancing::PingBalancer},
net::{
packet_window::PacketWindowFilter,
MonProxySocket,
UDP_ASSOCIATION_KEEP_ALIVE_CHANNEL_SIZE,
packet_window::PacketWindowFilter, MonProxySocket, UDP_ASSOCIATION_KEEP_ALIVE_CHANNEL_SIZE,
UDP_ASSOCIATION_SEND_CHANNEL_SIZE,
},
};
Expand Down Expand Up @@ -473,8 +471,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 805a8d9

Please sign in to comment.