92 Commits

Author SHA1 Message Date
egor-white
cf98c42995 Update workflow.yml 2025-11-03 22:30:52 +03:00
CherretGit
942578b5c5 optimize release binary 2025-11-03 23:47:45 +07:00
egor-white
6215a36eb6 Update customize.sh 2025-11-03 18:00:42 +03:00
CherretGit
5e64628d7f Update workflow.yml 2025-11-03 21:43:02 +07:00
CherretGit
8b0945352a Update workflow_without_post.yml 2025-11-03 21:41:47 +07:00
CherretGit
ca65e0c6f1 remove iptables crate, fix service_status 2025-11-03 21:16:14 +07:00
egor-white
234e9e5824 Merge pull request #7 from sqlerrorthing/refactor/rust/autostart
refactor: autostart
2025-11-03 16:28:23 +03:00
egor-white
aedf249712 Merge branch 'main' into refactor/rust/autostart 2025-11-03 16:28:13 +03:00
egor-white
526bf7ded2 Merge pull request #6 from sqlerrorthing/fix/right-library
fix: right library functions
2025-11-03 16:26:06 +03:00
sqlerrorthing
2c8721e42b right library api 2025-11-03 05:42:28 +08:00
sqlerrorthing
d59340a5c9 refactor autostart 2025-11-03 05:35:33 +08:00
egor-white
fc5cc814d6 edit workflow name 2025-11-03 00:31:35 +03:00
egor-white
924b6d20e8 fix workflow 2025-11-03 00:30:20 +03:00
egor-white
dedab3386a Update workflow_without_post.yml 2025-11-03 00:28:58 +03:00
egor-white
44deef4aef Merge pull request #5 from sqlerrorthing/fix/rust
fix: rust codebase
2025-11-03 00:27:08 +03:00
sqlerrorthing
eaf0e6c756 unnecessary dereference 2025-11-03 05:15:53 +08:00
sqlerrorthing
d1e56df7fc move module 2025-11-03 05:15:40 +08:00
sqlerrorthing
574bbbd8cc dereference in wrong place 2025-11-03 05:13:58 +08:00
sqlerrorthing
b5e37044e2 right use format macro 2025-11-03 05:13:34 +08:00
sqlerrorthing
aa1788386a fix shitcode 2025-11-03 05:10:52 +08:00
sqlerrorthing
8a1d336e4b good struct 2025-11-03 05:04:05 +08:00
sqlerrorthing
16ba9bedfc unnecessary .unwrap 2025-11-03 05:02:51 +08:00
white
6343e67cd9 change iptables lib to selfowned repo 2025-11-03 00:00:43 +03:00
white
2d9463e507 add service stop message 2025-11-02 23:54:51 +03:00
CherretGit
91d08d3df4 fix 2025-11-03 02:32:47 +07:00
egor-white
3e4f7bad3a Update customize.sh 2025-11-02 22:10:46 +03:00
egor-white
2c1594b13c Update workflow.yml 2025-11-02 22:05:30 +03:00
egor-white
ab7c49864c Update workflow.yml 2025-11-02 22:03:03 +03:00
egor-white
9dfb0b6d67 Update workflow_without_post.yml 2025-11-02 22:02:32 +03:00
CherretGit
46bff39782 fix stop service 2025-11-03 01:23:19 +07:00
CherretGit
0c932ff69c fix nfqws, add default json values 2025-11-03 01:03:47 +07:00
CherretGit
689488ba3f fix working dir 2025-11-01 23:01:44 +07:00
CherretGit
d63cb7c6e6 add saving logs from nfqws to files 2025-11-01 22:08:35 +07:00
CherretGit
90c7a55ab2 try to fix nfqws 2025-11-01 21:45:00 +07:00
CherretGit
dd80ffcd5f add --uid and --qnum to nfqws args 2025-11-01 21:08:10 +07:00
CherretGit
a581e02ccd Update workflow_without_post.yml 2025-11-01 20:20:01 +07:00
CherretGit
2e7b943712 fix customize.sh 2025-11-01 20:16:02 +07:00
CherretGit
4f6a80a8ee fix service status 2025-11-01 19:56:08 +07:00
CherretGit
8caa7ff696 fix 2025-11-01 18:51:57 +07:00
CherretGit
ef58166767 Update workflow_without_post.yml 2025-11-01 18:37:05 +07:00
CherretGit
89ecb5e7fe Update workflow_without_post.yml 2025-11-01 18:32:32 +07:00
CherretGit
26cb5ca046 Update update's.json and changelog 2025-11-01 10:57:14 +00:00
CherretGit
4370ff8867 Update workflow_without_post.yml 2025-11-01 17:51:14 +07:00
CherretGit
eafb226036 Delete src/system/bin directory 2025-11-01 17:40:45 +07:00
CherretGit
0316a4b004 Update file copy commands in workflow YAML 2025-11-01 17:39:43 +07:00
CherretGit
3d78a3d0a4 Update workflow_without_post.yml 2025-11-01 16:57:01 +07:00
CherretGit
d11eb93be6 change sh to bash 2025-11-01 16:43:40 +07:00
CherretGit
490c8fa685 Update workflow_without_post.yml 2025-11-01 16:27:08 +07:00
CherretGit
1128168924 create temp dir to save ndk 2025-11-01 16:25:00 +07:00
CherretGit
1b7448afa3 Test 2025-11-01 16:15:14 +07:00
CherretGit
636cd47ffa use println instead info 2025-11-01 15:51:11 +07:00
sqlerrorthing
ceb27e1ee8 refaktor 2025-11-01 13:00:19 +08:00
sqlerrorthing
fc431f8e88 refactor 2025-11-01 10:57:28 +08:00
sqlerrorthing
8a3df7b253 ... 2025-11-01 07:31:35 +08:00
sqlerrorthing
bb1fe1bc32 refactor 2025-11-01 07:27:14 +08:00
sqlerrorthing
f5cee6df60 build all 3 android targets 2025-11-01 07:27:04 +08:00
sqlerrorthing
930eaf48d2 remove useless 2025-11-01 03:39:48 +08:00
sqlerrorthing
515c946f13 fixess 2025-11-01 03:39:22 +08:00
sqlerrorthing
bf76e162ee fixes 2025-11-01 03:05:55 +08:00
sqlerrorthing
2790c8ed62 feat: build anrdoid (#1) 2025-11-01 02:55:42 +08:00
sqlerrorthing
2e9e08fb96 Merge branch 'rust' into feat/build-anrdoid 2025-11-01 02:54:44 +08:00
white
8542d33af2 create patch for workflow 2025-10-31 13:01:12 +03:00
white
1d9a8a641f removing procfs, adding iptables crate as submodule 2025-10-31 12:45:41 +03:00
sqlerrorthing
17d5e7a8f0 working 2025-10-31 17:38:31 +08:00
sqlerrorthing
aecde98d0d first working 2025-10-31 17:04:32 +08:00
sqlerrorthing
d5267997a3 code stolen from zapret 2025-10-31 16:13:01 +08:00
sqlerrorthing
57382991ad wtf 2025-10-31 15:25:14 +08:00
sqlerrorthing
12ceb7a7d1 build required libraries 2025-10-31 14:41:13 +08:00
sqlerrorthing
f37c14ef0a install android ndk 2025-10-31 12:47:47 +08:00
CherretGit
bfdd7a0a76 fix service status 2025-10-31 02:38:47 +07:00
CherretGit
47f314cd19 Add zapret binary version 2025-10-30 22:47:05 +07:00
white
10fdf4c227 remove bin-ver, add root checks on start and stop 2025-10-30 17:20:54 +03:00
CherretGit
784a248c11 stop_service command, fix 2025-10-30 18:41:47 +07:00
CherretGit
192d846a12 await 2025-10-30 04:09:37 +07:00
CherretGit
87a6b72aee move paths to constants (again) 2025-10-30 03:32:52 +07:00
sqlerrorthing
7ea4a516be daemonize 2025-10-29 23:12:53 +03:00
CherretGit
4b9e60336b Revert "move paths to constants"
This reverts commit 51af644b5f.
2025-10-30 03:08:03 +07:00
CherretGit
51af644b5f move paths to constants 2025-10-30 02:57:22 +07:00
egor-white
5f6663a067 Update README.md 2025-10-27 18:46:46 +03:00
egor-white
0e51fb14fd Update README.md 2025-10-27 17:56:10 +03:00
egor-white
31c2c08cf0 Update README.md 2025-10-27 17:54:43 +03:00
egor-white
bb389dff34 Update README.md 2025-10-27 16:47:25 +03:00
egor-white
3882924d60 Update README.md 2025-10-21 14:13:49 +03:00
egor-white
2f47b3c63d Update README.md 2025-10-21 14:13:31 +03:00
egor-white
2e4c484ffb Update README.md 2025-10-21 14:12:44 +03:00
CherretGit
55fd437762 Update changelog.md 2025-10-20 10:28:03 +07:00
CherretGit
d6bc7f17d7 Rename update_tv.json to update-tv.json 2025-10-20 10:26:27 +07:00
CherretGit
5136f3901b Rename update_hosts.json to update-hosts.json 2025-10-20 10:25:33 +07:00
CherretGit
ec072d4ae8 Update workflow.yml 2025-10-20 10:24:55 +07:00
CherretGit
e7b2075d1e Update update's.json and changelog 2025-10-20 03:18:25 +00:00
CherretGit
c7271b2825 update hosts 2025-10-19 14:47:19 +07:00
CherretGit
71e918bd13 Revert "Update service.sh"
This reverts commit 3a7c40f167.
2025-10-19 14:46:19 +07:00
28 changed files with 1219 additions and 1019 deletions

View File

@@ -3,10 +3,18 @@ name: Build module
on:
workflow_dispatch:
inputs:
create_release:
description: 'Create GitHub release?'
required: false
default: 'false'
tag:
description: "Tag for the release (x.x.x)"
required: true
type: string
zapret-version:
description: "Zapret version (x.x)"
required: true
type: string
version:
description: "Module version (x.x)"
required: true
@@ -27,45 +35,32 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
ZAPRET_VERSION: ${{ inputs.zapret-version }}
steps:
- uses: actions/checkout@v4
- name: Setup Git submodules
run: git submodule update --init --recursive
- name: Install dependencies
run: sudo apt install build-essential pkg-config just unzip
- name: Build zaprett
run: just -f rust/justfile build-android --release
- name: Make build dirs
run: mkdir -p zaprett/system/bin zaprett-hosts/system/bin zaprett-tv/system/bin zaprett/system/etc/zaprett/lists zapret-latest out lists zapret-hosts/system/etc/zaprett/lists zapret-tv/system/etc/zaprett/lists
- name: Download latest zapret binaries
run: |
LATEST_RELEASE=$(curl -s https://api.github.com/repos/bol-van/zapret/releases/latest)
DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | grep -o 'browser_download_url.*zapret-v.*\.zip"' | cut -d'"' -f3)
wget $DOWNLOAD_URL -O zapret-latest.zip
- name: Unzip zapret binaries
run: |
unzip -o zapret-latest.zip
ZAPRET_DIR=$(find . -maxdepth 1 -type d -name 'zapret-v*' | head -n 1)
if [ "$(ls -A "$ZAPRET_DIR")" ]; then
mv "$ZAPRET_DIR"/* zapret-latest/
else
echo "Warning: $ZAPRET_DIR is empty"
fi
rm -rf "${ZAPRET_DIR}"
rm zapret-latest.zip
run: mkdir -p zaprett/system/bin zaprett-hosts/system/bin zaprett/system/etc/zaprett/lists out lists zapret-hosts/system/etc/zaprett/lists
- name: Copy files to dirs
run: |
#copy nfqws and zaprett
cp zapret-latest/binaries/android-arm/nfqws zaprett/system/bin/nfqws_arm32
cp zapret-latest/binaries/android-arm64/nfqws zaprett/system/bin/nfqws_arm64
cp zapret-latest/binaries/android-x86/nfqws zaprett/system/bin/nfqws_x86
cp zapret-latest/binaries/android-x86_64/nfqws zaprett/system/bin/nfqws_x86_64
cp zapret-latest/binaries/linux-mips/nfqws zaprett/system/bin/nfqws_mips
cp zapret-latest/binaries/linux-mipsel/nfqws zaprett/system/bin/nfqws_mipsel
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
cp -a src-module/* zaprett/
#copy all files to another distributions
cp -a src/* zaprett/
cp -r zaprett/* zaprett-hosts/
cp -r zaprett/* zaprett-tv/
- name: Download and copy actual lists
run: |
wget https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/lists/include/list-youtube.txt -O lists/list-youtube.txt
@@ -73,7 +68,6 @@ jobs:
cp lists/list-youtube.txt zaprett/system/etc/zaprett/lists/
cp lists/list-youtube.txt zaprett-hosts/system/etc/zaprett/lists/
cp lists/list-youtube.txt zaprett-tv/system/etc/zaprett/lists/
cp lists/list-discord.txt zaprett/system/etc/zaprett/lists/
cp lists/list-discord.txt zaprett-hosts/system/etc/zaprett/lists/
@@ -102,30 +96,16 @@ jobs:
updateJson=https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/update-hosts.json
EOF
cat > zaprett-tv/module.prop <<EOF
id=zaprett
name=zaprett-tv
version=${{ inputs.version }}
versionCode=${{ inputs.version_code }}
author=egor-white, Cherret
description=Ускорение CDN серверов Google. ТГК: https://t.me/zaprett_module
updateJson=https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/update-tv.json
EOF
- name: Tree files
run: |
tree zaprett/ zaprett-hosts/ zaprett-tv/
- name: Create archives
run: |
cd zaprett && zip -r ../zaprett.zip ./* && cd ..
cd zaprett-hosts && zip -r ../zaprett-hosts.zip ./* && cd ..
cd zaprett-tv && zip -r ../zaprett-tv.zip ./* && cd ..
mv zaprett.zip out/
mv zaprett-hosts.zip out/
mv zaprett-tv.zip out/
- name: Create release
if: ${{ inputs.create_release == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag }}
@@ -134,10 +114,20 @@ jobs:
files: out/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
if: ${{ inputs.create_release != 'true' }}
uses: actions/upload-artifact@v5.0.0
with:
name: zaprett
path: out/*
- name: Update changelog
run: echo "${{ inputs.release_changes}}" > changelog.md
if: ${{ inputs.create_release == 'true' }}
run: echo "${{ inputs.release_changes }}" > changelog.md
- name: Update update.json
if: ${{ inputs.create_release == 'true' }}
run: |
cat > update.json <<EOF
{
@@ -147,7 +137,7 @@ jobs:
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
}
EOF
cat > update_hosts.json <<EOF
cat > update-hosts.json <<EOF
{
"version": "${{ inputs.version }}",
"versionCode": ${{ inputs.version_code }},
@@ -155,20 +145,12 @@ jobs:
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
}
EOF
cat > update_tv.json <<EOF
{
"version": "${{ inputs.version }}",
"versionCode": ${{ inputs.version_code }},
"zipUrl": "https://github.com/${{ github.repository }}/releases/download/${{ inputs.tag }}/zaprett-tv.zip",
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
}
EOF
- name: Commit jsons and changelog
if: ${{ inputs.create_release == 'true' }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update update's.json and changelog"
file_pattern: "update.json update_hosts.json update_tv.json changelog.md"
file_pattern: "update.json update-hosts.json changelog.md"
- name: Send bot post
env:
MESSAGE_TEXT: |

View File

@@ -1,12 +1,20 @@
name: Build module (Without telegram post)
name: Build module (without post)
on:
workflow_dispatch:
inputs:
create_release:
description: 'Create GitHub release?'
required: false
default: 'false'
tag:
description: "Tag for the release (x.x.x)"
required: true
type: string
zapret-version:
description: "Zapret version (x.x)"
required: true
type: string
version:
description: "Module version (x.x)"
required: true
@@ -27,45 +35,33 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
ZAPRET_VERSION: ${{ inputs.zapret-version }}
steps:
- uses: actions/checkout@v4
- name: Setup Git submodules
run: git submodule update --init --recursive
- name: Install dependencies
run: sudo apt install build-essential pkg-config just unzip
- name: Build zaprett
run: just -f rust/justfile build-android --release
- name: Make build dirs
run: mkdir -p zaprett/system/bin zaprett-hosts/system/bin zaprett-tv/system/bin zaprett/system/etc/zaprett/lists zapret-latest out lists zapret-hosts/system/etc/zaprett/lists zapret-tv/system/etc/zaprett/lists
- name: Download latest zapret binaries
run: |
LATEST_RELEASE=$(curl -s https://api.github.com/repos/bol-van/zapret/releases/latest)
DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | grep -o 'browser_download_url.*zapret-v.*\.zip"' | cut -d'"' -f3)
wget $DOWNLOAD_URL -O zapret-latest.zip
- name: Unzip zapret binaries
run: |
unzip -o zapret-latest.zip
ZAPRET_DIR=$(find . -maxdepth 1 -type d -name 'zapret-v*' | head -n 1)
if [ "$(ls -A "$ZAPRET_DIR")" ]; then
mv "$ZAPRET_DIR"/* zapret-latest/
else
echo "Warning: $ZAPRET_DIR is empty"
fi
rm -rf "${ZAPRET_DIR}"
rm zapret-latest.zip
run: mkdir -p zaprett/system/bin zaprett-hosts/system/bin zaprett/system/etc/zaprett/lists out lists zapret-hosts/system/etc/zaprett/lists
- name: Copy files to dirs
run: |
#copy nfqws and zaprett
cp zapret-latest/binaries/android-arm/nfqws zaprett/system/bin/nfqws_arm32
cp zapret-latest/binaries/android-arm64/nfqws zaprett/system/bin/nfqws_arm64
cp zapret-latest/binaries/android-x86/nfqws zaprett/system/bin/nfqws_x86
cp zapret-latest/binaries/android-x86_64/nfqws zaprett/system/bin/nfqws_x86_64
cp zapret-latest/binaries/linux-mips/nfqws zaprett/system/bin/nfqws_mips
cp zapret-latest/binaries/linux-mipsel/nfqws zaprett/system/bin/nfqws_mipsel
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
cp -a src-module/* zaprett/
#copy all files to another distributions
cp -a src/* zaprett/
cp -r zaprett/* zaprett-hosts/
cp -r zaprett/* zaprett-tv/
- name: Download and copy actual lists
run: |
wget https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/lists/include/list-youtube.txt -O lists/list-youtube.txt
@@ -73,7 +69,6 @@ jobs:
cp lists/list-youtube.txt zaprett/system/etc/zaprett/lists/
cp lists/list-youtube.txt zaprett-hosts/system/etc/zaprett/lists/
cp lists/list-youtube.txt zaprett-tv/system/etc/zaprett/lists/
cp lists/list-discord.txt zaprett/system/etc/zaprett/lists/
cp lists/list-discord.txt zaprett-hosts/system/etc/zaprett/lists/
@@ -102,30 +97,16 @@ jobs:
updateJson=https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/update-hosts.json
EOF
cat > zaprett-tv/module.prop <<EOF
id=zaprett
name=zaprett-tv
version=${{ inputs.version }}
versionCode=${{ inputs.version_code }}
author=egor-white, Cherret
description=Ускорение CDN серверов Google. ТГК: https://t.me/zaprett_module
updateJson=https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/update-tv.json
EOF
- name: Tree files
run: |
tree zaprett/ zaprett-hosts/ zaprett-tv/
- name: Create archives
run: |
cd zaprett && zip -r ../zaprett.zip ./* && cd ..
cd zaprett-hosts && zip -r ../zaprett-hosts.zip ./* && cd ..
cd zaprett-tv && zip -r ../zaprett-tv.zip ./* && cd ..
mv zaprett.zip out/
mv zaprett-hosts.zip out/
mv zaprett-tv.zip out/
- name: Create release
if: ${{ inputs.create_release == 'true' }}
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.tag }}
@@ -134,10 +115,20 @@ jobs:
files: out/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifact
if: ${{ inputs.create_release != 'true' }}
uses: actions/upload-artifact@v5.0.0
with:
name: zaprett
path: out/*
- name: Update changelog
run: echo "${{ inputs.release_changes}}" > changelog.md
if: ${{ inputs.create_release == 'true' }}
run: echo "${{ inputs.release_changes }}" > changelog.md
- name: Update update.json
if: ${{ inputs.create_release == 'true' }}
run: |
cat > update.json <<EOF
{
@@ -155,16 +146,11 @@ jobs:
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
}
EOF
cat > update_tv.json <<EOF
{
"version": "${{ inputs.version }}",
"versionCode": ${{ inputs.version_code }},
"zipUrl": "https://github.com/${{ github.repository }}/releases/download/${{ inputs.tag }}/zaprett-tv.zip",
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
}
EOF
- name: Commit jsons and changelog
if: ${{ inputs.create_release == 'true' }}
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update update's.json and changelog"
file_pattern: "update.json update_hosts.json update_tv.json changelog.md"
file_pattern: "update.json update_hosts.json changelog.md"

6
.gitmodules vendored
View File

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

View File

@@ -1,17 +1,23 @@
# zaprett
### [Официальный Telegram-канал модуля](https://t.me/zaprett_module)
![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/egor-white/zaprett/total)
![GitHub Downloads (all assets, latest release)](https://img.shields.io/github/downloads/egor-white/zaprett/latest/total)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/egor-white/zaprett/workflow.yml)
### [📣 Официальный Telegram-канал модуля](https://t.me/zaprett_module)
## О модуле
Представляет собой портированную версию [zapret](https://github.com/bol-van/zapret/) от [bol-van](https://github.com/bol-van/) для Android устройств.
Требования:
* Magisk 24.1+
* Прямые руки
* Termux или другой эмулятор терминала **И/ИЛИ** [приложение zaprett](https://github.com/egor-white/zaprett-app) (не обновляется) **ИЛИ** [ремейк приложения zaprett от cherret](https://github.com/CherretGit/zaprett-app)
* Termux или другой эмулятор терминала **И/ИЛИ** [ремейк приложения zaprett от cherret](https://github.com/CherretGit/zaprett-app) ("оригинал" устарел и не обновляется, вместо этого мы вдвоём занимаемся версией на Kotlin!)
На данный момент модуль умеет:
+ Включать, выключать и перезапускать nfqws
+ Работать с листами и стратегиями
+ Работать с листами, айписетами, стратегиями
+ Предлагать обновления через Magisk/KSU/KSU Next/APatch
## Какую версию модуля выбрать?
@@ -33,7 +39,5 @@
Говоря грубо, это файл, который влияет на работу нейросетей и других недоступных сервисов, перенаправляя ваш траффик на сторонние сервера.
Если вы используете модули, которые подменяют этот файл (например, всевозможные блокировщики рекламы и разблокировщики нейросетей), выбирайте версию <big>**без hosts**</big>, иначе модули будут конфликтовать друг с другом.
::: warning
Сервера, используемые в качестве прокси и указанные в файле hosts нам неподконтрольны, мы не несём за них отвественность, используйте с осторожностью
:::
⚠️ Сервера, используемые в качестве прокси и указанные в файле hosts нам неподконтрольны, мы не несём за них отвественность, используйте с осторожностью

View File

@@ -1 +1,3 @@
Список изменений: ● Обновление бинарников zapret до версии 72.1 ● Добавлена поддержка ipset ● Исправление автозапуска
Обновление бинарников zapret до версии 72.2
Обновление hosts файла в zaprett hosts

View File

@@ -1,3 +1,5 @@
### dns.malw.link: hosts file
# Последнее обновление: 17 октября 2025
# Дополнение к zapret:
157.240.245.174 instagram.com
157.240.245.174 www.instagram.com
@@ -7,182 +9,210 @@
3.66.189.153 protonmail.com
3.66.189.153 mail.proton.me
64.233.164.198 yt3.ggpht.com
64.233.164.132 yt4.ggpht.com
52.223.13.41 tracker.openbittorrent.com
130.255.77.28 ntc.party
172.64.33.155 rutor.info
173.245.59.155 rutor.is
185.87.51.182 controlplane.tailscale.com
# ChatGPT, OpenAI:
204.12.192.222 chatgpt.com
204.12.192.222 ab.chatgpt.com
204.12.192.222 auth.openai.com
204.12.192.222 auth0.openai.com
204.12.192.222 platform.openai.com
204.12.192.222 cdn.oaistatic.com
204.12.192.222 files.oaiusercontent.com
204.12.192.222 cdn.auth0.com
204.12.192.222 tcr9i.chat.openai.com
204.12.192.222 webrtc.chatgpt.com
204.12.192.219 android.chat.openai.com
204.12.192.222 api.openai.com
204.12.192.221 operator.chatgpt.com
204.12.192.222 sora.chatgpt.com
204.12.192.222 sora.com
204.12.192.222 sora.chatgpt.com
204.12.192.222 videos.openai.com
185.246.223.127 chatgpt.com
185.246.223.127 ab.chatgpt.com
185.246.223.127 auth.openai.com
185.246.223.127 auth0.openai.com
185.246.223.127 platform.openai.com
185.246.223.127 cdn.oaistatic.com
185.246.223.127 files.oaiusercontent.com
185.246.223.127 cdn.auth0.com
185.246.223.127 tcr9i.chat.openai.com
185.246.223.127 webrtc.chatgpt.com
185.246.223.127 android.chat.openai.com
185.246.223.127 api.openai.com
45.95.233.23 operator.chatgpt.com
185.246.223.127 sora.chatgpt.com
185.246.223.127 sora.com
185.246.223.127 videos.openai.com
# Сервисы Google:
204.12.192.222 gemini.google.com
204.12.192.222 aistudio.google.com
204.12.192.222 generativelanguage.googleapis.com
204.12.192.222 aitestkitchen.withgoogle.com
204.12.192.219 aisandbox-pa.googleapis.com
204.12.192.222 webchannel-alkalimakersuite-pa.clients6.google.com
204.12.192.221 alkalimakersuite-pa.clients6.google.com
204.12.192.221 assistant-s3-pa.googleapis.com
204.12.192.222 proactivebackend-pa.googleapis.com
204.12.192.222 o.pki.goog
204.12.192.222 labs.google
204.12.192.222 notebooklm.google
204.12.192.222 notebooklm.google.com
204.12.192.222 jules.google.com
204.12.192.222 stitch.withgoogle.com
185.246.223.127 gemini.google.com
134.0.118.88 aistudio.google.com
134.0.118.88 generativelanguage.googleapis.com
185.246.223.127 aitestkitchen.withgoogle.com
134.0.118.88 aisandbox-pa.googleapis.com
134.0.118.88 webchannel-alkalimakersuite-pa.clients6.google.com
134.0.118.88 alkalimakersuite-pa.clients6.google.com
134.0.118.88 assistant-s3-pa.googleapis.com
134.0.118.88 proactivebackend-pa.googleapis.com
185.246.223.127 o.pki.goog
185.246.223.127 labs.google
185.246.223.127 notebooklm.google
185.246.223.127 notebooklm.google.com
185.246.223.127 jules.google.com
185.246.223.127 stitch.withgoogle.com
# Microsoft Copilot, Microsoft Rewards, Xbox, Xbox Cloud Gaming:
204.12.192.222 copilot.microsoft.com
204.12.192.222 sydney.bing.com
204.12.192.222 edgeservices.bing.com
204.12.192.221 rewards.bing.com
204.12.192.222 xsts.auth.xboxlive.com
204.12.192.222 xgpuwebf2p.gssv-play-prod.xboxlive.com
204.12.192.222 xgpuweb.gssv-play-prod.xboxlive.com
185.246.223.127 copilot.microsoft.com
185.246.223.127 sydney.bing.com
185.246.223.127 edgeservices.bing.com
45.95.233.23 rewards.bing.com
185.246.223.127 xsts.auth.xboxlive.com
185.246.223.127 xgpuwebf2p.gssv-play-prod.xboxlive.com
185.246.223.127 xgpuweb.gssv-play-prod.xboxlive.com
# Spotify:
204.12.192.222 api.spotify.com
204.12.192.222 xpui.app.spotify.com
204.12.192.222 appresolve.spotify.com
204.12.192.222 login5.spotify.com
204.12.192.222 login.app.spotify.com
204.12.192.222 encore.scdn.co
204.12.192.222 ap-gew1.spotify.com
204.12.192.222 gew1-spclient.spotify.com
204.12.192.222 spclient.wg.spotify.com
204.12.192.222 api-partner.spotify.com
204.12.192.222 aet.spotify.com
204.12.192.222 www.spotify.com
204.12.192.222 accounts.spotify.com
204.12.192.221 open.spotify.com
185.246.223.127 api.spotify.com
185.246.223.127 xpui.app.spotify.com
185.246.223.127 appresolve.spotify.com
185.246.223.127 login5.spotify.com
185.246.223.127 login.app.spotify.com
185.246.223.127 encore.scdn.co
185.246.223.127 ap-gew1.spotify.com
185.246.223.127 gew1-spclient.spotify.com
185.246.223.127 spclient.wg.spotify.com
185.246.223.127 api-partner.spotify.com
185.246.223.127 aet.spotify.com
185.246.223.127 www.spotify.com
185.246.223.127 accounts.spotify.com
45.95.233.23 open.spotify.com
# GitHub Copilot:
204.12.192.222 api.github.com
204.12.192.222 api.individual.githubcopilot.com
204.12.192.222 proxy.individual.githubcopilot.com
50.7.87.84 api.github.com
185.246.223.127 api.individual.githubcopilot.com
185.246.223.127 proxy.individual.githubcopilot.com
# JetBrains:
50.7.85.221 datalore.jetbrains.com
107.150.34.100 plugins.jetbrains.com
204.12.192.222 download.jetbrains.com
185.246.223.127 download.jetbrains.com
185.246.223.127 api.jetbrains.ai
185.246.223.127 account.jetbrains.com
# ElevenLabs:
204.12.192.222 elevenlabs.io
204.12.192.222 api.us.elevenlabs.io
204.12.192.222 elevenreader.io
204.12.192.222 api.elevenlabs.io
204.12.192.222 help.elevenlabs.io
185.246.223.127 elevenlabs.io
185.246.223.127 api.us.elevenlabs.io
185.246.223.127 elevenreader.io
185.246.223.127 api.elevenlabs.io
185.246.223.127 help.elevenlabs.io
# Truth Social
204.12.192.221 truthsocial.com
204.12.192.221 static-assets-1.truthsocial.com
204.12.192.219 truthsocial.com
204.12.192.219 static-assets-1.truthsocial.com
# Grok
204.12.192.222 grok.com
204.12.192.222 accounts.x.ai
204.12.192.222 assets.grok.com
185.246.223.127 grok.com
185.246.223.127 accounts.x.ai
185.246.223.127 assets.grok.com
# Tidal
204.12.192.222 api.tidal.com
204.12.192.222 listen.tidal.com
204.12.192.222 login.tidal.com
204.12.192.222 auth.tidal.com
204.12.192.222 link.tidal.com
204.12.192.222 dd.tidal.com
204.12.192.222 resources.tidal.com
204.12.192.221 images.tidal.com
204.12.192.222 fsu.fa.tidal.com
204.12.192.222 geolocation.onetrust.com
204.12.192.222 api.squareup.com
204.12.192.222 api-global.squareup.com
185.246.223.127 api.tidal.com
185.246.223.127 listen.tidal.com
185.246.223.127 login.tidal.com
185.246.223.127 auth.tidal.com
185.246.223.127 link.tidal.com
185.246.223.127 dd.tidal.com
185.246.223.127 resources.tidal.com
45.95.233.23 images.tidal.com
185.246.223.127 fsu.fa.tidal.com
185.246.223.127 geolocation.onetrust.com
185.246.223.127 api.squareup.com
185.246.223.127 api-global.squareup.com
# Clash Royale, Clash of Clans, Brawl Stars
3.160.212.81 cdn.id.supercell.com
18.172.112.81 security.id.supercell.com
# Supercell
185.246.223.127 cdn.id.supercell.com
185.246.223.127 security.id.supercell.com
45.95.233.23 accounts.supercell.com
18.66.195.96 game-assets.clashroyaleapp.com
51.158.190.98 game.clashroyaleapp.com
3.162.38.39 game-assets.clashofclans.com
70.34.251.56 gamea.clashofclans.com
108.157.194.81 clashofclans.inbox.supercell.com
179.43.168.109 game.brawlstarsgame.com
18.239.69.129 game-assets.brawlstarsgame.com
204.12.192.222 store.supercell.com
185.246.223.127 game-assets.clashroyaleapp.com
185.246.223.127 game-assets.clashofclans.com
185.246.223.127 clashofclans.inbox.supercell.com
185.246.223.127 game-assets.brawlstarsgame.com
185.246.223.127 store.supercell.com
45.95.233.23 game.clashroyaleapp.com
64.188.98.242 gamea.clashofclans.com
185.246.223.127 game.brawlstarsgame.com
108.61.167.26 game.squadbustersgame.com
45.95.233.23 game.mocogame.com
# DeepL
204.12.192.222 deepl.com
204.12.192.222 www.deepl.com
204.12.192.222 www2.deepl.com
204.12.192.222 login-wall.deepl.com
204.12.192.219 w.deepl.com
204.12.192.222 s.deepl.com
204.12.192.222 dict.deepl.com
204.12.192.222 ita-free.www.deepl.com
204.12.192.222 write-free.www.deepl.com
204.12.192.222 experimentation.deepl.com
185.246.223.127 deepl.com
185.246.223.127 www.deepl.com
185.246.223.127 www2.deepl.com
185.246.223.127 login-wall.deepl.com
185.246.223.127 w.deepl.com
185.246.223.127 s.deepl.com
185.246.223.127 dict.deepl.com
185.246.223.127 ita-free.www.deepl.com
185.246.223.127 write-free.www.deepl.com
185.246.223.127 experimentation.deepl.com
185.246.223.127 experimentation-grpc.deepl.com
185.246.223.127 ita-free.app.deepl.com
185.246.223.127 shield.deepl.com
185.246.223.127 ott.deepl.com
185.246.223.127 api-free.deepl.com
185.246.223.127 backend.deepl.com
185.246.223.127 clearance.deepl.com
185.246.223.127 errortracking.deepl.com
185.246.223.127 auth.deepl.com
185.246.223.127 oneshot-free.www.deepl.com
# Deezer
204.12.192.220 deezer.com
204.12.192.220 www.deezer.com
204.12.192.220 dzcdn.net
204.12.192.220 payment.deezer.com
185.246.223.127 deezer.com
185.246.223.127 www.deezer.com
185.246.223.127 dzcdn.net
185.246.223.127 payment.deezer.com
# Weather.com
204.12.192.220 weather.com
204.12.192.220 upsx.weather.com
185.246.223.127 weather.com
185.246.223.127 upsx.weather.com
# Guilded
204.12.192.219 guilded.gg
204.12.192.219 www.guilded.gg
# Fitbit
204.12.192.219 api.fitbit.com
204.12.192.219 fitbit-pa.googleapis.com
204.12.192.219 fitbitvestibuleshim-pa.googleapis.com
204.12.192.219 fitbit.google.com
185.246.223.127 api.fitbit.com
185.246.223.127 fitbit-pa.googleapis.com
185.246.223.127 fitbitvestibuleshim-pa.googleapis.com
185.246.223.127 fitbit.google.com
# 4PDA
# Claude
185.246.223.127 claude.ai
185.246.223.127 console.anthropic.com
185.246.223.127 auth.anthropic.com
185.246.223.127 api.anthropic.com
#4PDA
185.246.223.127 4pda.to
185.246.223.127 app.4pda.to
185.246.223.127 s.4pda.to
185.246.223.127 appbk.4pda.to
45.81.252.72 cs11a0a.4pda.ws
185.234.59.26 cs7f6c.4pda.ws
217.182.194.171 cs4a0d.4pda.ws
141.94.143.110 cs3b2e.4pda.ws
54.36.104.75 cs2c9f.4pda.ws
# Trae.ai
185.246.223.127 trae-api-sg.mchost.guru
185.246.223.127 api.trae.ai
185.246.223.127 api-sg-central.trae.ai
185.246.223.127 api16-normal-alisg.mchost.guru
# Другое:
204.12.192.222 claude.ai
204.12.192.220 console.anthropic.com
204.12.192.222 www.notion.so
185.246.223.127 www.notion.so
50.7.85.222 www.canva.com
204.12.192.222 www.intel.com
204.12.192.219 www.dell.com
185.246.223.127 www.intel.com
185.246.223.127 www.dell.com
50.7.85.219 www.tiktok.com # Только на сайте. Приложение определяет регион по оператору, а не по IP. Поэтому есть моды.
142.54.189.106 web.archive.org # Блокирует от российских IP некоторые сайты
204.12.192.220 developer.nvidia.com
185.246.223.127 developer.nvidia.com
107.150.34.99 builds.parsec.app
204.12.192.220 tria.ge
204.12.192.220 api.imgur.com
185.246.223.127 tria.ge
185.246.223.127 api.imgur.com
45.95.233.23 www.dyson.com
45.95.233.23 www.dyson.fr
45.95.233.23 usher.ttvnw.net
64.188.98.242 api.manus.im
185.246.223.127 profile.broadcom.com
45.95.233.23 test.dns.malw.link
45.95.233.23 eu.posthog.com
185.246.223.127 www.qwant.com
185.246.223.127 guidedhacking.com
# Блокировка реально плохих сайтов
# Скримеры:
@@ -212,4 +242,5 @@
0.0.0.0 an.yandex.ru
0.0.0.0 appmetrica.yandex.ru
0.0.0.0 mc.yandex.ru
0.0.0.0 amc.yandex.ru
0.0.0.0 amc.yandex.ru
### dns.malw.link: end hosts file

461
rust/Cargo.lock generated
View File

@@ -2,12 +2,6 @@
# It is not intended for manual editing.
version = 4
[[package]]
name = "adler2"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]]
name = "aho-corasick"
version = "1.1.4"
@@ -17,15 +11,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
"libc",
]
[[package]]
name = "anstream"
version = "0.6.21"
@@ -82,12 +67,6 @@ version = "1.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
[[package]]
name = "autocfg"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
[[package]]
name = "bindgen"
version = "0.72.1"
@@ -114,12 +93,6 @@ version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
[[package]]
name = "bumpalo"
version = "3.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
[[package]]
name = "byteorder"
version = "1.5.0"
@@ -158,15 +131,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[package]]
name = "chrono"
version = "0.4.42"
name = "cfg_aliases"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2"
dependencies = [
"iana-time-zone",
"num-traits",
"windows-link",
]
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
name = "clang-sys"
@@ -245,27 +213,21 @@ dependencies = [
"tiny-keccak",
]
[[package]]
name = "core-foundation-sys"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "crc32fast"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
dependencies = [
"cfg-if",
]
[[package]]
name = "crunchy"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
[[package]]
name = "daemonize"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab8bfdaacb3c887a54d41bdf48d3af8873b3f5566469f8ba21b92057509f116e"
dependencies = [
"libc",
]
[[package]]
name = "dlv-list"
version = "0.5.2"
@@ -294,13 +256,16 @@ dependencies = [
]
[[package]]
name = "errno"
version = "0.3.14"
name = "env_logger"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580"
dependencies = [
"libc",
"windows-sys 0.61.2",
"humantime",
"is-terminal",
"log",
"regex",
"termcolor",
]
[[package]]
@@ -309,16 +274,6 @@ version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127"
[[package]]
name = "flate2"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfe33edd8e85a12a67454e37f8c75e730830d83e313556ab9ebf9ee7fbeb3bfb"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]]
name = "getrandom"
version = "0.2.16"
@@ -330,6 +285,18 @@ dependencies = [
"wasi",
]
[[package]]
name = "getset"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cf0fc11e47561d47397154977bc219f4cf809b2974facc3ccb3b89e2436f912"
dependencies = [
"proc-macro-error2",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "glob"
version = "0.3.3"
@@ -349,43 +316,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hex"
version = "0.4.3"
name = "hermit-abi"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
[[package]]
name = "iana-time-zone"
version = "0.1.64"
name = "humantime"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"log",
"wasm-bindgen",
"windows-core",
]
checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424"
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
name = "is-terminal"
version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
dependencies = [
"cc",
]
[[package]]
name = "iptables"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f30c9a636a0a728c67d1d420471c99b215708a17c222bb9afb16d0821e2d80d8"
dependencies = [
"lazy_static",
"regex",
"hermit-abi",
"libc",
"windows-sys 0.61.2",
]
[[package]]
@@ -409,22 +359,6 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "js-sys"
version = "0.3.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65"
dependencies = [
"once_cell",
"wasm-bindgen",
]
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
version = "0.2.177"
@@ -438,7 +372,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
dependencies = [
"cfg-if",
"windows-link",
"windows-link 0.2.1",
]
[[package]]
@@ -451,12 +385,6 @@ dependencies = [
"once_cell",
]
[[package]]
name = "linux-raw-sys"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
[[package]]
name = "lock_api"
version = "0.4.14"
@@ -484,16 +412,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "miniz_oxide"
version = "0.8.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
dependencies = [
"adler2",
"simd-adler32",
]
[[package]]
name = "mio"
version = "1.1.0"
@@ -505,6 +423,18 @@ dependencies = [
"windows-sys 0.61.2",
]
[[package]]
name = "nix"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
dependencies = [
"bitflags",
"cfg-if",
"cfg_aliases",
"libc",
]
[[package]]
name = "nom"
version = "7.1.3"
@@ -516,12 +446,31 @@ dependencies = [
]
[[package]]
name = "num-traits"
version = "0.2.19"
name = "ntapi"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4"
dependencies = [
"autocfg",
"winapi",
]
[[package]]
name = "objc2-core-foundation"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
dependencies = [
"bitflags",
]
[[package]]
name = "objc2-io-kit"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33fafba39597d6dc1fb709123dfa8289d39406734be322956a69f0931c73bb15"
dependencies = [
"libc",
"objc2-core-foundation",
]
[[package]]
@@ -566,7 +515,7 @@ dependencies = [
"libc",
"redox_syscall",
"smallvec",
"windows-link",
"windows-link 0.2.1",
]
[[package]]
@@ -575,6 +524,16 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
[[package]]
name = "pretty_env_logger"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "865724d4dbe39d9f3dd3b52b88d859d66bcb2d6a0acfd5ea68a65fb66d4bdc1c"
dependencies = [
"env_logger",
"log",
]
[[package]]
name = "prettyplease"
version = "0.2.37"
@@ -585,6 +544,28 @@ dependencies = [
"syn",
]
[[package]]
name = "proc-macro-error-attr2"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5"
dependencies = [
"proc-macro2",
"quote",
]
[[package]]
name = "proc-macro-error2"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802"
dependencies = [
"proc-macro-error-attr2",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "proc-macro2"
version = "1.0.103"
@@ -594,30 +575,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "procfs"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25485360a54d6861439d60facef26de713b1e126bf015ec8f98239467a2b82f7"
dependencies = [
"bitflags",
"chrono",
"flate2",
"procfs-core",
"rustix",
]
[[package]]
name = "procfs-core"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6401bf7b6af22f78b563665d15a22e9aef27775b79b149a66ca022468a4e405"
dependencies = [
"bitflags",
"chrono",
"hex",
]
[[package]]
name = "quote"
version = "1.0.41"
@@ -681,25 +638,6 @@ version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
[[package]]
name = "rustix"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.61.2",
]
[[package]]
name = "rustversion"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[package]]
name = "ryu"
version = "1.0.20"
@@ -779,12 +717,6 @@ dependencies = [
"libc",
]
[[package]]
name = "simd-adler32"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
[[package]]
name = "smallvec"
version = "1.15.1"
@@ -832,6 +764,29 @@ dependencies = [
"walkdir",
]
[[package]]
name = "sysinfo"
version = "0.37.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f"
dependencies = [
"libc",
"memchr",
"ntapi",
"objc2-core-foundation",
"objc2-io-kit",
"windows",
]
[[package]]
name = "termcolor"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
dependencies = [
"winapi-util",
]
[[package]]
name = "thiserror"
version = "2.0.17"
@@ -918,49 +873,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
[[package]]
name = "wasm-bindgen"
version = "0.2.105"
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"cfg-if",
"once_cell",
"rustversion",
"wasm-bindgen-macro",
"wasm-bindgen-shared",
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.105"
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.105"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc"
dependencies = [
"bumpalo",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.105"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76"
dependencies = [
"unicode-ident",
]
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
@@ -972,18 +898,57 @@ dependencies = [
]
[[package]]
name = "windows-core"
version = "0.62.2"
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.61.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"
dependencies = [
"windows-collections",
"windows-core",
"windows-future",
"windows-link 0.1.3",
"windows-numerics",
]
[[package]]
name = "windows-collections"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"
dependencies = [
"windows-core",
]
[[package]]
name = "windows-core"
version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
dependencies = [
"windows-implement",
"windows-interface",
"windows-link",
"windows-link 0.1.3",
"windows-result",
"windows-strings",
]
[[package]]
name = "windows-future"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"
dependencies = [
"windows-core",
"windows-link 0.1.3",
"windows-threading",
]
[[package]]
name = "windows-implement"
version = "0.60.2"
@@ -1006,6 +971,12 @@ dependencies = [
"syn",
]
[[package]]
name = "windows-link"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
[[package]]
name = "windows-link"
version = "0.2.1"
@@ -1013,21 +984,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-result"
version = "0.4.1"
name = "windows-numerics"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"
dependencies = [
"windows-link",
"windows-core",
"windows-link 0.1.3",
]
[[package]]
name = "windows-result"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"
dependencies = [
"windows-link 0.1.3",
]
[[package]]
name = "windows-strings"
version = "0.5.1"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"
dependencies = [
"windows-link",
"windows-link 0.1.3",
]
[[package]]
@@ -1045,7 +1026,7 @@ version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
"windows-link",
"windows-link 0.2.1",
]
[[package]]
@@ -1054,7 +1035,7 @@ version = "0.53.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
dependencies = [
"windows-link",
"windows-link 0.2.1",
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
@@ -1065,6 +1046,15 @@ dependencies = [
"windows_x86_64_msvc",
]
[[package]]
name = "windows-threading"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6"
dependencies = [
"windows-link 0.1.3",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.53.1"
@@ -1119,15 +1109,18 @@ version = "0.0.1"
dependencies = [
"anyhow",
"clap",
"iptables",
"daemonize",
"getset",
"libc",
"libnfqws",
"once_cell",
"procfs",
"log",
"nix",
"pretty_env_logger",
"regex",
"rust-ini",
"serde",
"serde_json",
"sysctl",
"sysinfo",
"tokio",
]

View File

@@ -10,9 +10,7 @@ resolver = "3"
[workspace.dependencies]
anyhow = "1.0.100"
clap = { version = "4.5.50", features = ["derive"] }
iptables = "0.6.0"
libc = "0.2.177"
procfs = "0.18.0"
regex = "1.12.2"
rust-ini = "0.21.3"
serde = { version = "1.0.228", features = ["derive"] }
@@ -20,4 +18,15 @@ serde_json = "1.0.145"
sysctl = "0.7.1"
tokio = { version = "1.48.0", features = ["full"] }
once_cell = "1.21.3"
daemonize = "0.5.0"
log = "0.4.28"
pretty_env_logger = "0.5.0"
nix = { version = "0.30.1", features = ["signal"] }
getset = "0.1.6"
sysinfo = "0.37.2"
[profile.release]
panic = "abort"
opt-level = "z"
lto = true
strip = true

View File

@@ -16,12 +16,16 @@ rel_manifest_path!(NFQ_CRYPTO, "zapret/nfq/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))
.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")
@@ -33,9 +37,13 @@ fn main() {
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=nfqws");
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();

View File

@@ -7,14 +7,17 @@ repository.workspace = true
[dependencies]
anyhow = { workspace = true }
clap = { workspace = true }
iptables = { workspace = true }
libc = { workspace = true }
procfs = { workspace = true }
regex = { workspace = true }
rust-ini = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sysctl ={ workspace = true }
tokio = { workspace = true }
once_cell = { workspace = true }
libnfqws = { path = "../libnfqws" }
libnfqws = { path = "../libnfqws" }
daemonize = { workspace = true }
pretty_env_logger = { workspace = true }
log = { workspace = true }
nix = { workspace = true, features = ["user"] }
getset = { workspace = true }
sysinfo = { workspace = true }

View File

@@ -0,0 +1,5 @@
use std::env;
fn main() {
let zapret_version = env::var("ZAPRET_VERSION").unwrap_or("unknown".to_string());
println!("cargo:rustc-env=ZAPRET_VERSION={}", zapret_version);
}

View File

@@ -0,0 +1,20 @@
use crate::MODULE_PATH;
use tokio::fs;
use tokio::fs::File;
pub async fn set_autostart(autostart: bool) -> Result<(), anyhow::Error> {
let autostart_path = MODULE_PATH.join("autostart");
if autostart {
File::create(autostart_path).await?;
} else {
fs::remove_file(autostart_path).await?;
}
Ok(())
}
pub fn get_autostart() {
let file = MODULE_PATH.join("autostart");
println!("{}", file.exists());
}

View File

@@ -0,0 +1,13 @@
pub mod commands;
use clap::Parser;
use commands::Command;
use getset::Getters;
#[derive(Parser, Getters)]
#[command(version)]
#[getset(get = "pub")]
pub struct CliApp {
#[command(subcommand)]
cmd: Option<Command>,
}

View File

@@ -0,0 +1,68 @@
use crate::service::{restart_service, service_status, start_service, stop_service};
use crate::{bin_version, module_version};
use clap::Subcommand;
use log::error;
use crate::autostart::{get_autostart, set_autostart};
#[derive(Subcommand)]
pub enum Command {
/// Start the service
Start,
/// Stop the service
Stop,
/// Restart the service
Restart,
/// Show the current service status
Status,
/// Enable or disable automatic restart
SetAutostart {
/// Whether to enable (true) or disable (false) autostart
#[arg(value_parser = clap::value_parser!(bool))]
autostart: bool,
},
/// Show whether autostart is enabled
GetAutostart,
/// Show the module version
ModuleVersion,
/// Show the nfqws binary version
BinaryVersion,
}
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::Status => {
println!(
"zaprett is {}",
if service_status().await? {
"working"
} else {
"stopped"
}
);
}
Command::SetAutostart { autostart } => {
if let Err(err) = set_autostart(*autostart).await {
error!("Failed to set auto start: {err}")
}
}
Command::GetAutostart => get_autostart(),
Command::ModuleVersion => println!("{}", module_version().await?),
Command::BinaryVersion => println!("{}", bin_version()),
}
Ok(())
}
}

View File

@@ -0,0 +1,63 @@
use crate::{MODULE_PATH, merge_files};
use getset::Getters;
use serde::{Deserialize, Serialize};
#[derive(Default, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum ListType {
#[default]
Whitelist,
Blacklist,
}
#[derive(Default, Serialize, Deserialize, Getters)]
#[getset(get = "pub")]
#[serde(default)]
pub struct Config {
active_lists: Vec<String>,
active_ipsets: Vec<String>,
active_exclude_lists: Vec<String>,
active_exclude_ipsets: Vec<String>,
list_type: ListType,
strategy: String,
app_list: String,
whitelist: Vec<String>,
blacklist: Vec<String>,
}
impl ListType {
/// # Returns
///
/// (hostlist arg, ipset arg)
pub async fn merge(&self, config: &Config) -> (String, String) {
let module_path_str = MODULE_PATH.to_str().unwrap();
let (host_files, ipset_files, host_suffix, ipset_suffix, exclude_flag) = match self {
ListType::Whitelist => (
&config.active_lists,
&config.active_ipsets,
"hostlist",
"ipset",
"",
),
ListType::Blacklist => (
&config.active_exclude_lists,
&config.active_exclude_ipsets,
"hostlist-exclude",
"ipset-exclude",
"-exclude",
),
};
let host_path = MODULE_PATH.join(format!("tmp/{host_suffix}"));
let ipset_path = MODULE_PATH.join(format!("tmp/{ipset_suffix}"));
merge_files(host_files, host_path).await.unwrap();
merge_files(ipset_files, ipset_path).await.unwrap();
(
format!("--hostlist{exclude_flag}={module_path_str}/tmp/{host_suffix}"),
format!("--ipset{exclude_flag}={module_path_str}/tmp/{ipset_suffix}"),
)
}
}

View File

@@ -0,0 +1,26 @@
use crate::{MODULE_PATH, run_nfqws};
use daemonize::Daemonize;
use log::{error, info};
use std::fs::File;
pub async fn daemonize_nfqws(args: &str) {
info!("Starting nfqws as a daemon");
let stdout = File::create(MODULE_PATH.join("tmp/nfqws.out")).unwrap();
let stderr = File::create(MODULE_PATH.join("tmp/nfqws.err")).unwrap();
let daemonize = Daemonize::new()
.pid_file(MODULE_PATH.join("tmp/pid.lock").as_path())
.working_directory(MODULE_PATH.join("tmp"))
.stdout(stdout)
.stderr(stderr)
.privileged_action(|| "Executed before drop privileges");
match daemonize.start() {
Ok(_) => {
info!("Success, daemonized");
run_nfqws(args).unwrap()
}
Err(e) => error!("Error while starting nfqws daemon: {e}"),
}
}

View File

@@ -0,0 +1,88 @@
use std::error;
use std::process::Command;
pub fn setup_iptables_rules() -> Result<(), Box<dyn error::Error>> {
Command::new("iptables")
.arg("-t")
.arg("mangle")
.arg("-I")
.arg("POSTROUTING")
.arg("-j")
.arg("NFQUEUE")
.arg("--queue-num")
.arg("200")
.arg("--queue-bypass")
.status()
.expect("failed to add iptables rules");
Command::new("iptables")
.arg("-t")
.arg("mangle")
.arg("-I")
.arg("PREROUTING")
.arg("-j")
.arg("NFQUEUE")
.arg("--queue-num")
.arg("200")
.arg("--queue-bypass")
.status()
.expect("failed to add iptables rules");
Command::new("iptables")
.arg("-t")
.arg("filter")
.arg("-A")
.arg("FORWARD")
.arg("-j")
.arg("NFQUEUE")
.arg("--queue-num")
.arg("200")
.arg("--queue-bypass")
.status()
.expect("failed to add iptables rules");
Ok(())
}
pub fn clear_iptables_rules() -> Result<(), Box<dyn error::Error>> {
Command::new("iptables")
.arg("-t")
.arg("mangle")
.arg("-D")
.arg("POSTROUTING")
.arg("-j")
.arg("NFQUEUE")
.arg("--queue-num")
.arg("200")
.arg("--queue-bypass")
.status()
.expect("failed to remove iptables rules");
Command::new("iptables")
.arg("-t")
.arg("mangle")
.arg("-D")
.arg("PREROUTING")
.arg("-j")
.arg("NFQUEUE")
.arg("--queue-num")
.arg("200")
.arg("--queue-bypass")
.status()
.expect("failed to remove iptables rules");
Command::new("iptables")
.arg("-t")
.arg("filter")
.arg("-D")
.arg("FORWARD")
.arg("-j")
.arg("NFQUEUE")
.arg("--queue-num")
.arg("200")
.arg("--queue-bypass")
.status()
.expect("failed to remove iptables rules");
Ok(())
}

View File

@@ -0,0 +1,103 @@
pub mod cli;
pub mod config;
mod daemon;
pub mod iptables_rust;
mod service;
mod autostart;
use ini::Ini;
use libnfqws::nfqws_main;
use std::error;
use std::ffi::CString;
use std::os::raw::c_char;
use std::path::Path;
use std::sync::LazyLock;
use anyhow::bail;
use tokio::fs::File;
use tokio::io::{copy, AsyncWriteExt};
use tokio::task::spawn_blocking;
pub static MODULE_PATH: LazyLock<&Path> =
LazyLock::new(|| Path::new("/data/adb/modules/zaprett"));
pub static ZAPRETT_DIR_PATH: LazyLock<&Path> =
LazyLock::new(|| Path::new("/storage/emulated/0/zaprett"));
pub static DEFAULT_START: &str = "
--filter-tcp=80 --dpi-desync=fake,split2 --dpi-desync-autottl=2 --dpi-desync-fooling=md5sig,badsum $hostlist --new
--filter-tcp=443 $hostlist --dpi-desync=fake,split2 --dpi-desync-repeats=6 --dpi-desync-fooling=md5sig,badsum --dpi-desync-fake-tls=${zaprettdir}/bin/tls_clienthello_www_google_com.bin --new
--filter-tcp=80,443 --dpi-desync=fake,disorder2 --dpi-desync-repeats=6 --dpi-desync-autottl=2 --dpi-desync-fooling=md5sig,badsum $hostlist --new
--filter-udp=50000-50100 --dpi-desync=fake --dpi-desync-any-protocol --dpi-desync-fake-quic=0xC30000000108 --new
--filter-udp=443 $hostlist --dpi-desync=fake --dpi-desync-repeats=6 --dpi-desync-fake-quic=${zaprettdir}/bin/quic_initial_www_google_com.bin --new
--filter-udp=443 --dpi-desync=fake --dpi-desync-repeats=6 $hostlist
";
async fn module_version() -> anyhow::Result<String> {
let prop = spawn_blocking(|| Ini::load_from_file(MODULE_PATH.join("module.prop")))
.await??;
if let Some(props) = prop.section::<String>(None)
&& let Some(version) = props.get("version")
{
return Ok(version.into());
}
bail!("Failed to get version, prop not found")
}
fn bin_version() -> &'static str {
env!("ZAPRET_VERSION")
}
pub async fn merge_files(
input_paths: &[impl AsRef<Path>],
output_path: impl AsRef<Path>,
) -> Result<(), Box<dyn error::Error>> {
let output_path = output_path.as_ref();
let mut output_file = File::create(output_path).await?;
for input in input_paths {
let input = input.as_ref();
let mut input_file = File::open(input)
.await
.map_err(|e| format!("Failed to open {}: {e}", input.display()))?;
copy(&mut input_file, &mut output_file).await.map_err(|e| {
format!(
"Failed to write contents of {}: {e}",
input.display()
)
})?;
}
output_file.flush().await?;
Ok(())
}
fn run_nfqws(args_str: &str) -> anyhow::Result<()> {
let mut args = vec![
"nfqws".to_string(),
"--uid=0:0".to_string(),
"--qnum=200".to_string(),
];
if args_str.trim().is_empty() {
args.push("-v".to_string());
} else {
args.extend(args_str.split_whitespace().map(String::from));
}
let c_args: Vec<CString> = args
.into_iter()
.map(|arg| CString::new(arg).unwrap())
.collect();
let mut ptrs: Vec<*const c_char> = c_args.iter().map(|arg| arg.as_ptr()).collect();
unsafe {
nfqws_main(c_args.len() as libc::c_int, ptrs.as_mut_ptr() as *mut _);
}
Ok(())
}

View File

@@ -1,337 +1,15 @@
// mod libnfqws;
use anyhow::bail;
use clap::{ArgAction, Parser, Subcommand, builder::BoolishValueParser};
use ini::Ini;
use procfs::process::all_processes;
use regex::Regex;
use serde::{Deserialize, Serialize};
use std::ffi::CString;
use std::fs::File;
use std::io::BufReader;
use std::io::{Read, Write};
use std::os::raw::c_char;
use std::sync::atomic::{AtomicBool, Ordering};
use std::{fs, path::Path};
use sysctl::{CtlValue, Sysctl};
use tokio::task;
use libnfqws::nfqws_main;
#[derive(Parser)]
#[command(version)]
struct Cli {
#[command(subcommand)]
cmd: Option<Commands>,
}
#[derive(Subcommand)]
enum Commands {
#[clap(about = "Start service")]
Start,
#[clap(about = "Stop service")]
Stop,
#[clap(about = "Restart service")]
Restart,
#[clap(about = "Show service status")]
Status,
#[clap(about = "Enable/disable autorestart")]
SetAutostart {
#[arg(
value_name = "boolean",
action = ArgAction::Set,
value_parser = BoolishValueParser::new()
)]
autostart: bool,
},
#[clap(about = "Get autorestart state")]
GetAutostart,
#[clap(about = "Get module version")]
ModuleVer,
#[clap(about = "Get nfqws binary version")]
BinVer,
}
#[derive(Serialize, Deserialize)]
struct Config {
active_lists: Vec<String>,
active_ipsets: Vec<String>,
active_exclude_lists: Vec<String>,
active_exclude_ipsets: Vec<String>,
list_type: String,
strategy: String,
app_list: String,
whitelist: Vec<String>,
blacklist: Vec<String>,
}
use clap::Parser;
use zaprett::cli::CliApp;
#[tokio::main]
async fn main() {
let cli = Cli::parse();
match &cli.cmd {
Some(Commands::Start) => start_service(),
Some(Commands::Stop) => stop_service(),
Some(Commands::Restart) => restart_service(),
Some(Commands::Status) => service_status(),
Some(Commands::SetAutostart { autostart }) => set_autostart(autostart),
Some(Commands::GetAutostart) => get_autostart(),
Some(Commands::ModuleVer) => module_version(),
Some(Commands::BinVer) => todo!(), //bin_version(),
//None => println!("zaprett installed. Join us: t.me/zaprett_module"),
None => run_nfqws("--version".to_string()).await.unwrap(),
async fn main() -> anyhow::Result<()> {
pretty_env_logger::init();
let cli = CliApp::parse();
match cli.cmd() {
Some(cmd) => cmd.exec().await?,
None => println!("zaprett installed. Join us: t.me/zaprett_module"),
}
tokio::signal::ctrl_c().await.unwrap();
}
fn start_service() {
println!("Starting zaprett service...");
let tmp_dir = Path::new("/data/adb/modules/zaprett/tmp");
if tmp_dir.exists() {
fs::remove_dir_all(&tmp_dir).unwrap()
}
let reader =
BufReader::new(File::open("/sdcard/zaprett/config.json").expect("cannot open config.json"));
let config: Config = serde_json::from_reader(reader).expect("invalid json");
let list_type: &String = &config.list_type;
let def_strat: String = String::from("
--filter-tcp=80 --dpi-desync=fake,split2 --dpi-desync-autottl=2 --dpi-desync-fooling=md5sig,badsum $hostlist --new
--filter-tcp=443 $hostlist --dpi-desync=fake,split2 --dpi-desync-repeats=6 --dpi-desync-fooling=md5sig,badsum --dpi-desync-fake-tls=${zaprettdir}/bin/tls_clienthello_www_google_com.bin --new
--filter-tcp=80,443 --dpi-desync=fake,disorder2 --dpi-desync-repeats=6 --dpi-desync-autottl=2 --dpi-desync-fooling=md5sig,badsum $hostlist --new
--filter-udp=50000-50100 --dpi-desync=fake --dpi-desync-any-protocol --dpi-desync-fake-quic=0xC30000000108 --new
--filter-udp=443 $hostlist --dpi-desync=fake --dpi-desync-repeats=6 --dpi-desync-fake-quic=${zaprettdir}/bin/quic_initial_www_google_com.bin --new
--filter-udp=443 --dpi-desync=fake --dpi-desync-repeats=6 $hostlist
");
let strat = if Path::new(&config.strategy).exists() {
fs::read_to_string(&config.strategy).unwrap_or_else(|_| def_strat)
} else {
def_strat
};
let regex_hostlist = Regex::new(r"\$hostlist").unwrap();
let regex_ipsets = Regex::new(r"\$ipset").unwrap();
let regex_zaprettdir = Regex::new(r"\$\{?zaprettdir\}?").unwrap();
let zaprett_dir = String::from("/sdcard/zaprett");
let mut strat_modified = String::new();
if list_type.eq("whitelist") {
merge_files(
config.active_lists,
"/data/adb/modules/zaprett/tmp/hostlist",
)
.unwrap();
merge_files(config.active_ipsets, "/data/adb/modules/zaprett/tmp/ipset").unwrap();
let hosts = String::from("--hostlist=/data/adb/modules/zaprett/tmp/hostlist");
let ipsets = String::from("--ipset=/data/adb/modules/zaprett/tmp/ipset");
strat_modified = regex_hostlist.replace_all(&strat, &hosts).into_owned();
strat_modified = regex_ipsets
.replace_all(&strat_modified, &ipsets)
.into_owned();
strat_modified = regex_zaprettdir
.replace_all(&strat_modified, &zaprett_dir)
.into_owned();
} else if list_type.eq("blacklist") {
merge_files(
config.active_exclude_lists,
"/data/adb/modules/zaprett/tmp/hostlist-exclude",
)
.unwrap();
merge_files(
config.active_exclude_ipsets,
"/data/adb/modules/zaprett/tmp/ipset-exclude",
)
.unwrap();
let hosts =
String::from("--hostlist-exclude=/data/adb/modules/zaprett/tmp/hostlist-exclude");
let ipsets = String::from("--ipset-exclude=/data/adb/modules/zaprett/tmp/ipset-exclude");
strat_modified = regex_hostlist.replace_all(&strat, &hosts).into_owned();
strat_modified = regex_ipsets
.replace_all(&strat_modified, &ipsets)
.into_owned();
strat_modified = regex_zaprettdir
.replace_all(&strat_modified, &zaprett_dir)
.into_owned();
} else {
panic!("no list-type called {}", &list_type)
}
let ctl = sysctl::Ctl::new("net.netfilter.nf_conntrack_tcp_be_liberal").unwrap();
ctl.set_value(CtlValue::Int(1)).unwrap();
setup_iptables_rules();
//run_nfqws(&strat_modified);
todo!();
println!("zaprett service started!");
}
fn stop_service() {
clear_iptables_rules();
todo!()
}
fn restart_service() {
stop_service();
start_service();
println!("zaprett service restarted!")
}
fn set_autostart(autostart: &bool) {
if *autostart {
if let Err(e) = std::fs::File::create("/data/adb/modules/zaprett/autostart") {
eprintln!("autostart: cannot create flag file: {e}");
}
} else {
fs::remove_file("/data/adb/modules/zaprett/autostart").unwrap()
}
}
fn get_autostart() {
let file = Path::new("/data/adb/modules/zaprett/autostart");
println!("{}", file.exists());
}
fn service_status() {
let running = match all_processes() {
Ok(iter) => iter
.filter_map(|rp| rp.ok())
.filter_map(|p| p.stat().ok())
.any(|st| st.comm == "nfqws"),
Err(_) => false,
};
println!("zaprett is {}", if running { "working" } else { "stopped" });
}
fn module_version() {
if let Ok(prop) = Ini::load_from_file("/data/adb/modules/zaprett/module.prop") {
if let Some(props) = prop.section::<String>(None) {
if let Some(v) = props.get("version") {
println!("{}", v);
}
}
}
}
fn bin_version() {
todo!()
/*if let Ok(output) = Command::new("nfqws").arg("--version").output() {
if output.status.success() {
let stdout = String::from_utf8_lossy(&output.stdout);
if let Ok(re) = Regex::new(r"version v[0-9.]+") {
if let Some(m) = re.find(&stdout) {
if let Some(v) = m.as_str().split_whitespace().nth(1) {
println!("{}", v);
return;
}
}
}
}
}*/
}
fn merge_files(
input_paths: Vec<String>,
output_path: &str,
) -> Result<(), Box<dyn std::error::Error>> {
let mut combined_content = String::new();
for path_str in input_paths {
let path = Path::new(&path_str);
let mut file = File::open(path)?;
let mut content = String::new();
file.read_to_string(&mut content)?;
combined_content.push_str(&content);
}
let mut output_file = File::create(output_path)?;
output_file.write_all(combined_content.as_bytes())?;
Ok(())
}
fn setup_iptables_rules() {
let ipt = iptables::new(false).unwrap();
ipt.insert(
"mangle",
"POSTROUTING",
"-j NFQUEUE --queue-num 200 --queue-bypass",
1,
)
.unwrap();
ipt.insert(
"mangle",
"PREROUTING",
"-j NFQUEUE --queue-num 200 --queue-bypass",
1,
)
.unwrap();
ipt.append(
"filter",
"FORWARD",
"-j NFQUEUE --queue-num 200 --queue-bypass",
)
.unwrap();
}
fn clear_iptables_rules() {
let ipt = iptables::new(false).unwrap();
ipt.delete(
"mangle",
"POSTROUTING",
"-j NFQUEUE --queue-num 200 --queue-bypass",
)
.unwrap();
ipt.delete(
"mangle",
"PREROUTING",
"-j NFQUEUE --queue-num 200 --queue-bypass",
)
.unwrap();
ipt.delete(
"filter",
"FORWARD",
"-j NFQUEUE --queue-num 200 --queue-bypass",
)
.unwrap();
}
async fn run_nfqws(args_str: String) -> anyhow::Result<()> {
static RUNNING: AtomicBool = AtomicBool::new(false);
if RUNNING.swap(true, Ordering::SeqCst) {
bail!("nfqws already started!");
}
let mut args = vec!["nfqws".to_string()];
if args_str.trim().is_empty() {
args.push("-v".to_string());
} else {
args.extend(args_str.trim().split_whitespace().map(String::from));
}
// fire-and-forget
let _ = task::spawn_blocking(move || {
let c_args: Vec<CString> = args
.into_iter()
.map(|arg| CString::new(arg).unwrap())
.collect();
let mut ptrs: Vec<*const c_char> = c_args.iter().map(|arg| arg.as_ptr()).collect();
unsafe {
nfqws_main(c_args.len() as libc::c_int, ptrs.as_mut_ptr() as *mut _);
}
RUNNING.store(false, Ordering::SeqCst);
});
Ok(())
}

