mirror of
https://github.com/egor-white/zaprett.git
synced 2025-12-10 05:19:42 +05:00
fix
This commit is contained in:
97
.github/workflows/workflow.yml
vendored
97
.github/workflows/workflow.yml
vendored
@@ -3,69 +3,64 @@ name: Build module
|
|||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
|
create_release:
|
||||||
|
description: 'Create GitHub release?'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
tag:
|
tag:
|
||||||
description: 'Tag for the release (x.x.x)'
|
description: "Tag for the release (x.x.x)"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
zapret-version:
|
||||||
|
description: "Zapret version (x.x)"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
version:
|
version:
|
||||||
description: 'Module version (x.x)'
|
description: "Module version (x.x)"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
version_code:
|
version_code:
|
||||||
description: 'Module version code (xx)'
|
description: "Module version code (xx)"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
release_name:
|
release_name:
|
||||||
description: 'Release Name'
|
description: "Release Name"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
release_changes:
|
release_changes:
|
||||||
description: 'Release Changes'
|
description: "Release Changes"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
ZAPRET_VERSION: ${{ inputs.zapret-version }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- 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
|
- 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
|
run: mkdir -p zaprett/system/bin zaprett-hosts/system/bin zaprett/system/etc/zaprett/lists out lists zapret-hosts/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
|
|
||||||
|
|
||||||
- name: Copy files to dirs
|
- name: Copy files to dirs
|
||||||
run: |
|
run: |
|
||||||
#copy nfqws and zaprett
|
cp rust/target/armv7-linux-androideabi/release/zaprett zaprett/system/bin/zaprett-armv7
|
||||||
cp zapret-latest/binaries/android-arm/nfqws zaprett/system/bin/nfqws_arm32
|
cp rust/target/aarch64-linux-android/release/zaprett zaprett/system/bin/zaprett-aarch64
|
||||||
cp zapret-latest/binaries/android-arm64/nfqws zaprett/system/bin/nfqws_arm64
|
cp rust/target/x86_64-linux-android/release/zaprett zaprett/system/bin/zaprett-x86_64
|
||||||
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 -a src/* zaprett/
|
cp -a src/* zaprett/
|
||||||
|
|
||||||
#copy all files to another distributions
|
|
||||||
cp -r zaprett/* zaprett-hosts/
|
cp -r zaprett/* zaprett-hosts/
|
||||||
cp -r zaprett/* zaprett-tv/
|
|
||||||
- name: Download and copy actual lists
|
- name: Download and copy actual lists
|
||||||
run: |
|
run: |
|
||||||
wget https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/lists/include/list-youtube.txt -O lists/list-youtube.txt
|
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/system/etc/zaprett/lists/
|
||||||
cp lists/list-youtube.txt zaprett-hosts/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/system/etc/zaprett/lists/
|
||||||
cp lists/list-discord.txt zaprett-hosts/system/etc/zaprett/lists/
|
cp lists/list-discord.txt zaprett-hosts/system/etc/zaprett/lists/
|
||||||
@@ -102,16 +96,6 @@ jobs:
|
|||||||
updateJson=https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/update-hosts.json
|
updateJson=https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/update-hosts.json
|
||||||
EOF
|
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
|
- name: Tree files
|
||||||
run: |
|
run: |
|
||||||
tree zaprett/ zaprett-hosts/ zaprett-tv/
|
tree zaprett/ zaprett-hosts/ zaprett-tv/
|
||||||
@@ -119,13 +103,12 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd zaprett && zip -r ../zaprett.zip ./* && cd ..
|
cd zaprett && zip -r ../zaprett.zip ./* && cd ..
|
||||||
cd zaprett-hosts && zip -r ../zaprett-hosts.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.zip out/
|
||||||
mv zaprett-hosts.zip out/
|
mv zaprett-hosts.zip out/
|
||||||
mv zaprett-tv.zip out/
|
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
|
if: ${{ inputs.create_release == 'true' }}
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ inputs.tag }}
|
tag_name: ${{ inputs.tag }}
|
||||||
@@ -134,10 +117,22 @@ jobs:
|
|||||||
files: out/*
|
files: out/*
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
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
|
- name: Update changelog
|
||||||
|
if: ${{ inputs.create_release == 'true' }}
|
||||||
run: echo "${{ inputs.release_changes }}" > changelog.md
|
run: echo "${{ inputs.release_changes }}" > changelog.md
|
||||||
|
|
||||||
- name: Update update.json
|
- name: Update update.json
|
||||||
|
if: ${{ inputs.create_release == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
cat > update.json <<EOF
|
cat > update.json <<EOF
|
||||||
{
|
{
|
||||||
@@ -155,6 +150,7 @@ jobs:
|
|||||||
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
|
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
<<<<<<< HEAD
|
||||||
cat > update-tv.json <<EOF
|
cat > update-tv.json <<EOF
|
||||||
{
|
{
|
||||||
"version": "${{ inputs.version }}",
|
"version": "${{ inputs.version }}",
|
||||||
@@ -163,12 +159,14 @@ jobs:
|
|||||||
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
|
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
=======
|
||||||
|
>>>>>>> origin/rust
|
||||||
- name: Commit jsons and changelog
|
- name: Commit jsons and changelog
|
||||||
|
if: ${{ inputs.create_release == 'true' }}
|
||||||
uses: stefanzweifel/git-auto-commit-action@v5
|
uses: stefanzweifel/git-auto-commit-action@v5
|
||||||
with:
|
with:
|
||||||
commit_message: "Update update's.json and changelog"
|
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
|
- name: Send bot post
|
||||||
env:
|
env:
|
||||||
MESSAGE_TEXT: |
|
MESSAGE_TEXT: |
|
||||||
@@ -185,4 +183,3 @@ jobs:
|
|||||||
-d parse_mode=HTML \
|
-d parse_mode=HTML \
|
||||||
-d disable_web_page_preview=true \
|
-d disable_web_page_preview=true \
|
||||||
--data-urlencode "text=$MESSAGE_TEXT"
|
--data-urlencode "text=$MESSAGE_TEXT"
|
||||||
|
|
||||||
|
|||||||
110
.github/workflows/workflow_without_post.yml
vendored
110
.github/workflows/workflow_without_post.yml
vendored
@@ -1,79 +1,74 @@
|
|||||||
name: Build module (Without telegram post)
|
name: Build module
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
|
create_release:
|
||||||
|
description: 'Create GitHub release?'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
tag:
|
tag:
|
||||||
description: 'Tag for the release (x.x.x)'
|
description: "Tag for the release (x.x.x)"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
zapret-version:
|
||||||
|
description: "Zapret version (x.x)"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
version:
|
version:
|
||||||
description: 'Module version (x.x)'
|
description: "Module version (x.x)"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
version_code:
|
version_code:
|
||||||
description: 'Module version code (xx)'
|
description: "Module version code (xx)"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
release_name:
|
release_name:
|
||||||
description: 'Release Name'
|
description: "Release Name"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
release_changes:
|
release_changes:
|
||||||
description: 'Release Changes'
|
description: "Release Changes"
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
ZAPRET_VERSION: ${{ inputs.zapret-version }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- 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
|
- 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
|
run: mkdir -p zaprett/system/bin zaprett-hosts/system/bin zaprett/system/etc/zaprett/lists out lists zapret-hosts/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
|
|
||||||
|
|
||||||
- name: Copy files to dirs
|
- name: Copy files to dirs
|
||||||
run: |
|
run: |
|
||||||
#copy nfqws and zaprett
|
#copy nfqws and zaprett
|
||||||
cp zapret-latest/binaries/android-arm/nfqws zaprett/system/bin/nfqws_arm32
|
cp rust/target/armv7-linux-androideabi/release/zaprett zaprett/system/bin/zaprett-armv7
|
||||||
cp zapret-latest/binaries/android-arm64/nfqws zaprett/system/bin/nfqws_arm64
|
cp rust/target/aarch64-linux-android/release/zaprett zaprett/system/bin/zaprett-aarch64
|
||||||
cp zapret-latest/binaries/android-x86/nfqws zaprett/system/bin/nfqws_x86
|
cp rust/target/x86_64-linux-android/release/zaprett zaprett/system/bin/zaprett-x86_64
|
||||||
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 -a src/* zaprett/
|
cp -a src/* zaprett/
|
||||||
|
|
||||||
#copy all files to another distributions
|
|
||||||
cp -r zaprett/* zaprett-hosts/
|
cp -r zaprett/* zaprett-hosts/
|
||||||
cp -r zaprett/* zaprett-tv/
|
|
||||||
- name: Download and copy actual lists
|
- name: Download and copy actual lists
|
||||||
run: |
|
run: |
|
||||||
wget https://raw.githubusercontent.com/CherretGit/zaprett-hosts-repo/refs/heads/main/lists/list-youtube.txt -O lists/list-youtube.txt
|
wget https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/lists/include/list-youtube.txt -O lists/list-youtube.txt
|
||||||
wget https://raw.githubusercontent.com/CherretGit/zaprett-hosts-repo/refs/heads/main/lists/list-discord.txt -O lists/list-discord.txt
|
wget https://raw.githubusercontent.com/CherretGit/zaprett-repo/refs/heads/main/lists/include/list-discord.txt -O lists/list-discord.txt
|
||||||
|
|
||||||
cp lists/list-youtube.txt zaprett/system/etc/zaprett/lists/
|
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-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/system/etc/zaprett/lists/
|
||||||
cp lists/list-discord.txt zaprett-hosts/system/etc/zaprett/lists/
|
cp lists/list-discord.txt zaprett-hosts/system/etc/zaprett/lists/
|
||||||
@@ -87,7 +82,7 @@ jobs:
|
|||||||
name=zaprett
|
name=zaprett
|
||||||
version=${{ inputs.version }}
|
version=${{ inputs.version }}
|
||||||
versionCode=${{ inputs.version_code }}
|
versionCode=${{ inputs.version_code }}
|
||||||
author=egor-white, Huananzhi X99, Cherret
|
author=egor-white, Cherret
|
||||||
description=Ускорение CDN серверов Google. ТГК: https://t.me/zaprett_module
|
description=Ускорение CDN серверов Google. ТГК: https://t.me/zaprett_module
|
||||||
updateJson=https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/update.json
|
updateJson=https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/update.json
|
||||||
EOF
|
EOF
|
||||||
@@ -97,21 +92,11 @@ jobs:
|
|||||||
name=zaprett-hosts
|
name=zaprett-hosts
|
||||||
version=${{ inputs.version }}
|
version=${{ inputs.version }}
|
||||||
versionCode=${{ inputs.version_code }}
|
versionCode=${{ inputs.version_code }}
|
||||||
author=egor-white, Huananzhi X99, Cherret
|
author=egor-white, Cherret
|
||||||
description=Ускорение CDN серверов Google. ТГК: https://t.me/zaprett_module
|
description=Ускорение CDN серверов Google. ТГК: https://t.me/zaprett_module
|
||||||
updateJson=https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/update-hosts.json
|
updateJson=https://raw.githubusercontent.com/egor-white/zaprett/refs/heads/main/update-hosts.json
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat > zaprett-tv/module.prop <<EOF
|
|
||||||
id=zaprett
|
|
||||||
name=zaprett-tv
|
|
||||||
version=${{ inputs.version }}
|
|
||||||
versionCode=${{ inputs.version_code }}
|
|
||||||
author=egor-white, Huananzhi X99, 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
|
- name: Tree files
|
||||||
run: |
|
run: |
|
||||||
tree zaprett/ zaprett-hosts/ zaprett-tv/
|
tree zaprett/ zaprett-hosts/ zaprett-tv/
|
||||||
@@ -119,13 +104,12 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd zaprett && zip -r ../zaprett.zip ./* && cd ..
|
cd zaprett && zip -r ../zaprett.zip ./* && cd ..
|
||||||
cd zaprett-hosts && zip -r ../zaprett-hosts.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.zip out/
|
||||||
mv zaprett-hosts.zip out/
|
mv zaprett-hosts.zip out/
|
||||||
mv zaprett-tv.zip out/
|
|
||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
|
if: ${{ inputs.create_release == 'true' }}
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ inputs.tag }}
|
tag_name: ${{ inputs.tag }}
|
||||||
@@ -134,10 +118,22 @@ jobs:
|
|||||||
files: out/*
|
files: out/*
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
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
|
- name: Update changelog
|
||||||
|
if: ${{ inputs.create_release == 'true' }}
|
||||||
run: echo "${{ inputs.release_changes }}" > changelog.md
|
run: echo "${{ inputs.release_changes }}" > changelog.md
|
||||||
|
|
||||||
- name: Update update.json
|
- name: Update update.json
|
||||||
|
if: ${{ inputs.create_release == 'true' }}
|
||||||
run: |
|
run: |
|
||||||
cat > update.json <<EOF
|
cat > update.json <<EOF
|
||||||
{
|
{
|
||||||
@@ -155,16 +151,10 @@ jobs:
|
|||||||
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
|
"changelog": "https://raw.githubusercontent.com/${{ github.repository }}/refs/heads/main/changelog.md"
|
||||||
}
|
}
|
||||||
EOF
|
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
|
- name: Commit jsons and changelog
|
||||||
|
if: ${{ inputs.create_release == 'true' }}
|
||||||
uses: stefanzweifel/git-auto-commit-action@v5
|
uses: stefanzweifel/git-auto-commit-action@v5
|
||||||
with:
|
with:
|
||||||
commit_message: "Update update's.json and changelog"
|
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"
|
||||||
|
|
||||||
|
|||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
target
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "rust/crates/libnfqws/zapret"]
|
||||||
|
path = rust/crates/libnfqws/zapret
|
||||||
|
url = https://github.com/bol-van/zapret.git
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
Обновление бинарников zapret до версии 72.2
|
Обновление бинарников zapret до версии 72.2
|
||||||
Обновление hosts файла в zaprett hosts
|
Обновление hosts файла в zaprett hosts
|
||||||
|
|
||||||
|
|||||||
1142
rust/Cargo.lock
generated
Normal file
1142
rust/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
27
rust/Cargo.toml
Normal file
27
rust/Cargo.toml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
[workspace.package]
|
||||||
|
version = "0.0.1"
|
||||||
|
edition = "2024"
|
||||||
|
repository = "https://github.com/egor-white/zaprett"
|
||||||
|
|
||||||
|
[workspace]
|
||||||
|
members = ["crates/*"]
|
||||||
|
resolver = "3"
|
||||||
|
|
||||||
|
[workspace.dependencies]
|
||||||
|
anyhow = "1.0.100"
|
||||||
|
clap = { version = "4.5.50", features = ["derive"] }
|
||||||
|
libc = "0.2.177"
|
||||||
|
regex = "1.12.2"
|
||||||
|
rust-ini = "0.21.3"
|
||||||
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
|
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"] }
|
||||||
|
iptables = { git = "https://github.com/sqlerrorthing/rust-iptables.git", branch = "feat/add-android" }
|
||||||
|
getset = "0.1.6"
|
||||||
|
sysinfo = "0.37.2"
|
||||||
11
rust/crates/libnfqws/Cargo.toml
Normal file
11
rust/crates/libnfqws/Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[package]
|
||||||
|
name = "libnfqws"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
cc = "1.2.43"
|
||||||
|
once_cell = "1.21.3"
|
||||||
|
glob = "0.3.3"
|
||||||
|
bindgen = "0.72.1"
|
||||||
68
rust/crates/libnfqws/build.rs
Normal file
68
rust/crates/libnfqws/build.rs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
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");
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
cc::Build::new()
|
||||||
|
.files(
|
||||||
|
glob::glob(&format!("{}/*.c", NFQ.display()))
|
||||||
|
.unwrap()
|
||||||
|
.filter_map(Result::ok),
|
||||||
|
)
|
||||||
|
.files(
|
||||||
|
glob::glob(&format!("{}/*.c", NFQ_CRYPTO.display()))
|
||||||
|
.unwrap()
|
||||||
|
.filter_map(Result::ok),
|
||||||
|
)
|
||||||
|
.include(&*NFQ)
|
||||||
|
.include(&*NFQ_CRYPTO)
|
||||||
|
.flag("-w")
|
||||||
|
.define("main", "nfqws_main")
|
||||||
|
.compile("libnfqws.a");
|
||||||
|
|
||||||
|
println!("cargo:rustc-link-lib=z");
|
||||||
|
println!("cargo:rustc-link-lib=netfilter_queue");
|
||||||
|
println!("cargo:rustc-link-lib=nfnetlink");
|
||||||
|
println!("cargo:rustc-link-lib=mnl");
|
||||||
|
|
||||||
|
let _ = env::var("NETFILTER_LIBS")
|
||||||
|
.map(|libs| println!("cargo:rustc-link-search=native={libs}/lib"));
|
||||||
|
|
||||||
|
println!("cargo:rustc-link-lib=static=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();
|
||||||
|
|
||||||
|
for header in glob::glob(&format!("{}/*.h", NFQ.display()))
|
||||||
|
.unwrap()
|
||||||
|
.filter_map(Result::ok)
|
||||||
|
{
|
||||||
|
builder = builder.header(header.to_string_lossy());
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.clang_arg("-Dmain=nfqws_main");
|
||||||
|
|
||||||
|
let bindings = builder
|
||||||
|
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
|
||||||
|
.generate()
|
||||||
|
.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");
|
||||||
|
}
|
||||||
2
rust/crates/libnfqws/src/lib.rs
Normal file
2
rust/crates/libnfqws/src/lib.rs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#![allow(warnings)]
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/libnfqws.rs"));
|
||||||
1
rust/crates/libnfqws/zapret
Submodule
1
rust/crates/libnfqws/zapret
Submodule
Submodule rust/crates/libnfqws/zapret added at 1408c38522
24
rust/crates/zaprett/Cargo.toml
Normal file
24
rust/crates/zaprett/Cargo.toml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
[package]
|
||||||
|
name = "zaprett"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow = { workspace = true }
|
||||||
|
clap = { workspace = true }
|
||||||
|
libc = { workspace = true }
|
||||||
|
regex = { workspace = true }
|
||||||
|
rust-ini = { workspace = true }
|
||||||
|
serde = { workspace = true }
|
||||||
|
serde_json = { workspace = true }
|
||||||
|
sysctl ={ workspace = true }
|
||||||
|
tokio = { workspace = true }
|
||||||
|
libnfqws = { path = "../libnfqws" }
|
||||||
|
daemonize = { workspace = true }
|
||||||
|
pretty_env_logger = { workspace = true }
|
||||||
|
log = { workspace = true }
|
||||||
|
nix = { workspace = true, features = ["user"] }
|
||||||
|
iptables = { workspace = true }
|
||||||
|
getset = { workspace = true }
|
||||||
|
sysinfo = { workspace = true }
|
||||||
5
rust/crates/zaprett/build.rs
Normal file
5
rust/crates/zaprett/build.rs
Normal 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);
|
||||||
|
}
|
||||||
13
rust/crates/zaprett/src/cli.rs
Normal file
13
rust/crates/zaprett/src/cli.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
pub mod commands;
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
|
use getset::Getters;
|
||||||
|
use commands::Command;
|
||||||
|
|
||||||
|
#[derive(Parser, Getters)]
|
||||||
|
#[command(version)]
|
||||||
|
#[getset(get = "pub")]
|
||||||
|
pub struct CliApp {
|
||||||
|
#[command(subcommand)]
|
||||||
|
cmd: Option<Command>,
|
||||||
|
}
|
||||||
67
rust/crates/zaprett/src/cli/commands.rs
Normal file
67
rust/crates/zaprett/src/cli/commands.rs
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
use crate::service::{restart_service, service_status, start_service, stop_service};
|
||||||
|
use crate::{bin_version, get_autostart, module_version, set_autostart};
|
||||||
|
use clap::Subcommand;
|
||||||
|
use log::error;
|
||||||
|
|
||||||
|
#[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 => module_version(),
|
||||||
|
Command::BinaryVersion => bin_version(),
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
92
rust/crates/zaprett/src/config.rs
Normal file
92
rust/crates/zaprett/src/config.rs
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
use crate::{MODULE_PATH, merge_files};
|
||||||
|
use getset::Getters;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(rename_all = "lowercase")]
|
||||||
|
pub enum ListType {
|
||||||
|
Whitelist,
|
||||||
|
Blacklist,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ListType {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Whitelist
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Getters)]
|
||||||
|
#[getset(get = "pub")]
|
||||||
|
pub struct Config {
|
||||||
|
#[serde(default)]
|
||||||
|
active_lists: Vec<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
active_ipsets: Vec<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
active_exclude_lists: Vec<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
active_exclude_ipsets: Vec<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
list_type: ListType,
|
||||||
|
#[serde(default)]
|
||||||
|
strategy: String,
|
||||||
|
#[serde(default)]
|
||||||
|
app_list: String,
|
||||||
|
#[serde(default)]
|
||||||
|
whitelist: Vec<String>,
|
||||||
|
#[serde(default)]
|
||||||
|
blacklist: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Config {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
active_lists: vec![],
|
||||||
|
active_ipsets: vec![],
|
||||||
|
active_exclude_lists: vec![],
|
||||||
|
active_exclude_ipsets: vec![],
|
||||||
|
list_type: Default::default(),
|
||||||
|
strategy: String::new(),
|
||||||
|
app_list: String::new(),
|
||||||
|
whitelist: vec![],
|
||||||
|
blacklist: vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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}"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
26
rust/crates/zaprett/src/daemon.rs
Normal file
26
rust/crates/zaprett/src/daemon.rs
Normal 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}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
51
rust/crates/zaprett/src/iptables_rust.rs
Normal file
51
rust/crates/zaprett/src/iptables_rust.rs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
use std::error;
|
||||||
|
|
||||||
|
pub fn setup_iptables_rules() -> Result<(), Box<dyn error::Error>> {
|
||||||
|
let ipt = iptables::new(false)?;
|
||||||
|
|
||||||
|
ipt.insert(
|
||||||
|
"mangle",
|
||||||
|
"POSTROUTING",
|
||||||
|
"-j NFQUEUE --queue-num 200 --queue-bypass",
|
||||||
|
1,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
ipt.insert(
|
||||||
|
"mangle",
|
||||||
|
"PREROUTING",
|
||||||
|
"-j NFQUEUE --queue-num 200 --queue-bypass",
|
||||||
|
1,
|
||||||
|
)?;
|
||||||
|
|
||||||
|
ipt.append(
|
||||||
|
"filter",
|
||||||
|
"FORWARD",
|
||||||
|
"-j NFQUEUE --queue-num 200 --queue-bypass",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clear_iptables_rules() -> Result<(), Box<dyn error::Error>> {
|
||||||
|
let ipt = iptables::new(false)?;
|
||||||
|
|
||||||
|
ipt.delete(
|
||||||
|
"mangle",
|
||||||
|
"POSTROUTING",
|
||||||
|
"-j NFQUEUE --queue-num 200 --queue-bypass",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
ipt.delete(
|
||||||
|
"mangle",
|
||||||
|
"PREROUTING",
|
||||||
|
"-j NFQUEUE --queue-num 200 --queue-bypass",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
ipt.delete(
|
||||||
|
"filter",
|
||||||
|
"FORWARD",
|
||||||
|
"-j NFQUEUE --queue-num 200 --queue-bypass",
|
||||||
|
)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
111
rust/crates/zaprett/src/lib.rs
Normal file
111
rust/crates/zaprett/src/lib.rs
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
pub mod cli;
|
||||||
|
pub mod config;
|
||||||
|
mod daemon;
|
||||||
|
pub mod iptables_rust;
|
||||||
|
mod service;
|
||||||
|
|
||||||
|
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 tokio::fs;
|
||||||
|
use tokio::fs::File;
|
||||||
|
use tokio::io::{AsyncWriteExt, copy};
|
||||||
|
|
||||||
|
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 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(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_autostart() {
|
||||||
|
let file = MODULE_PATH.join("autostart");
|
||||||
|
println!("{}", file.exists());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn module_version() {
|
||||||
|
if let Ok(prop) = Ini::load_from_file(MODULE_PATH.join("module.prop"))
|
||||||
|
&& let Some(props) = prop.section::<String>(None)
|
||||||
|
&& let Some(version) = props.get("version")
|
||||||
|
{
|
||||||
|
println!("{version}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn bin_version() {
|
||||||
|
println!("{}", 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_path = input.as_ref();
|
||||||
|
let mut input_file = File::open(input_path)
|
||||||
|
.await
|
||||||
|
.map_err(|e| format!("Failed to open {}: {}", input_path.display(), e))?;
|
||||||
|
|
||||||
|
copy(&mut input_file, &mut output_file).await.map_err(|e| {
|
||||||
|
format!(
|
||||||
|
"Failed to write contents of {}: {}",
|
||||||
|
input_path.display(),
|
||||||
|
e
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
}
|
||||||
|
|
||||||
|
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(())
|
||||||
|
}
|
||||||
15
rust/crates/zaprett/src/main.rs
Normal file
15
rust/crates/zaprett/src/main.rs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
use clap::Parser;
|
||||||
|
use zaprett::cli::CliApp;
|
||||||
|
|
||||||
|
#[tokio::main]
|
||||||
|
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"),
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
124
rust/crates/zaprett/src/service.rs
Normal file
124
rust/crates/zaprett/src/service.rs
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
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 std::path::Path;
|
||||||
|
use sysctl::Sysctl;
|
||||||
|
use sysinfo::{Pid as SysPid, System};
|
||||||
|
use tokio::fs;
|
||||||
|
use tokio::fs::File;
|
||||||
|
use tokio::io::AsyncReadExt;
|
||||||
|
|
||||||
|
pub async fn start_service() -> anyhow::Result<()> {
|
||||||
|
if !Uid::effective().is_root() {
|
||||||
|
bail!("Running not from root, exiting");
|
||||||
|
};
|
||||||
|
|
||||||
|
if service_status().await.unwrap() {
|
||||||
|
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 = sysctl::Ctl::new("net.netfilter.nf_conntrack_tcp_be_liberal")?;
|
||||||
|
ctl.set_value(sysctl::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.unwrap() {
|
||||||
|
bail!("zaprett service alreeady 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)?;
|
||||||
|
|
||||||
|
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
109
rust/justfile
Normal 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
|
||||||
41
rust/libnetfilter_queue-android.patch
Normal file
41
rust/libnetfilter_queue-android.patch
Normal 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
|
||||||
@@ -7,7 +7,7 @@ ui_print " /___\__,_| .__/|_| \\___|\__|\__|"
|
|||||||
ui_print " | | "
|
ui_print " | | "
|
||||||
ui_print " |_| "
|
ui_print " |_| "
|
||||||
ui_print "(!) To download app, use Telegram channel"
|
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 "App by: egor-white, Cherret"
|
||||||
ui_print "####################"
|
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;
|
mkdir /sdcard/zaprett; mkdir /sdcard/zaprett/lists; mkdir /sdcard/zaprett/bin; mkdir /sdcard/zaprett/strategies;
|
||||||
|
|
||||||
ui_print "Filling configuration file if not exist..."
|
ui_print "Filling configuration file if not exist..."
|
||||||
if [ ! -f "/sdcard/zaprett/config" ]; then
|
if [ ! -f "/sdcard/zaprett/config.json" ]; then
|
||||||
echo active_lists=/storage/emulated/0/zaprett/lists/list-youtube.txt >> /sdcard/zaprett/config
|
cat > /sdcard/zaprett/config.json << EOL
|
||||||
echo active_exclude_lists= >> /sdcard/zaprett/config
|
{
|
||||||
echo list_type=whitelist
|
"active_lists": ["/sdcard/zaprett/lists/include/list-youtube.txt", "/sdcard/zaprett/lists/include/list-youtube.txt"],
|
||||||
echo zaprettdir=/sdcard/zaprett >> /sdcard/zaprett/config
|
"active_ipsets": [],
|
||||||
echo strategy="" >> /sdcard/zaprett/config
|
"active_exclude_lists": [],
|
||||||
|
"active_exclude_ipsets": [],
|
||||||
|
"list_type": "whitelist",
|
||||||
|
"strategy": "",
|
||||||
|
"app_list": "whitelist",
|
||||||
|
"whitelist": [],
|
||||||
|
"blacklist": []
|
||||||
|
}
|
||||||
|
EOL
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ui_print "Copying lists and binaries to /sdcard/zaprett..."
|
ui_print "Copying lists and binaries to /sdcard/zaprett..."
|
||||||
@@ -33,30 +41,21 @@ ui_print "Copying files to /bin"
|
|||||||
arch=$(uname -m)
|
arch=$(uname -m)
|
||||||
case "$arch" in
|
case "$arch" in
|
||||||
"x86_64")
|
"x86_64")
|
||||||
nfqws="nfqws_x86_64"
|
zaprett_bin="zaprett-x86_64"
|
||||||
;;
|
|
||||||
"i386"|"i686")
|
|
||||||
nfqws="nfqws_x86"
|
|
||||||
;;
|
;;
|
||||||
"armv7l"|"arm")
|
"armv7l"|"arm")
|
||||||
nfqws="nfqws_arm32"
|
zaprett_bin="zaprett-armv7"
|
||||||
;;
|
;;
|
||||||
"aarch64"|"armv8l")
|
"aarch64"|"armv8l")
|
||||||
nfqws="nfqws_arm64"
|
zaprett_bin="zaprett-aarch64"
|
||||||
;;
|
|
||||||
"mips")
|
|
||||||
nfqws="nfqws_mips"
|
|
||||||
;;
|
|
||||||
"mipsel")
|
|
||||||
nfqws="nfqws_mipsel"
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
ui_print "Unknown arch: $arch"
|
ui_print "Unknown arch: $arch"
|
||||||
abort
|
abort
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
mv $MODPATH/system/bin/$nfqws $MODPATH/system/bin/nfqws
|
mv $MODPATH/system/bin/$zaprett_bin $MODPATH/system/bin/zaprett
|
||||||
rm $MODPATH/system/bin/nfqws_*
|
rm $MODPATH/system/bin/zaprett-*
|
||||||
mkdir $MODPATH/tmp
|
mkdir $MODPATH/tmp
|
||||||
|
|
||||||
ui_print "Setting permissions..."
|
ui_print "Setting permissions..."
|
||||||
@@ -65,4 +64,4 @@ chmod 777 /sdcard/zaprett; chmod 777 $MODPATH/service.sh
|
|||||||
ui_print "Cleaning temp files..."
|
ui_print "Cleaning temp files..."
|
||||||
rm -rf $MODPATH/system/etc/zaprett
|
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"
|
||||||
|
|||||||
@@ -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
|
|
||||||
Reference in New Issue
Block a user