mirror of
https://github.com/egor-white/zaprett.git
synced 2026-03-22 00:18:13 +05:00
new build system
This commit is contained in:
@@ -22,6 +22,30 @@ echo "Copy files to dirs"
|
||||
cp rust/target/armv7-linux-androideabi/release/zaprett zaprett/system/bin/zaprett-armv7
|
||||
cp rust/target/aarch64-linux-android/release/zaprett zaprett/system/bin/zaprett-aarch64
|
||||
cp rust/target/x86_64-linux-android/release/zaprett zaprett/system/bin/zaprett-x86_64
|
||||
|
||||
echo "Copy shared libraries"
|
||||
for arch in armeabi-v7a arm64-v8a x86_64; do
|
||||
case "$arch" in
|
||||
armeabi-v7a) target=armv7-linux-androideabi ;;
|
||||
arm64-v8a) target=aarch64-linux-android ;;
|
||||
x86_64) target=x86_64-linux-android ;;
|
||||
esac
|
||||
|
||||
src_dir="rust/target/${target}/release"
|
||||
lib_dir="zaprett/system/lib/$arch"
|
||||
mkdir -p "$lib_dir"
|
||||
|
||||
for lib in libnfqws.so libnfqws2.so; do
|
||||
found=$(find "$src_dir" -name "$lib" -type f | head -n 1)
|
||||
if [ -n "$found" ]; then
|
||||
cp "$found" "$lib_dir/"
|
||||
echo "Copied $lib for $arch"
|
||||
else
|
||||
echo "Warning: $lib not found for $arch in $src_dir"
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
cp -a src/* zaprett/
|
||||
cp -r zaprett/* zaprett-hosts/
|
||||
|
||||
|
||||
29
rust/Cargo.lock
generated
29
rust/Cargo.lock
generated
@@ -107,9 +107,9 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.43"
|
||||
version = "1.2.57"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "739eb0f94557554b3ca9a86d2d37bebd49c5e6d0c1d2bda35ba5bdac830befc2"
|
||||
checksum = "7a0dd1ca384932ff3641c8718a02769f1698e7563dc6974ffd03346116310423"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"shlex",
|
||||
@@ -187,6 +187,15 @@ version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
|
||||
|
||||
[[package]]
|
||||
name = "cmake"
|
||||
version = "0.1.57"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.4"
|
||||
@@ -235,9 +244,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.4"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127"
|
||||
checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582"
|
||||
|
||||
[[package]]
|
||||
name = "getset"
|
||||
@@ -328,9 +337,8 @@ name = "libnfqws"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
"cmake",
|
||||
"glob",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -338,9 +346,8 @@ name = "libnfqws2"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cc",
|
||||
"cmake",
|
||||
"glob",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -431,12 +438,6 @@ dependencies = [
|
||||
"objc2-core-foundation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell_polyfill"
|
||||
version = "1.70.2"
|
||||
|
||||
34
rust/crates/libnfqws/CMakeLists.txt
Normal file
34
rust/crates/libnfqws/CMakeLists.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(nfqws C)
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
file(GLOB NFQ_SOURCES "zapret/nfq/*.c")
|
||||
file(GLOB NFQ_CRYPTO_SOURCES "zapret/nfq/crypto/*.c")
|
||||
|
||||
add_library(nfqws SHARED
|
||||
${NFQ_SOURCES}
|
||||
${NFQ_CRYPTO_SOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(nfqws PRIVATE
|
||||
zapret/nfq
|
||||
zapret/nfq/crypto
|
||||
)
|
||||
|
||||
target_compile_definitions(nfqws PRIVATE main=nfqws_main)
|
||||
target_compile_options(nfqws PRIVATE -w)
|
||||
|
||||
find_library(LOG_LIB log)
|
||||
target_link_libraries(nfqws PRIVATE ${LOG_LIB})
|
||||
|
||||
target_link_libraries(nfqws PRIVATE
|
||||
z
|
||||
netfilter_queue
|
||||
nfnetlink
|
||||
mnl
|
||||
)
|
||||
|
||||
install(TARGETS nfqws
|
||||
LIBRARY DESTINATION lib
|
||||
)
|
||||
@@ -5,7 +5,6 @@ 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"
|
||||
cmake = "0.1.57"
|
||||
|
||||
@@ -1,264 +1,29 @@
|
||||
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, "zapret/nfq");
|
||||
rel_manifest_path!(NFQ_CRYPTO, "zapret/nfq/crypto");
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
const SYMBOLS: &[&str] = &[
|
||||
"DLOG",
|
||||
"net32_add",
|
||||
"net16_add",
|
||||
"tcp_find_option",
|
||||
"tcp_find_scale_factor",
|
||||
"tcp_find_mss",
|
||||
"proto_skip_ipv6",
|
||||
"proto_check_ipv4",
|
||||
"proto_check_ipv6",
|
||||
"extract_ports",
|
||||
"extract_endpoints",
|
||||
"proto_name",
|
||||
"family_from_proto",
|
||||
"str_ip",
|
||||
"print_ip",
|
||||
"str_srcdst_ip6",
|
||||
"str_ip6hdr",
|
||||
"print_ip6hdr",
|
||||
"str_tcphdr",
|
||||
"print_tcphdr",
|
||||
"l7proto_str",
|
||||
"l7_proto_match",
|
||||
"posmarker_name",
|
||||
"AnyProtoPos",
|
||||
"ResolvePos",
|
||||
"HttpPos",
|
||||
"TLSPos",
|
||||
"TLSFindExt",
|
||||
"TLSAdvanceToHostInSNI",
|
||||
"ResolveMultiPos",
|
||||
"IsHttp",
|
||||
"HttpFindHost",
|
||||
"IsHttpReply",
|
||||
"HttpReplyCode",
|
||||
"HttpExtractHeader",
|
||||
"HttpExtractHost",
|
||||
"HttpReplyLooksLikeDPIRedirect",
|
||||
"TLSVersionStr",
|
||||
"TLSRecordDataLen",
|
||||
"TLSRecordLen",
|
||||
"DLOG_CONDUP",
|
||||
"IsTLSRecordFull",
|
||||
"DLOG_ERR",
|
||||
"IsTLSClientHello",
|
||||
"DLOG_PERROR",
|
||||
"LOG_APPEND",
|
||||
"HOSTLIST_DEBUGLOG_APPEND",
|
||||
"hexdump_limited_dlog",
|
||||
"TLSHandshakeLen",
|
||||
"IsTLSHandshakeClientHello",
|
||||
"IsTLSHandshakeFull",
|
||||
"TLSFindExtLenOffsetInHandshake",
|
||||
"TLSFindExtLen",
|
||||
"TLSFindExtInHandshake",
|
||||
"TLSHelloExtractHost",
|
||||
"TLSHelloExtractHostFromHandshake",
|
||||
"IsQUICCryptoHello",
|
||||
"QUICDraftVersion",
|
||||
"str_udphdr",
|
||||
"QUICIsLongHeader",
|
||||
"dp_init",
|
||||
"dp_list_add",
|
||||
"dp_clear",
|
||||
"dp_entry_destroy",
|
||||
"dp_list_destroy",
|
||||
"dp_list_have_autohostlist",
|
||||
"cleanup_params",
|
||||
"progname",
|
||||
"tld",
|
||||
"QUICExtractVersion",
|
||||
"QUICExtractDCID",
|
||||
"QUICDecryptInitial",
|
||||
"print_udphdr",
|
||||
"QUICDefragCrypto",
|
||||
"IsQUICInitial",
|
||||
"IsWireguardHandshakeInitiation",
|
||||
"proto_skip_ipv4",
|
||||
"IsDiscordIpDiscoveryRequest",
|
||||
"IsStunMessage",
|
||||
"proto_check_tcp",
|
||||
"proto_skip_tcp",
|
||||
"proto_check_udp",
|
||||
"proto_skip_udp",
|
||||
"proto_dissect_l3l4",
|
||||
"tcp_synack_segment",
|
||||
"tcp_syn_segment",
|
||||
"rawsend_cleanup",
|
||||
"rawsend_preinit",
|
||||
"rawsend",
|
||||
"rawsend_rp",
|
||||
"rawsend_queue",
|
||||
"wlan_info_deinit",
|
||||
"wlan_info_init",
|
||||
"wlan_info_get_rate_limited",
|
||||
"wlans",
|
||||
"wlan_ifname2ssid",
|
||||
"wlan_ifidx2ssid",
|
||||
"wlan_ssid_search_ifname",
|
||||
"wlan_ssid_search_ifidx",
|
||||
"verdict_tcp_csum_fix",
|
||||
"dpi_desync_packet",
|
||||
"verdict_udp_csum_fix",
|
||||
"unique_size_t",
|
||||
"qsort_size_t",
|
||||
"dbgprint_socket_buffers",
|
||||
"fake_http_request_default",
|
||||
"rtrim",
|
||||
"replace_char",
|
||||
"fake_tls_clienthello_default",
|
||||
"params",
|
||||
"strncasestr",
|
||||
"load_file",
|
||||
"append_to_list_file",
|
||||
"expand_bits",
|
||||
"strip_host_to_ip",
|
||||
"ntop46",
|
||||
"ntop46_port",
|
||||
"print_sockaddr",
|
||||
"saport",
|
||||
"pntoh64",
|
||||
"set_socket_buffers",
|
||||
"phton64",
|
||||
"seq_within",
|
||||
"ipv6_addr_is_zero",
|
||||
"parse_hex_str",
|
||||
"fprint_localtime",
|
||||
"file_mod_time",
|
||||
"file_mod_signature",
|
||||
"file_open_test",
|
||||
"pf_in_range",
|
||||
"pf_parse",
|
||||
"pf_is_empty",
|
||||
"fill_random_bytes",
|
||||
"fill_random_az",
|
||||
"fill_random_az09",
|
||||
"set_console_io_buffering",
|
||||
"set_env_exedir",
|
||||
"str_cidr4",
|
||||
"print_cidr4",
|
||||
"str_cidr6",
|
||||
"print_cidr6",
|
||||
"parse_cidr4",
|
||||
"parse_cidr6",
|
||||
"config_from_file",
|
||||
"cleanup_args",
|
||||
"save_file",
|
||||
"HostlistPoolAddStrLen",
|
||||
"HostlistPoolAddStr",
|
||||
"HostlistPoolGetStr",
|
||||
"HostlistPoolCheckStr",
|
||||
"HostlistPoolDestroy",
|
||||
"HostFailPoolDestroy",
|
||||
"HostFailPoolAdd",
|
||||
"HostFailPoolFind",
|
||||
"HostFailPoolDel",
|
||||
"HostFailPoolPurge",
|
||||
"HostFailPoolPurgeRateLimited",
|
||||
"HostFailPoolDump",
|
||||
"strlist_add",
|
||||
"strlist_destroy",
|
||||
"strlist_search",
|
||||
"hostlist_files_add",
|
||||
"hostlist_files_destroy",
|
||||
"hostlist_files_search",
|
||||
"hostlist_files_reset_modtime",
|
||||
"hostlist_collection_add",
|
||||
"hostlist_collection_destroy",
|
||||
"hostlist_collection_search",
|
||||
"hostlist_collection_is_empty",
|
||||
"kavl_find_kavl_bit",
|
||||
"kavl_insert_kavl_bit",
|
||||
"kavl_erase_kavl_bit",
|
||||
"kavl_itr_first_kavl_bit",
|
||||
"kavl_itr_find_kavl_bit",
|
||||
"kavl_bit_delete",
|
||||
"kavl_bit_destroy",
|
||||
"kavl_bit_add",
|
||||
"kavl_bit_get",
|
||||
"ipset4Check",
|
||||
"ipset4Add",
|
||||
"ipset4Print",
|
||||
"ipset6Check",
|
||||
"ipset6Add",
|
||||
"ipset6Print",
|
||||
"ipsetDestroy",
|
||||
"ipsetPrint",
|
||||
"ipset_files_add",
|
||||
"ipset_files_destroy",
|
||||
"ipset_files_search",
|
||||
"ipset_files_reset_modtime",
|
||||
"ipset_collection_add",
|
||||
"ipset_collection_destroy",
|
||||
"ipset_collection_search",
|
||||
"ipset_collection_is_empty",
|
||||
"port_filter_add",
|
||||
"port_filters_destroy",
|
||||
"port_filters_deny_if_empty",
|
||||
"blob_collection_add",
|
||||
"blob_collection_add_blob",
|
||||
"blob_collection_destroy",
|
||||
"blob_collection_empty",
|
||||
"ipcacheDestroy",
|
||||
"ipcachePrint",
|
||||
"ipcacheTouch",
|
||||
"ipcachePurgeRateLimited",
|
||||
];
|
||||
let mut cc_builder = cc::Build::new();
|
||||
cc_builder.files(
|
||||
glob::glob(&format!("{}/*.c", NFQ.display()))
|
||||
.unwrap()
|
||||
.filter_map(Result::ok),
|
||||
);
|
||||
cc_builder.files(
|
||||
glob::glob(&format!("{}/*.c", NFQ_CRYPTO.display()))
|
||||
.unwrap()
|
||||
.filter_map(Result::ok),
|
||||
);
|
||||
cc_builder.include(&*NFQ);
|
||||
cc_builder.include(&*NFQ_CRYPTO);
|
||||
cc_builder.flag("-w");
|
||||
for &symbol in SYMBOLS {
|
||||
let val = format!("nfq_{}", symbol);
|
||||
cc_builder.define(symbol, Some(&val[..]));
|
||||
}
|
||||
cc_builder.define("main", "nfqws_main");
|
||||
cc_builder.compile("libnfqws.a");
|
||||
let dst = cmake::Config::new(env::var("CARGO_MANIFEST_DIR").unwrap()).build();
|
||||
|
||||
println!("cargo:rustc-link-search=native={}", dst.join("lib").display());
|
||||
|
||||
println!("cargo:rustc-link-lib=dylib=nfqws");
|
||||
|
||||
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"));
|
||||
if let Ok(libs) = env::var("NETFILTER_LIBS") {
|
||||
println!("cargo:rustc-link-search=native={libs}/lib");
|
||||
}
|
||||
|
||||
println!("cargo:rustc-link-lib=static=nfqws");
|
||||
println!("cargo:rerun-if-changed={}", NFQ.display());
|
||||
println!("cargo:rerun-if-changed={}", NFQ_CRYPTO.display());
|
||||
println!("cargo:rerun-if-changed=zapret/nfq");
|
||||
println!("cargo:rerun-if-changed=CMakeLists.txt");
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
||||
let mut builder = bindgen::Builder::default();
|
||||
|
||||
for header in glob::glob(&format!("{}/*.h", NFQ.display()))
|
||||
for header in glob::glob("zapret/nfq/*.h")
|
||||
.unwrap()
|
||||
.filter_map(Result::ok)
|
||||
{
|
||||
@@ -273,7 +38,8 @@ fn main() {
|
||||
.expect("Unable to generate libnfqws");
|
||||
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
|
||||
bindings
|
||||
.write_to_file(out_path.join("libnfqws.rs"))
|
||||
.expect("Couldn't write libnfqws");
|
||||
}
|
||||
}
|
||||
34
rust/crates/libnfqws2/CMakeLists.txt
Normal file
34
rust/crates/libnfqws2/CMakeLists.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(nfqws2 C)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
file(GLOB NFQ_SOURCES "zapret2/nfq2/*.c")
|
||||
file(GLOB NFQ_CRYPTO_SOURCES "zapret2/nfq2/crypto/*.c")
|
||||
|
||||
add_library(nfqws2 SHARED ${NFQ_SOURCES} ${NFQ_CRYPTO_SOURCES})
|
||||
|
||||
target_include_directories(nfqws2 PRIVATE
|
||||
"zapret2/nfq2"
|
||||
"zapret2/nfq2/crypto"
|
||||
$ENV{NETFILTER_LIBS}/include
|
||||
$ENV{LUAJIT_LIBS}/include/luajit-2.1
|
||||
)
|
||||
|
||||
target_compile_definitions(nfqws2 PRIVATE main=nfqws2_main)
|
||||
target_compile_options(nfqws2 PRIVATE -w)
|
||||
|
||||
find_library(LOG_LIB log)
|
||||
target_link_libraries(nfqws2 PRIVATE ${LOG_LIB})
|
||||
|
||||
target_link_libraries(nfqws2 PRIVATE
|
||||
z
|
||||
netfilter_queue
|
||||
nfnetlink
|
||||
mnl
|
||||
unwind
|
||||
$ENV{LUAJIT_LIBS}/lib/libluajit-5.1.a
|
||||
)
|
||||
|
||||
install(TARGETS nfqws2
|
||||
LIBRARY DESTINATION lib
|
||||
)
|
||||
@@ -5,7 +5,6 @@ edition.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.2.43"
|
||||
once_cell = "1.21.3"
|
||||
cmake = "0.1.57"
|
||||
glob = "0.3.3"
|
||||
bindgen = "0.72.1"
|
||||
|
||||
@@ -1,297 +1,38 @@
|
||||
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");
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
const SYMBOLS: &[&str] = &[
|
||||
"DLOG",
|
||||
"net32_add",
|
||||
"net16_add",
|
||||
"tcp_find_option",
|
||||
"tcp_find_scale_factor",
|
||||
"tcp_find_mss",
|
||||
"proto_skip_ipv6",
|
||||
"proto_check_ipv4",
|
||||
"proto_check_ipv6",
|
||||
"extract_ports",
|
||||
"extract_endpoints",
|
||||
"proto_name",
|
||||
"family_from_proto",
|
||||
"str_ip",
|
||||
"print_ip",
|
||||
"str_srcdst_ip6",
|
||||
"str_ip6hdr",
|
||||
"print_ip6hdr",
|
||||
"str_tcphdr",
|
||||
"print_tcphdr",
|
||||
"l7proto_str",
|
||||
"l7_proto_match",
|
||||
"posmarker_name",
|
||||
"AnyProtoPos",
|
||||
"ResolvePos",
|
||||
"HttpPos",
|
||||
"TLSPos",
|
||||
"TLSFindExt",
|
||||
"TLSAdvanceToHostInSNI",
|
||||
"ResolveMultiPos",
|
||||
"IsHttp",
|
||||
"HttpFindHost",
|
||||
"IsHttpReply",
|
||||
"HttpReplyCode",
|
||||
"HttpExtractHeader",
|
||||
"HttpExtractHost",
|
||||
"HttpReplyLooksLikeDPIRedirect",
|
||||
"TLSVersionStr",
|
||||
"TLSRecordDataLen",
|
||||
"TLSRecordLen",
|
||||
"DLOG_CONDUP",
|
||||
"IsTLSRecordFull",
|
||||
"DLOG_ERR",
|
||||
"IsTLSClientHello",
|
||||
"DLOG_PERROR",
|
||||
"LOG_APPEND",
|
||||
"HOSTLIST_DEBUGLOG_APPEND",
|
||||
"hexdump_limited_dlog",
|
||||
"TLSHandshakeLen",
|
||||
"IsTLSHandshakeClientHello",
|
||||
"IsTLSHandshakeFull",
|
||||
"TLSFindExtLenOffsetInHandshake",
|
||||
"TLSFindExtLen",
|
||||
"TLSFindExtInHandshake",
|
||||
"TLSHelloExtractHost",
|
||||
"TLSHelloExtractHostFromHandshake",
|
||||
"IsQUICCryptoHello",
|
||||
"QUICDraftVersion",
|
||||
"str_udphdr",
|
||||
"QUICIsLongHeader",
|
||||
"dp_init",
|
||||
"dp_list_add",
|
||||
"dp_clear",
|
||||
"dp_entry_destroy",
|
||||
"dp_list_destroy",
|
||||
"dp_list_have_autohostlist",
|
||||
"cleanup_params",
|
||||
"progname",
|
||||
"tld",
|
||||
"QUICExtractVersion",
|
||||
"QUICExtractDCID",
|
||||
"QUICDecryptInitial",
|
||||
"print_udphdr",
|
||||
"QUICDefragCrypto",
|
||||
"IsQUICInitial",
|
||||
"IsWireguardHandshakeInitiation",
|
||||
"proto_skip_ipv4",
|
||||
"IsDiscordIpDiscoveryRequest",
|
||||
"IsStunMessage",
|
||||
"proto_check_tcp",
|
||||
"proto_skip_tcp",
|
||||
"proto_check_udp",
|
||||
"proto_skip_udp",
|
||||
"proto_dissect_l3l4",
|
||||
"tcp_synack_segment",
|
||||
"tcp_syn_segment",
|
||||
"rawsend_cleanup",
|
||||
"rawsend_preinit",
|
||||
"rawsend",
|
||||
"rawsend_rp",
|
||||
"rawsend_queue",
|
||||
"wlan_info_deinit",
|
||||
"wlan_info_init",
|
||||
"wlan_info_get_rate_limited",
|
||||
"wlans",
|
||||
"wlan_ifname2ssid",
|
||||
"wlan_ifidx2ssid",
|
||||
"wlan_ssid_search_ifname",
|
||||
"wlan_ssid_search_ifidx",
|
||||
"verdict_tcp_csum_fix",
|
||||
"dpi_desync_packet",
|
||||
"verdict_udp_csum_fix",
|
||||
"unique_size_t",
|
||||
"qsort_size_t",
|
||||
"dbgprint_socket_buffers",
|
||||
"fake_http_request_default",
|
||||
"rtrim",
|
||||
"replace_char",
|
||||
"fake_tls_clienthello_default",
|
||||
"params",
|
||||
"strncasestr",
|
||||
"load_file",
|
||||
"append_to_list_file",
|
||||
"expand_bits",
|
||||
"strip_host_to_ip",
|
||||
"ntop46",
|
||||
"ntop46_port",
|
||||
"print_sockaddr",
|
||||
"saport",
|
||||
"pntoh64",
|
||||
"set_socket_buffers",
|
||||
"phton64",
|
||||
"seq_within",
|
||||
"ipv6_addr_is_zero",
|
||||
"parse_hex_str",
|
||||
"fprint_localtime",
|
||||
"file_mod_time",
|
||||
"file_mod_signature",
|
||||
"file_open_test",
|
||||
"pf_in_range",
|
||||
"pf_parse",
|
||||
"pf_is_empty",
|
||||
"fill_random_bytes",
|
||||
"fill_random_az",
|
||||
"fill_random_az09",
|
||||
"set_console_io_buffering",
|
||||
"set_env_exedir",
|
||||
"str_cidr4",
|
||||
"print_cidr4",
|
||||
"str_cidr6",
|
||||
"print_cidr6",
|
||||
"parse_cidr4",
|
||||
"parse_cidr6",
|
||||
"config_from_file",
|
||||
"cleanup_args",
|
||||
"save_file",
|
||||
"HostlistPoolAddStrLen",
|
||||
"HostlistPoolAddStr",
|
||||
"HostlistPoolGetStr",
|
||||
"HostlistPoolCheckStr",
|
||||
"HostlistPoolDestroy",
|
||||
"HostFailPoolDestroy",
|
||||
"HostFailPoolAdd",
|
||||
"HostFailPoolFind",
|
||||
"HostFailPoolDel",
|
||||
"HostFailPoolPurge",
|
||||
"HostFailPoolPurgeRateLimited",
|
||||
"HostFailPoolDump",
|
||||
"strlist_add",
|
||||
"strlist_destroy",
|
||||
"strlist_search",
|
||||
"hostlist_files_add",
|
||||
"hostlist_files_destroy",
|
||||
"hostlist_files_search",
|
||||
"hostlist_files_reset_modtime",
|
||||
"hostlist_collection_add",
|
||||
"hostlist_collection_destroy",
|
||||
"hostlist_collection_search",
|
||||
"hostlist_collection_is_empty",
|
||||
"kavl_find_kavl_bit",
|
||||
"kavl_insert_kavl_bit",
|
||||
"kavl_erase_kavl_bit",
|
||||
"kavl_itr_first_kavl_bit",
|
||||
"kavl_itr_find_kavl_bit",
|
||||
"kavl_bit_delete",
|
||||
"kavl_bit_destroy",
|
||||
"kavl_bit_add",
|
||||
"kavl_bit_get",
|
||||
"ipset4Check",
|
||||
"ipset4Add",
|
||||
"ipset4Print",
|
||||
"ipset6Check",
|
||||
"ipset6Add",
|
||||
"ipset6Print",
|
||||
"ipsetDestroy",
|
||||
"ipsetPrint",
|
||||
"ipset_files_add",
|
||||
"ipset_files_destroy",
|
||||
"ipset_files_search",
|
||||
"ipset_files_reset_modtime",
|
||||
"ipset_collection_add",
|
||||
"ipset_collection_destroy",
|
||||
"ipset_collection_search",
|
||||
"ipset_collection_is_empty",
|
||||
"port_filter_add",
|
||||
"port_filters_destroy",
|
||||
"port_filters_deny_if_empty",
|
||||
"blob_collection_add",
|
||||
"blob_collection_add_blob",
|
||||
"blob_collection_destroy",
|
||||
"blob_collection_empty",
|
||||
"ipcacheDestroy",
|
||||
"ipcachePrint",
|
||||
"ipcacheTouch",
|
||||
"ipcachePurgeRateLimited",
|
||||
];
|
||||
let mut cc_builder = cc::Build::new();
|
||||
cc_builder.files(
|
||||
glob::glob(&format!("{}/*.c", NFQ.display()))
|
||||
.unwrap()
|
||||
.filter_map(Result::ok),
|
||||
);
|
||||
cc_builder.files(
|
||||
glob::glob(&format!("{}/*.c", NFQ_CRYPTO.display()))
|
||||
.unwrap()
|
||||
.filter_map(Result::ok),
|
||||
);
|
||||
cc_builder.include(&*NFQ);
|
||||
cc_builder.include(&*NFQ_CRYPTO);
|
||||
cc_builder.flag("-w");
|
||||
for &symbol in SYMBOLS {
|
||||
let val = format!("nfq2_{}", symbol);
|
||||
cc_builder.define(symbol, Some(&val[..]));
|
||||
}
|
||||
cc_builder.define("main", "nfqws2_main");
|
||||
cc_builder.compile("libnfqws2.a");
|
||||
|
||||
let compiler = cc_builder.get_compiler();
|
||||
let output = compiler.to_command()
|
||||
.arg("-print-libgcc-file-name")
|
||||
.output()
|
||||
.expect("Failed to query compiler for libgcc path");
|
||||
|
||||
let path_str = String::from_utf8(output.stdout).unwrap();
|
||||
let lib_path = Path::new(path_str.trim());
|
||||
|
||||
if lib_path.exists() {
|
||||
if let Some(parent) = lib_path.parent() {
|
||||
println!("cargo:rustc-link-search=native={}", parent.display());
|
||||
}
|
||||
|
||||
if let Some(stem) = lib_path.file_stem() {
|
||||
let lib_name = stem.to_string_lossy();
|
||||
let lib_name = lib_name.strip_prefix("lib").unwrap_or(&lib_name);
|
||||
println!("cargo:rustc-link-lib=static={}", lib_name);
|
||||
}
|
||||
} else {
|
||||
println!("cargo:warning=Could not find compiler builtins library at {:?}", lib_path);
|
||||
println!("cargo:rustc-link-lib=gcc");
|
||||
}
|
||||
|
||||
let dst = cmake::Config::new(env::var("CARGO_MANIFEST_DIR").unwrap()).build();
|
||||
println!("cargo:rustc-link-search=native={}", dst.join("lib").display());
|
||||
println!("cargo:rustc-link-lib=dylib=nfqws2");
|
||||
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");
|
||||
println!("cargo:rustc-link-lib=static=luajit");
|
||||
println!("cargo:rustc-link-lib=unwind"); // for shitass luajit
|
||||
println!("cargo:rustc-link-lib=static=luajit-5.1");
|
||||
println!("cargo:rustc-link-lib=unwind");
|
||||
|
||||
let _ = env::var("NETFILTER_LIBS")
|
||||
.map(|libs| println!("cargo:rustc-link-search=native={libs}/lib"));
|
||||
let _ = env::var("LUAJIT_LIBS")
|
||||
.map(|libs| println!("cargo:rustc-link-search=native={libs}/lib"));
|
||||
if let Ok(libs) = env::var("NETFILTER_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());
|
||||
if let Ok(libs) = env::var("LUAJIT_LIBS") {
|
||||
println!("cargo:rustc-link-search=native={libs}/lib");
|
||||
}
|
||||
|
||||
println!("cargo:rerun-if-changed=CMakeLists.txt");
|
||||
println!("cargo:rerun-if-changed=zapret2/nfq2");
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
|
||||
let mut builder = bindgen::Builder::default();
|
||||
|
||||
for header in glob::glob(&format!("{}/*.h", NFQ.display()))
|
||||
for header in glob::glob("zapret2/nfq2/*.h")
|
||||
.unwrap()
|
||||
.filter_map(Result::ok)
|
||||
{
|
||||
builder = builder.header(header.to_string_lossy());
|
||||
}
|
||||
|
||||
builder = builder.clang_arg("-Dmain=nfqws2_main");
|
||||
|
||||
if let Ok(luajit) = env::var("LUAJIT") {
|
||||
@@ -305,7 +46,8 @@ fn main() {
|
||||
.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");
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ _build_netfilter_libs target_arch:
|
||||
(
|
||||
cd $i-*
|
||||
make clean
|
||||
CFLAGS="-Os -flto=auto -Wno-implicit-function-declaration" \
|
||||
CFLAGS="-Os -flto=auto -Wno-implicit-function-declaration -fPIC" \
|
||||
./configure --prefix= --host={{target_arch}} --enable-static --disable-shared --disable-dependency-tracking
|
||||
make -j$(nproc)
|
||||
make install DESTDIR=$NETFILTER_LIBS-{{target_arch}}
|
||||
@@ -99,15 +99,12 @@ _build_luajit target_arch:
|
||||
|
||||
(
|
||||
cd luajit2-*
|
||||
make clean
|
||||
make BUILDMODE=static XCFLAGS=-DLUAJIT_DISABLE_FFI \
|
||||
HOST_CC="$HOSTCC" CROSS= CC="$CC" \
|
||||
TARGET_AR="$AR rcus" TARGET_STRIP=$STRIP \
|
||||
CFLAGS="-Os -flto=auto" -j$(nproc)
|
||||
|
||||
make clean
|
||||
make BUILDMODE=static XCFLAGS="-DLUAJIT_DISABLE_FFI -fPIC" \
|
||||
HOST_CC="$HOSTCC" CROSS= CC="$CC" \
|
||||
TARGET_AR="$AR rcus" TARGET_STRIP=$STRIP \
|
||||
CFLAGS="-Os -fPIC" -j$(nproc)
|
||||
make install PREFIX= DESTDIR="{{LUAJIT_LIBS}}-{{target_arch}}"
|
||||
mv "{{LUAJIT_LIBS}}-{{target_arch}}/lib/libluajit-5.1.a" \
|
||||
"{{LUAJIT_LIBS}}-{{target_arch}}/lib/libluajit.a"
|
||||
)
|
||||
else
|
||||
echo "LuaJIT for {{target_arch}} already built"
|
||||
@@ -161,7 +158,6 @@ build-android *args: prepare-android
|
||||
export LJIT=1
|
||||
export LCFLAGS="-I$LUAJIT_LIBS-$t/include/luajit-2.1"
|
||||
export LLIB="-L$LUAJIT_LIBS-$t/lib -lluajit-2.1"
|
||||
|
||||
just _build_netfilter_libs $t
|
||||
just _build_luajit $t
|
||||
just _install_rust_target $t
|
||||
|
||||
@@ -22,20 +22,36 @@ arch=$(uname -m)
|
||||
case "$arch" in
|
||||
"x86_64")
|
||||
zaprett_bin="zaprett-x86_64"
|
||||
l_base="lib64"
|
||||
l_sub="x86_64"
|
||||
;;
|
||||
"armv7l"|"arm" | "armv8l")
|
||||
"armv7l"|"arm"|"armv8l")
|
||||
zaprett_bin="zaprett-armv7"
|
||||
l_base="lib"
|
||||
l_sub="armeabi-v7a"
|
||||
;;
|
||||
"aarch64")
|
||||
zaprett_bin="zaprett-aarch64"
|
||||
l_base="lib64"
|
||||
l_sub="arm64-v8a"
|
||||
;;
|
||||
*)
|
||||
ui_print "Unknown arch: $arch"
|
||||
abort
|
||||
;;
|
||||
esac
|
||||
mv $MODPATH/system/bin/$zaprett_bin $MODPATH/system/bin/zaprett
|
||||
rm $MODPATH/system/bin/zaprett-*
|
||||
|
||||
mv "$MODPATH/system/bin/$zaprett_bin" "$MODPATH/system/bin/zaprett"
|
||||
rm -f "$MODPATH/system/bin/zaprett-"*
|
||||
|
||||
if [ -d "$MODPATH/system/lib/$l_sub" ]; then
|
||||
mkdir -p "$MODPATH/system/lib_tmp"
|
||||
mv "$MODPATH/system/lib/$l_sub/"* "$MODPATH/system/lib_tmp/"
|
||||
rm -rf "$MODPATH/system/lib"
|
||||
mkdir -p "$MODPATH/system/$l_base"
|
||||
mv "$MODPATH/system/lib_tmp/"* "$MODPATH/system/$l_base/"
|
||||
rm -rf "$MODPATH/system/lib_tmp"
|
||||
fi
|
||||
mkdir $MODPATH/tmp
|
||||
|
||||
ui_print "Cleaning temp files..."
|
||||
|
||||
Reference in New Issue
Block a user