View File

@@ -0,0 +1,125 @@
use crate::config::Config;
use crate::daemon::daemonize_nfqws;
use crate::iptables_rust::{clear_iptables_rules, setup_iptables_rules};
use crate::{DEFAULT_START, MODULE_PATH, ZAPRETT_DIR_PATH};
use anyhow::bail;
use log::info;
use nix::sys::signal::{Signal, kill};
use nix::unistd::{Pid, Uid};
use regex::Regex;
use std::borrow::Cow;
use sysctl::{Ctl, CtlValue, Sysctl};
use sysinfo::{Pid as SysPid, System};
use tokio::fs;
use tokio::fs::File;
use tokio::io::AsyncReadExt;
use std::path::Path;
pub async fn start_service() -> anyhow::Result<()> {
if !Uid::effective().is_root() {
bail!("Running not from root, exiting");
};
if service_status().await? {
bail!("zaprett already started")
}
println!("Starting zaprett service...");
let tmp_dir = MODULE_PATH.join("tmp");
if tmp_dir.exists() {
fs::remove_dir_all(&tmp_dir).await?;
fs::create_dir_all(&tmp_dir).await?;
}
let mut config_contents = String::new();
File::open(ZAPRETT_DIR_PATH.join("config.json"))
.await
.expect("cannot open config.json")
.read_to_string(&mut config_contents)
.await?;
let config: Config = serde_json::from_str(&config_contents).expect("invalid json");
let start = fs::read_to_string(config.strategy())
.await
.map(Cow::Owned)
.unwrap_or(Cow::Borrowed(DEFAULT_START));
let regex_hostlist = Regex::new(r"\$hostlist")?;
let regex_ipsets = Regex::new(r"\$ipset")?;
let regex_zaprettdir = Regex::new(r"\$\{?zaprettdir}?")?;
let mut strat_modified;
let (hosts, ipsets) = config.list_type().merge(&config).await;
strat_modified = regex_hostlist.replace_all(&start, &hosts).into_owned();
strat_modified = regex_ipsets
.replace_all(&strat_modified, &ipsets)
.into_owned();
strat_modified = regex_zaprettdir
.replace_all(&strat_modified, ZAPRETT_DIR_PATH.to_str().unwrap())
.into_owned();
let ctl = Ctl::new("net.netfilter.nf_conntrack_tcp_be_liberal")?;
ctl.set_value(CtlValue::String("1".into()))?;
setup_iptables_rules().expect("setup iptables rules");
daemonize_nfqws(&strat_modified).await;
println!("zaprett service started!");
Ok(())
}
pub async fn stop_service() -> anyhow::Result<()> {
if !Uid::effective().is_root() {
bail!("Running not from root, exiting");
};
if !service_status().await? {
bail!("zaprett service already stopped")
}
clear_iptables_rules().expect("clear iptables rules");
let pid_str = fs::read_to_string(MODULE_PATH.join("tmp/pid.lock")).await?;
let pid = pid_str.trim().parse::<i32>()?;
kill(Pid::from_raw(pid), Signal::SIGKILL)?;
println!("zaprett service stopped");
Ok(())
}
pub async fn restart_service() -> anyhow::Result<()> {
if !Uid::effective().is_root() {
bail!("Running not from root, exiting");
};
stop_service().await?;
start_service().await?;
info!("zaprett service restarted!");
Ok(())
}
pub async fn service_status() -> anyhow::Result<bool> {
if !Uid::effective().is_root() {
bail!("Running not from root, exiting");
};
let pid_i32 = match fs::read_to_string(Path::new(*MODULE_PATH).join("tmp/pid.lock")).await {
Ok(s) => match s.trim().parse::<i32>() {
Ok(pid) => pid,
Err(_) => return Ok(false),
},
Err(_) => return Ok(false),
};
let pid = SysPid::from(pid_i32 as usize);
let system = System::new_all();
if let Some(process) = system.process(pid) {
if process.name() == "zaprett" {
return Ok(true);
}
}
Ok(false)
}

