16 Commits
main ... hybrid

Author SHA1 Message Date
CherretGit
b038b6c977 Merge pull request #15 from egor-white/main
Update update's.json and changelog
2026-01-20 23:34:00 +07:00
CherretGit
93763862ad Merge pull request #14 from egor-white/main
Update print statement from 'Hello' to 'Goodbye'
2026-01-20 23:17:00 +07:00
CherretGit
fde07bae80 Merge pull request #13 from egor-white/main
fix zaprett-hosts
2026-01-20 22:07:52 +07:00
CherretGit
0b339eb2f9 fix bindgen 2026-01-20 21:48:17 +07:00
CherretGit
86defa0cb3 fix workflow 2026-01-20 21:31:22 +07:00
CherretGit
54e0e421ec try to fix justfile №3 2026-01-20 21:27:53 +07:00
CherretGit
a473e5c64b try to fix justfile №2 2026-01-20 21:21:10 +07:00
CherretGit
d503b4229a try to fix justfile 2026-01-20 21:09:35 +07:00
CherretGit
a89008497f remove luajit from cargo.toml, add libnfqws2 2026-01-20 21:00:31 +07:00
CherretGit
979c100259 add luajit to justfile 2026-01-20 20:53:05 +07:00
CherretGit
725510bafb remove return 2026-01-20 20:17:01 +07:00
egor-white
32b1bc9de9 Merge branch 'main' into hybrid 2026-01-19 16:27:18 +03:00
egor-white
634f9245b2 Revert "migrate tv version to default package"
This reverts commit 4526c6d313.
2026-01-19 16:13:03 +03:00
egor-white
4526c6d313 migrate tv version to default package 2026-01-19 16:08:59 +03:00
egor-white
cceed3a1d7 add luajit 2026-01-19 16:04:01 +03:00
egor-white
60f112656a add zapret2 as submodule, configure zapret2 crate compiling 2026-01-19 16:01:51 +03:00
11 changed files with 143 additions and 14 deletions

View File

@@ -44,7 +44,10 @@ jobs:
run: git submodule update --init --recursive
- name: Install dependencies
run: sudo apt install build-essential pkg-config just unzip
run: |
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y build-essential pkg-config just unzip libc6-dev-i386 gcc-multilib
- name: Build zaprett
run: just -f rust/justfile build-android --release

View File

@@ -44,7 +44,10 @@ jobs:
run: git submodule update --init --recursive
- name: Install dependencies
run: sudo apt install build-essential pkg-config just unzip
run: |
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install -y build-essential pkg-config just unzip libc6-dev-i386 gcc-multilib
- name: Build zaprett
run: just -f rust/justfile build-android --release

3
.gitmodules vendored
View File

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

11
rust/Cargo.lock generated
View File

@@ -385,6 +385,16 @@ dependencies = [
"once_cell",
]
[[package]]
name = "libnfqws2"
version = "0.0.1"
dependencies = [
"bindgen",
"cc",
"glob",
"once_cell",
]
[[package]]
name = "lock_api"
version = "0.4.14"
@@ -1113,6 +1123,7 @@ dependencies = [
"getset",
"libc",
"libnfqws",
"libnfqws2",
"log",
"nix",
"pretty_env_logger",

View File

@@ -0,0 +1,11 @@
[package]
name = "libnfqws2"
version.workspace = true
edition.workspace = true
repository.workspace = true
[build-dependencies]
cc = "1.2.43"
once_cell = "1.21.3"
glob = "0.3.3"
bindgen = "0.72.1"

View File

@@ -0,0 +1,71 @@
use once_cell::sync::Lazy;
use std::env;
use std::path::{Path, PathBuf};
macro_rules! rel_manifest_path {
($name:ident, $path:expr) => {
static $name: Lazy<PathBuf> = Lazy::new(|| {
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
Path::new(&manifest_dir).join($path)
});
};
}
rel_manifest_path!(NFQ, "zapret2/nfq2");
rel_manifest_path!(NFQ_CRYPTO, "zapret2/nfq2/crypto");
fn main() {
cc::Build::new()
.files(
glob::glob(&format!("{}/*.c", NFQ.display()))
.unwrap()
.filter_map(Result::ok),
)
.files(
glob::glob(&format!("{}/*.c", NFQ_CRYPTO.display()))
.unwrap()
.filter_map(Result::ok),
)
.include(&*NFQ)
.include(&*NFQ_CRYPTO)
.flag("-w")
.define("main", "nfqws2_main")
.compile("libnfqws2.a");
println!("cargo:rustc-link-lib=z");
println!("cargo:rustc-link-lib=netfilter_queue");
println!("cargo:rustc-link-lib=nfnetlink");
println!("cargo:rustc-link-lib=mnl");
let _ = env::var("NETFILTER_LIBS")
.map(|libs| println!("cargo:rustc-link-search=native={libs}/lib"));
println!("cargo:rustc-link-lib=static=nfqws2");
println!("cargo:rerun-if-changed={}", NFQ.display());
println!("cargo:rerun-if-changed={}", NFQ_CRYPTO.display());
println!("cargo:rerun-if-changed=build.rs");
let mut builder = bindgen::Builder::default();
for header in glob::glob(&format!("{}/*.h", NFQ.display()))
.unwrap()
.filter_map(Result::ok)
{
builder = builder.header(header.to_string_lossy());
}
if let Ok(luajit) = env::var("LUAJIT") {
builder = builder
.clang_arg(format!("-I{}", luajit))
.clang_arg("-Dmain=nfqws2_main");
}
let bindings = builder
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate()
.expect("Unable to generate libnfqws2");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("libnfqws2.rs"))
.expect("Couldn't write libnfqws2");
}

