Merge branch 'rust' into feat/build-anrdoid

This commit is contained in:
sqlerrorthing
2025-11-01 02:54:44 +08:00
committed by GitHub
6 changed files with 39 additions and 10 deletions

3
.gitmodules vendored
View File

@@ -7,3 +7,6 @@
[submodule "rust/crates/libnfqws/zapret"] [submodule "rust/crates/libnfqws/zapret"]
path = rust/crates/libnfqws/zapret path = rust/crates/libnfqws/zapret
url = https://github.com/bol-van/zapret.git url = https://github.com/bol-van/zapret.git
[submodule "rust/crates/iptables"]
path = rust/crates/iptables
url = https://github.com/yaa110/rust-iptables

1
rust/Cargo.lock generated
View File

@@ -905,7 +905,6 @@ dependencies = [
"libnfqws", "libnfqws",
"log", "log",
"nix", "nix",
"once_cell",
"pretty_env_logger", "pretty_env_logger",
"regex", "regex",
"rust-ini", "rust-ini",

1
rust/crates/iptables Submodule

Submodule rust/crates/iptables added at e0e1f5dcc0

View File

@@ -14,7 +14,6 @@ serde = { workspace = true }
serde_json = { workspace = true } serde_json = { workspace = true }
sysctl ={ workspace = true } sysctl ={ workspace = true }
tokio = { workspace = true } tokio = { workspace = true }
once_cell = { workspace = true }
libnfqws = { path = "../libnfqws" } libnfqws = { path = "../libnfqws" }
daemonize = { workspace = true } daemonize = { workspace = true }
pretty_env_logger = { workspace = true } pretty_env_logger = { workspace = true }

View File

@@ -302,14 +302,22 @@ fn get_autostart() {
} }
fn service_status() -> bool { fn service_status() -> bool {
unimplemented!(); let pid_str = match fs::read_to_string(MODULE_PATH.join("tmp/pid.lock")) {
// match all_processes() { Ok(s) => s,
// Ok(iter) => iter Err(_) => return false,
// .filter_map(|rp| rp.ok()) };
// .filter_map(|p| p.stat().ok()) let pid = match pid_str.trim().parse::<i32>() {
// .any(|st| st.comm == "zaprett"), Ok(p) => p,
// Err(_) => false, Err(_) => return false,
// } };
return true
/*match all_processes() {
Ok(iter) => iter
.filter_map(|rp| rp.ok())
.filter_map(|p| p.stat().ok())
.any(|st| st.pid == pid),
Err(_) => false,
}*/
} }
fn module_version() { fn module_version() {

View File

@@ -0,0 +1,19 @@
diff --git a/crates/iptables/src/lib.rs b/crates/iptables/src/lib.rs
index 4a4d6dc..e7d15fc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -92,14 +92,6 @@ pub struct IPTables {
pub is_numeric: bool,
}
-/// Returns `None` because iptables only works on linux
-#[cfg(not(target_os = "linux"))]
-pub fn new(is_ipv6: bool) -> Result<IPTables, Box<dyn Error>> {
- Err(error_from_str("iptables only works on Linux"))
-}
-
-/// Creates a new `IPTables` Result with the command of 'iptables' if `is_ipv6` is `false`, otherwise the command is 'ip6tables'.
-#[cfg(target_os = "linux")]
pub fn new(is_ipv6: bool) -> Result<IPTables, Box<dyn Error>> {
let cmd = if is_ipv6 { "ip6tables" } else { "iptables" };