109
rust/justfile Normal file
View File

@@ -0,0 +1,109 @@
set shell := ["bash", "-eu", "-c"]
export ANDROID_API := "21"
export ANDROID_NDK_VERSION := "r27d-linux"
TARGET := `pwd` + "/target"
export NETFILTER_LIBS := TARGET + "/netfilter"
export NDK_HOME := TARGET + "/android-ndk-" + ANDROID_NDK_VERSION
_download_android_ndk:
#!/usr/bin/env bash
if [ ! -d "{{NDK_HOME}}" ]; then
echo "Downloading ndk {{ANDROID_NDK_VERSION}} to {{NDK_HOME}}"
TMPFILE="{{NDK_HOME}}.tmp"
TMPDIR="{{NDK_HOME}}.extracted.tmp"
mkdir -p "$(dirname "$TMPFILE")"
curl -L -C - -o "$TMPFILE" "https://dl.google.com/android/repository/android-ndk-{{ANDROID_NDK_VERSION}}.zip"
unzip "$TMPFILE" -d "$TMPDIR"
inner_folder=$(find "$TMPDIR" -mindepth 1 -maxdepth 1 -type d | head -n 1)
mv -T "$inner_folder" "$NDK_HOME"
rm -rf "$TMPFILE" "$TMPDIR"
echo "Android ndk {{ANDROID_NDK_VERSION}} successfully installed in {{NDK_HOME}}"
else
echo "Android ndk {{ANDROID_NDK_VERSION}} already installed in {{NDK_HOME}}"
fi
_build_netfilter_libs target_arch:
#!/usr/bin/env bash
if [ ! -d "{{NETFILTER_LIBS}}-{{target_arch}}" ]; then
export PATCH="$(pwd)/libnetfilter_queue-android.patch"
cd "{{TARGET}}"
export TOOLCHAIN=$NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64
export CC="$TOOLCHAIN/bin/clang --target={{target_arch}}$ANDROID_API"
export AR=$TOOLCHAIN/bin/llvm-ar
export AS=$CC
export LD=$TOOLCHAIN/bin/ld
export RANLIB=$TOOLCHAIN/bin/llvm-ranlib
export STRIP=$TOOLCHAIN/bin/llvm-strip
export PKG_CONFIG_PATH=$NETFILTER_LIBS-{{target_arch}}/lib/pkgconfig
if [ ! -d "libnfnetlink-1.0.2" ]; then
wget -O- https://www.netfilter.org/pub/libnfnetlink/libnfnetlink-1.0.2.tar.bz2 | tar -xj
fi
if [ ! -d "libmnl-1.0.5" ]; then
wget -O- https://www.netfilter.org/pub/libmnl/libmnl-1.0.5.tar.bz2 | tar -xj
fi
if [ ! -d "libnetfilter_queue-1.0.5" ]; then
wget -O- https://www.netfilter.org/pub/libnetfilter_queue/libnetfilter_queue-1.0.5.tar.bz2 | tar -xj
patch -p1 -d libnetfilter_queue-* -i $PATCH
fi
for i in libmnl libnfnetlink libnetfilter_queue ; do
(
cd $i-*
make clean
CFLAGS="-Os -flto=auto -Wno-implicit-function-declaration" \
./configure --prefix= --host={{target_arch}} --enable-static --disable-shared --disable-dependency-tracking
make -j$(nproc)
make install DESTDIR=$NETFILTER_LIBS-{{target_arch}}
)
sed -i "s|^prefix=.*|prefix=$NETFILTER_LIBS-{{target_arch}}|g" $NETFILTER_LIBS-{{target_arch}}/lib/pkgconfig/$i.pc
done
else
echo "Netfilter libs for {{target_arch}} already built"
fi
_instal_rust_target target:
#!/usr/bin/env bash
if ! rustup target list --installed | grep -q "{{target}}"; then
echo "Installing missing target: {{target}}"
rustup target add "{{target}}"
else
echo "Target already installed: {{target}}"
fi
prepare-android: _download_android_ndk
#!/usr/bin/env bash
cargo install cargo-ndk
build-android *args: prepare-android
#!/usr/bin/env bash
targets=("armv7-linux-androideabi" "aarch64-linux-android" "x86_64-linux-android")
for i in "${!targets[@]}"; do
t=${targets[$i]}
(
echo "Building target $t"
export CFLAGS="-I$NETFILTER_LIBS-$t/include"
export LDFLAGS="-L$NETFILTER_LIBS-$t/lib"
export CXXFLAGS="$CFLAGS"
just _build_netfilter_libs $t
just _instal_rust_target $t
NETFILTER_LIBS=$NETFILTER_LIBS-$t cargo ndk -t $t --platform $ANDROID_API build {{args}}
)
done