View File

@@ -0,0 +1,2 @@
#![allow(warnings)]
include!(concat!(env!("OUT_DIR"), "/libnfqws2.rs"));

View File

@@ -15,6 +15,7 @@ serde_json = { workspace = true }
sysctl ={ workspace = true }
tokio = { workspace = true }
libnfqws = { path = "../libnfqws" }
libnfqws2 = { path = "../libnfqws2" }
daemonize = { workspace = true }
pretty_env_logger = { workspace = true }
log = { workspace = true }

View File

@@ -2,7 +2,6 @@ use crate::autostart::{get_autostart, set_autostart};
use crate::service::{restart_service, service_status, start_service, stop_service};
use crate::{bin_version, module_version, run_nfqws};
use clap::Subcommand;
use log::error;
#[derive(Subcommand)]
pub enum Command {
@@ -40,11 +39,9 @@ pub enum Command {
impl Command {
pub async fn exec(&self) -> anyhow::Result<()> {
match self {
Command::Start => return start_service().await,
Command::Stop => {
let _ = stop_service().await;
}
Command::Restart => return restart_service().await,
Command::Start => start_service().await?,
Command::Stop => stop_service().await?,
Command::Restart => restart_service().await?,
Command::Status => {
println!(
"zaprett is {}",
@@ -55,11 +52,7 @@ impl Command {
}
);
}
Command::SetAutostart => {
if let Err(err) = set_autostart().await {
error!("Failed to set auto start: {err}")
}
}
Command::SetAutostart => set_autostart().await?,
Command::GetAutostart => println!("{}", get_autostart()),
Command::ModuleVersion => println!("{}", module_version().await?),
Command::BinaryVersion => println!("{}", bin_version()),

View File

@@ -61,6 +61,32 @@ _build_netfilter_libs target_arch:
patch -p1 -d libnetfilter_queue-* -i $PATCH
fi
if [ ! -d "luajit2-*" ]; then
wget -qO- https://github.com/openresty/luajit2/archive/refs/tags/v2.1-20250826.tar.gz | tar -xz
fi
case "{{target_arch}}" in
*64*)
HOSTCC="cc"
;;
*)
HOSTCC="cc -m32"
esac
(
cd luajit2-*
make BUILDMODE=static XCFLAGS=-DLUAJIT_DISABLE_FFI \
HOST_CC="$HOSTCC" CROSS= CC="$CC" \
TARGET_AR="$AR rcus" TARGET_STRIP=$STRIP \
CFLAGS="-Os -flto=auto $CFLAGS" -j$(nproc)
make install PREFIX= DESTDIR=$NETFILTER_LIBS-{{target_arch}}
)
LJIT=1
LCFLAGS="-I${NETFILTER_LIBS-{{target_arch}}}/include/luajit-2.1"
LLIB="-L${NETFILTER_LIBS-{{target_arch}}}/lib -lluajit-2.1"
for i in libmnl libnfnetlink libnetfilter_queue ; do
(
cd $i-*
@@ -98,9 +124,13 @@ build-android *args: prepare-android
t=${targets[$i]}
(
echo "Building target $t"
export CFLAGS="-I$NETFILTER_LIBS-$t/include"
export CFLAGS="-I$NETFILTER_LIBS-$t/include -I$NETFILTER_LIBS-$t/include/luajit-2.1"
export LUAJIT="$NETFILTER_LIBS-$t/include/luajit-2.1"
export LDFLAGS="-L$NETFILTER_LIBS-$t/lib"
export CXXFLAGS="$CFLAGS"
export LJIT=1
export LCFLAGS="-I$NETFILTER_LIBS-$t/include -I$NETFILTER_LIBS-$t/include/luajit-2.1"
export LLIB="-L$NETFILTER_LIBS-$t/lib -lluajit-2.1"
just _build_netfilter_libs $t
just _instal_rust_target $t