View File

@@ -0,0 +1,41 @@
--- a/src/extra/pktbuff.c
+++ b/src/extra/pktbuff.c
@@ -14,7 +14,7 @@
#include <string.h> /* for memcpy */
#include <stdbool.h>
-#include <netinet/if_ether.h>
+#include <linux/if_ether.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
--- a/src/nlmsg.c
+++ b/src/nlmsg.c
@@ -21,7 +21,7 @@
#include <linux/netfilter/nfnetlink_queue.h>
-#include <libnetfilter_queue/libnetfilter_queue.h>
+// #include <libnetfilter_queue/libnetfilter_queue.h>
#include "internal.h"
--- a/src/extra/tcp.c
+++ b/src/extra/tcp.c
@@ -139,12 +139,16 @@ void nfq_tcp_compute_checksum_ipv6(struc
* (union is compatible to any of its members)
* This means this part of the code is -fstrict-aliasing safe now.
*/
+#ifndef __ANDROID__
union tcp_word_hdr {
struct tcphdr hdr;
uint32_t words[5];
};
+#endif
+#ifndef tcp_flag_word
#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words[3])
+#endif
/**
* nfq_pkt_snprintf_tcp_hdr - print tcp header into one buffer in a humnan

View File

@@ -7,7 +7,7 @@ ui_print " /___\__,_| .__/|_| \\___|\__|\__|"
ui_print " | | "
ui_print " |_| "
ui_print "(!) To download app, use Telegram channel"
ui_print "Module by: egor-white, Cherret, Huananzhi X99"
ui_print "Module by: egor-white, Cherret"
ui_print "App by: egor-white, Cherret"
ui_print "####################"
@@ -18,12 +18,20 @@ ui_print "Creating zaprett directory..."
mkdir /sdcard/zaprett; mkdir /sdcard/zaprett/lists; mkdir /sdcard/zaprett/bin; mkdir /sdcard/zaprett/strategies;
ui_print "Filling configuration file if not exist..."
if [ ! -f "/sdcard/zaprett/config" ]; then
echo active_lists=/storage/emulated/0/zaprett/lists/list-youtube.txt >> /sdcard/zaprett/config
echo active_exclude_lists= >> /sdcard/zaprett/config
echo list_type=whitelist
echo zaprettdir=/sdcard/zaprett >> /sdcard/zaprett/config
echo strategy="" >> /sdcard/zaprett/config
if [ ! -f "/sdcard/zaprett/config.json" ]; then
cat > /sdcard/zaprett/config.json << EOL
{
"active_lists": ["/sdcard/zaprett/lists/include/list-youtube.txt", "/sdcard/zaprett/lists/include/list-discord.txt"],
"active_ipsets": [],
"active_exclude_lists": [],
"active_exclude_ipsets": [],
"list_type": "whitelist",
"strategy": "",
"app_list": "whitelist",
"whitelist": [],
"blacklist": []
}
EOL
fi
ui_print "Copying lists and binaries to /sdcard/zaprett..."
@@ -33,30 +41,21 @@ ui_print "Copying files to /bin"
arch=$(uname -m)
case "$arch" in
"x86_64")
nfqws="nfqws_x86_64"
;;
"i386"|"i686")
nfqws="nfqws_x86"
zaprett_bin="zaprett-x86_64"
;;
"armv7l"|"arm")
nfqws="nfqws_arm32"
zaprett_bin="zaprett-armv7"
;;
"aarch64"|"armv8l")
nfqws="nfqws_arm64"
;;
"mips")
nfqws="nfqws_mips"
;;
"mipsel")
nfqws="nfqws_mipsel"
zaprett_bin="zaprett-aarch64"
;;
*)
ui_print "Unknown arch: $arch"
abort
;;
esac
mv $MODPATH/system/bin/$nfqws $MODPATH/system/bin/nfqws
rm $MODPATH/system/bin/nfqws_*
mv $MODPATH/system/bin/$zaprett_bin $MODPATH/system/bin/zaprett
rm $MODPATH/system/bin/zaprett-*
mkdir $MODPATH/tmp
ui_print "Setting permissions..."
@@ -65,4 +64,4 @@ chmod 777 /sdcard/zaprett; chmod 777 $MODPATH/service.sh
ui_print "Cleaning temp files..."
rm -rf $MODPATH/system/etc/zaprett
ui_print "Installation done. Telegram channel: https://t.me/zaprett_module"
ui_print "Installation done. Join us in Telegram: https://t.me/zaprett_module"

View File

@@ -1,9 +1,9 @@
#!/system/bin/sh
while [ -z "$(getprop sys.boot_completed)" ]; do sleep 2; done
su -c "zaprett start"
while true; do
sleep 3600
if [ -f "/data/adb/modules/zaprett/autostart" ]; then
su -c "zaprett restart"
fi
done
if [ -f "/data/adb/modules/zaprett/autostart" ]; then
su -c "zaprett start"
while true; do
sleep 3600
su -c "zaprett restart"
done
fi

View File

@@ -1,150 +0,0 @@
#!/system/bin/sh
source /sdcard/zaprett/config
clear_iptables_rules() {
iptables -t mangle -D POSTROUTING -j NFQUEUE --queue-num 200 --queue-bypass 2>/dev/null
iptables -t mangle -D PREROUTING -j NFQUEUE --queue-num 200 --queue-bypass 2>/dev/null
iptables -t filter -D FORWARD -j NFQUEUE --queue-num 200 --queue-bypass 2>/dev/null
}
start_service() {
rm -f /data/adb/modules/zaprett/tmp/*
echo "Starting zaprett..."
hostlist=""
ipset=""
case "$list_type" in
whitelist)
lists="$active_lists"
ipsets="$active_ipsets"
opt="--hostlist"
ipopt="--ipset"
;;
blacklist)
lists="$active_exclude_lists"
ipsets="$active_exclude_ipsets"
opt="--hostlist-exclude"
ipopt="--ipset-exclude"
;;
*)
echo "Unknown list-type: $list_type" >&2
lists=""
ipsets=""
opt=""
ipopt=""
;;
esac
if [ -n "$lists" ] && [ -n "$opt" ]; then
for itm in $(echo "$lists" | tr ',' ' ' | sort -u); do
if [ -f "$itm" ]; then
dst="/data/adb/modules/zaprett/tmp/$(basename "$itm")"
cp "$itm" "$dst"
case "$hostlist" in
*"$opt=$dst"*) ;;
*) hostlist="$hostlist $opt=$dst" ;;
esac
fi
done
fi
if [ -n "$ipsets" ] && [ -n "$ipopt" ]; then
for ipt in $(echo "$ipsets" | tr ',' ' ' | sort -u); do
if [ -f "$ipt" ]; then
dst="/data/adb/modules/zaprett/tmp/$(basename "$ipt")"
cp "$ipt" "$dst"
case "$ipset" in
*"$ipopt=$dst"*) ;;
*) ipset="$ipset $ipopt=$dst" ;;
esac
fi
done
fi
config=""
if [[ -n "$strategy" && -f "$strategy" ]]; then
config="$(eval "echo \"$(<"$strategy")\"")"
fi
if [[ -z "$config" ]]; then
config="--filter-tcp=80 --dpi-desync=fake,split2 --dpi-desync-autottl=2 --dpi-desync-fooling=md5sig,badsum $hostlist --new"
config="$config --filter-tcp=443 $hostlist --dpi-desync=fake,split2 --dpi-desync-repeats=6 --dpi-desync-fooling=md5sig,badsum --dpi-desync-fake-tls=${zaprettdir}/bin/tls_clienthello_www_google_com.bin --new"
config="$config --filter-tcp=80,443 --dpi-desync=fake,disorder2 --dpi-desync-repeats=6 --dpi-desync-autottl=2 --dpi-desync-fooling=md5sig,badsum $hostlist --new"
config="$config --filter-udp=50000-50100 --dpi-desync=fake --dpi-desync-any-protocol --dpi-desync-fake-quic=0xC30000000108 --new"
config="$config --filter-udp=443 $hostlist --dpi-desync=fake --dpi-desync-repeats=6 --dpi-desync-fake-quic=${zaprettdir}/bin/quic_initial_www_google_com.bin --new"
config="$config --filter-udp=443 --dpi-desync=fake --dpi-desync-repeats=6 $hostlist"
fi
sysctl net.netfilter.nf_conntrack_tcp_be_liberal=1 > /dev/null
iptables -t mangle -I POSTROUTING -j NFQUEUE --queue-num 200 --queue-bypass
iptables -t mangle -I PREROUTING -j NFQUEUE --queue-num 200 --queue-bypass
iptables -t filter -A FORWARD -j NFQUEUE --queue-num 200 --queue-bypass
nfqws --uid=0:0 --qnum=200 $config > /dev/null &
echo "zaprett service started!"
}
stop_service() {
echo "Stopping zaprett..."
clear_iptables_rules
kill "$(pidof nfqws)" 2>/dev/null
rm -f /data/adb/modules/zaprett/tmp/*
echo "zaprett service stopped!"
}
if [ "$1" == "start" ]; then
start_service
fi
if [ "$1" == "stop" ]; then
stop_service
fi
if [ "$1" == "status" ]; then
pidof "nfqws" > /dev/null && echo "zaprett is working" || echo "zaprett is stopped"
fi
if [ "$1" == "restart" ]; then
stop_service
start_service
echo "zaprett service restarted!"
fi
if [ "$1" == "help" ]; then
echo -e "Помощь по модулю zaprett:\nzaprett start - запуск сервиса\nzaprett stop - остановка сервиса\nzaprett restart - перезапуск сервиса\nzaprett status - статус сервиса\nzaprett module-ver - версия модуля\nzaprett bin-ver - версия бинарных файлов\nzaprett autostart - переключение автозапуска модуля\nzaprett get-autostart - получить активен ли автозапуск"
fi
if [ "$1" == "module-ver" ]; then
grep 'version=' /data/adb/modules/zaprett/module.prop | sed 's/version=//'
fi
if [ "$1" == "bin-ver" ]; then
nfqws --version | grep -o 'version v[0-9.]*' | head -n1 | cut -d' ' -f2
fi
if [ "$1" == "autostart" ]; then
FILE="/data/adb/modules/zaprett/autostart"
if [ -f "$FILE" ]; then
rm "$FILE"
echo "false"
else
touch "$FILE"
echo "true"
fi
fi
if [ "$1" == "get-autostart" ]; then
FILE="/data/adb/modules/zaprett/autostart"
if [ -f "$FILE" ]; then
echo "true"
else
echo "false"
fi
fi
if [[ -z $1 ]]; then
echo "zaprett installed. Telegram: t.me/zaprett_module"
fi

View File

@@ -1,6 +1,6 @@
{
"version": "5.1",
"versionCode": 51,
"zipUrl": "https://github.com/egor-white/zaprett/releases/download/5.1.0/zaprett-hosts.zip",
"version": "5.2",
"versionCode": 52,
"zipUrl": "https://github.com/egor-white/zaprett/releases/download/5.2.0/zaprett-hosts.zip",
"changelog": "https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/changelog.md"
}

View File

@@ -1,6 +1,6 @@
{
"version": "5.1",
"versionCode": 51,
"zipUrl": "https://github.com/egor-white/zaprett/releases/download/5.1.0/zaprett-tv.zip",
"version": "5.2",
"versionCode": 52,
"zipUrl": "https://github.com/egor-white/zaprett/releases/download/5.2.0/zaprett-tv.zip",
"changelog": "https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/changelog.md"
}

View File

@@ -1,6 +1,6 @@
{
"version": "5.1",
"versionCode": 51,
"zipUrl": "https://github.com/egor-white/zaprett/releases/download/5.1.0/zaprett.zip",
"version": "5.2",
"versionCode": 52,
"zipUrl": "https://github.com/egor-white/zaprett/releases/download/5.2.0/zaprett.zip",
"changelog": "https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/changelog.md"
}