Compare commits

..

31 Commits

Author SHA1 Message Date
remittor
40a3605034 Bump version to v72.20260108 2026-01-08 19:57:07 +03:00
remittor
3227458422 readme: Update link to instructions 2026-01-08 19:38:51 +03:00
remittor
54fdbe4d5e updater: Add support install packages on clean OpenWrt
Example: ./update-pkg.sh -u 1
Example: ./update-pkg.sh -u 2
2026-01-08 18:33:18 +03:00
remittor
b714b629b7 Integrate mdig and ip2net to main package 2026-01-01 12:27:28 +03:00
remittor
354a71f6c5 Remove tpws, mdig, ip2net packages 2026-01-01 12:22:58 +03:00
remittor
f48488b21b updater: Change get_actual_release error 1 to 150 2025-12-30 13:39:18 +03:00
remittor
a3c256c31a zapret: Global use of dynamic variables 2025-12-29 21:09:35 +03:00
remittor
1d2d3c4b84 luci: updater: Skip error -32000 2025-12-29 19:36:12 +03:00
remittor
5b6fd0a1e6 updater: Fix get_pkg_version for OpenWrt 25 2025-12-29 18:34:31 +03:00
remittor
791ea2d2b6 github: issue: Add help_wanted templates 2025-12-27 11:28:18 +03:00
remittor
9d73b59640 Bump version to v72.20251227 2025-12-27 11:27:41 +03:00
remittor
b58cbafec6 updater: Fix luci package name 2025-12-27 11:27:05 +03:00
remittor
a56b1e3f1c luci: tools: Fix save changes into modal dialog for NFQWS_OPT 2025-12-27 10:29:21 +03:00
remittor
80f15e3da1 def-cfg: Add new strategy v6_by_StressOzz 2025-12-27 10:25:54 +03:00
remittor
89bcec8a60 updater: Fix files renaming 2025-12-26 15:45:20 +03:00
remittor
735575c7bc updater: Update func download_releases_info 2025-12-26 08:57:31 +03:00
remittor
5550820fdc Bump version to v72.20251225-r2 2025-12-25 18:04:53 +03:00
remittor
0e8366f7d1 luci: tools: Fix show and close modal dialog for NFQWS_OPT 2025-12-25 18:02:11 +03:00
remittor
ea3c774537 updater: Fix find base package after ZIP unpack 2025-12-25 14:57:36 +03:00
remittor
57b7e65532 github: Fix bug_report.yml 2025-12-25 12:01:27 +03:00
remittor
eeacc486f9 Add ISSUE_TEMPLATE 2025-12-25 11:52:35 +03:00
remittor
101382faf7 Bump version to v72.20251225 2025-12-25 08:58:38 +03:00
remittor
21229ef152 def-cfg: Add strategies by Flowseal (ALT7 + TLS_AUTO_ALT3) 2025-12-25 08:54:40 +03:00
remittor
9aaf2b29e3 fake: Add TLS 1.3 hello from max.ru 2025-12-25 08:25:26 +03:00
remittor
246f4a08a0 luci: tools: Fix close modal dialog for NFQWS_OPT 2025-12-24 18:50:48 +03:00
remittor
3d3eb82b7b luci: updater: Fix timer using 2025-12-24 14:39:52 +03:00
remittor
8aff441b88 luci: tools: Fix close modal dialog for NFQWS_OPT 2025-12-23 14:14:07 +03:00
remittor
1c866d5de1 comfunc: Fix remove debug log 2025-12-20 10:11:18 +03:00
remittor
57d5ab5060 Bump version to v72.20251219 2025-12-19 11:17:04 +03:00
remittor
5a685cfa27 updater: Add check for unzip installed 2025-12-19 11:11:47 +03:00
remittor
21017047a8 updater: Fix parsing package version (APK) 2025-12-19 10:22:54 +03:00
34 changed files with 1384 additions and 582 deletions

View File

@@ -0,0 +1,80 @@
---
name: 🐛 Bug Report
description: Report a reproducible bug
title: "[BUG] "
labels: ["bug"]
assignees: []
body:
- type: markdown
attributes:
value: |
Thanks for reporting a bug! Please fill out the form below.
Before sending, please:
- Check [existing issues](https://github.com/remittor/zapret-openwrt/issues)
- Read [documentation](https://github.com/remittor/zapret-openwrt/wiki/)
- type: textarea
id: description
attributes:
label: 📝 Bug description
description: A clear and concise description of what is not working
placeholder: A clear and concise description of the bug
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Steps to reproduce
description: Steps to reproduce the problem. If you're following a manual, please include a link to it.
placeholder: |
1.
2.
3.
4.
validations:
required: true
- type: textarea
id: expected
attributes:
label: ✅ Expected behavior
description: A clear and concise description of what was to happen
placeholder: Describe the expected behavior
validations:
required: true
- type: textarea
id: environment
attributes:
label: 🖥️ System Information
description: |
Information about your system (fill in all that used)
value: |
- **OpenWrt version**:
- **Zapret version**:
- **Router model**:
render: markdown
validations:
required: true
- type: textarea
id: strategy
attributes:
label: ✅ The NFQWS strategy used
description: All parameters of the NFQWS strategy, or its name
placeholder: If the problem is caused by the NFQWS strategy
- type: textarea
id: config
attributes:
label: ⚙️ System Configurations
description: |
Relevant parts of the configuration (remove sensitive information!)
placeholder: |
For example:
- Contents of /etc/config/zapret
- Firewall configuration (Flow offloading, etc.)
- Additional configurations required for wireless/network/dhcp, etc.
render: shell

View File

@@ -0,0 +1,80 @@
---
name: 🐛 Сообщение об ошибке
description: Сообщить об ошибке
title: "[BUG] "
labels: ["bug"]
assignees: []
body:
- type: markdown
attributes:
value: |
Спасибо за создание отчета об ошибке!
Перед отправкой, пожалуйста:
- Проверьте [существующие issues](https://github.com/remittor/zapret-openwrt/issues)
- Просмотрите [документацию](https://github.com/remittor/zapret-openwrt/wiki/)
- type: textarea
id: description
attributes:
label: 📝 Описание проблемы
description: Четкое и краткое описание того, что не работает
placeholder: Опишите проблему
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Шаги для воспроизведения
description: Шаги для воспроизведения проблемы. Если вы настраваете что-то по какому либо мануалу, приложите ссылку на него.
placeholder: |
1.
2.
3.
4.
validations:
required: true
- type: textarea
id: expected
attributes:
label: ✅ Ожидаемое поведение
description: Четкое и краткое описание того, что должно было произойти
placeholder: Опишите ожидаемое поведение
validations:
required: true
- type: textarea
id: environment
attributes:
label: 🖥️ Информация о системе
description: |
Информация о вашей системе (заполните всё применяемое)
value: |
- **OpenWrt версия**:
- **Zapret версия**:
- **Роутер модель**:
render: markdown
validations:
required: true
- type: textarea
id: strategy
attributes:
label: ✅ Используемая стратегия NFQWS
description: Все параметры стратегии NFQWS, либо её название
placeholder: Если проблема вызвана стратегией NFQWS
- type: textarea
id: config
attributes:
label: ⚙️ Конфигурация
description: |
Релевантные части конфигурации (удалите чувствительную информацию!)
placeholder: |
Например:
- Содержимое /etc/config/zapret
- Конфигурация файервола (опция Flow offloading и т.п.)
- Дополнительные конфиги, которые потребуются wireless/network/dhcp и т.д.
render: shell

9
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,9 @@
blank_issues_enabled: false
contact_links:
- name: 💬 Installation instructions / Инструкция по установке
url: https://github.com/remittor/zapret-openwrt/wiki/Installing-zapret%E2%80%90openwrt-package
about: Installation instructions / Инструкция по установке
- name: 📚 Original documetation / Оригинальная документация к zapret'у
url: https://github.com/bol-van/zapret/blob/master/docs/readme.md
about: README zapret

View File

@@ -0,0 +1,66 @@
---
name: ✨ Feature Request
description: Suggest a new feature or improvement
title: "[FEATURE] "
labels: ["enhancement", "needs-discussion"]
assignees: []
body:
- type: markdown
attributes:
value: |
Before sending, please:
- Check [existing requests](https://github.com/remittor/zapret-openwrt/issues?q=is%3Aissue+label%3Aenhancement)
- Make sure the function doesn't exist in [documentation](https://github.com/remittor/zapret-openwrt/wiki/)
- type: textarea
id: summary
attributes:
label: Brief description
description: Brief description of the proposed function
placeholder: In one sentence, describe what you want to add...
validations:
required: true
- type: textarea
id: problem
attributes:
label: The problem it solves
description: |
Description of the problem or inconvenience this feature will solve
placeholder: |
There is no possibility now [...]
validations:
required: true
- type: textarea
id: solution
attributes:
label: 💡 Proposed solution
description: A clear and concise description of what you want to achieve
placeholder: |
I want Zapret to be able to [...]
I suggest adding a feature that [...]
Could be improved [...]
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Workaround
description: |
Describe any alternative solutions or features you considered.
Are there any workarounds you currently use?
placeholder: |
I'm currently solving this problem by [...]
An alternative would be [...]
I tried using [...], but it doesn't work because [...]
- type: textarea
id: implementation
attributes:
label: Implementation ideas (optional)
description: |
If you have any ideas on how this could be implemented, please share them. Please keep LuCI's limitations in mind.
placeholder: |
This can be achieved using [...]

View File

@@ -0,0 +1,68 @@
---
name: ✨ Запрос новой функции
description: Предложите новую функцию или улучшение для Zapret
title: "[FEATURE] "
labels: ["enhancement", "needs-discussion"]
assignees: []
body:
- type: markdown
attributes:
value: |
Спасибо за предложение новой функции!
Перед отправкой, пожалуйста:
- Проверьте [существующие запросы](https://github.com/remittor/zapret-openwrt/issues?q=is%3Aissue+label%3Aenhancement)
- Убедитесь, что функции не существует в [документации](https://github.com/remittor/zapret-openwrt/wiki/)
- type: textarea
id: summary
attributes:
label: Краткое описание
description: Краткое описание предлагаемой функции
placeholder: В одном предложении опишите, что вы хотите добавить...
validations:
required: true
- type: textarea
id: problem
attributes:
label: Проблема, которую решает
description: |
Описание проблемы или неудобства, которое решит эта функция
placeholder: |
Сейчас нет возможности [...]
validations:
required: true
- type: textarea
id: solution
attributes:
label: 💡 Предлагаемое решение
description: Четкое и краткое описание того, что вы хотите реализовать
placeholder: |
Я хочу, чтобы Zapret мог [...]
Предлагаю добавить функцию, которая [...]
Можно было бы улучшить [...] путем [...]
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Workaround
description: |
Опишите альтернативные решения или функции, которые вы рассматривали
Есть ли обходные пути, которые вы используете сейчас?
placeholder: |
Сейчас я решаю это проблему путем [...]
Альтернативой могло бы быть [...]
Пробовал использовать [...], но это не подходит потому что [...]
- type: textarea
id: implementation
attributes:
label: Идеи реализации (опционально)
description: |
Если у вас есть идеи о том, как это можно реализовать, поделитесь ими. Помните про ограничения LuCI.
placeholder: |
Это можно реализовать с помощью [...]

View File

@@ -0,0 +1,78 @@
---
name: 🆘 Help wanted
description: Ask for help or propose to help
title: "[HELP] "
labels: ["help wanted"]
assignees: []
body:
- type: markdown
attributes:
value: |
Before sending, please:
- Check [existing issues](https://github.com/remittor/zapret-openwrt/issues)
- Read [documentation](https://github.com/remittor/zapret-openwrt/wiki/)
- type: textarea
id: description
attributes:
label: 📝 Problem description
description: What do you need help with?
placeholder: A clear and concise description of the problem
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Steps to reproduce
description: Steps to reproduce the problem. If you're following a manual, please include a link to it.
placeholder: |
1.
2.
3.
4.
validations:
required: true
- type: textarea
id: expected
attributes:
label: ✅ Expected behavior
description: A clear and concise description of what was to happen
placeholder: Describe the expected behavior
validations:
required: true
- type: textarea
id: environment
attributes:
label: 🖥️ System Information
description: |
Information about your system (fill in all that used)
value: |
- **OpenWrt version**:
- **Zapret version**:
- **Router model**:
render: markdown
validations:
required: true
- type: textarea
id: strategy
attributes:
label: ✅ The NFQWS strategy used
description: All parameters of the NFQWS strategy, or its name
placeholder: If the problem is caused by the NFQWS strategy
- type: textarea
id: config
attributes:
label: ⚙️ System Configurations
description: |
Relevant parts of the configuration (remove sensitive information!)
placeholder: |
For example:
- Contents of /etc/config/zapret
- Firewall configuration (Flow offloading, etc.)
- Additional configurations required for wireless/network/dhcp, etc.
render: shell

View File

@@ -0,0 +1,78 @@
---
name: 🆘 Нужна помощь
description: Нужна помощь
title: "[HELP] "
labels: ["help wanted"]
assignees: []
body:
- type: markdown
attributes:
value: |
Перед отправкой, пожалуйста:
- Проверьте [существующие issues](https://github.com/remittor/zapret-openwrt/issues)
- Просмотрите [документацию](https://github.com/remittor/zapret-openwrt/wiki/)
- type: textarea
id: description
attributes:
label: 📝 Описание проблемы
description: В чём именно нужна помощь?
placeholder: Опишите проблему
validations:
required: true
- type: textarea
id: reproduction
attributes:
label: Шаги для воспроизведения
description: Шаги для воспроизведения проблемы. Если вы настраваете что-то по какому либо мануалу, приложите ссылку на него.
placeholder: |
1.
2.
3.
4.
validations:
required: true
- type: textarea
id: expected
attributes:
label: ✅ Ожидаемое поведение
description: Четкое и краткое описание того, что должно было произойти
placeholder: Опишите ожидаемое поведение
validations:
required: true
- type: textarea
id: environment
attributes:
label: 🖥️ Информация о системе
description: |
Информация о вашей системе (заполните всё применяемое)
value: |
- **OpenWrt версия**:
- **Zapret версия**:
- **Роутер модель**:
render: markdown
validations:
required: true
- type: textarea
id: strategy
attributes:
label: ✅ Используемая стратегия NFQWS
description: Все параметры стратегии NFQWS, либо её название
placeholder: Если проблема вызвана стратегией NFQWS
- type: textarea
id: config
attributes:
label: ⚙️ Конфигурация
description: |
Релевантные части конфигурации (удалите чувствительную информацию!)
placeholder: |
Например:
- Содержимое /etc/config/zapret
- Конфигурация файервола (опция Flow offloading и т.п.)
- Дополнительные конфиги, которые потребуются wireless/network/dhcp и т.д.
render: shell

View File

@@ -137,10 +137,13 @@ jobs:
- mipsel_24kc_24kf - mipsel_24kc_24kf
- mipsel_74kc - mipsel_74kc
- mipsel_mips32 - mipsel_mips32
- riscv64_generic
- x86_64 - x86_64
isTestOrFake: isTestOrFake:
- ${{ needs.check.outputs.test_build == 'true' || needs.check.outputs.fake_build == 'true' }} - ${{ needs.check.outputs.test_build == 'true' || needs.check.outputs.fake_build == 'true' }}
exclude: exclude:
- branch: openwrt-24.10
arch: riscv64_generic
- branch: SNAPSHOT - branch: SNAPSHOT
arch: arm_cortex-a9_vfpv3-d16 arch: arm_cortex-a9_vfpv3-d16
- { isTestOrFake: true } - { isTestOrFake: true }
@@ -249,9 +252,9 @@ jobs:
cat .config cat .config
echo "------------- .config END -------------------" echo "------------- .config END -------------------"
if [ "$ARCH" = "$LUCI_ARCH" ]; then if [ "$ARCH" = "$LUCI_ARCH" ]; then
PKGLIST=`echo package/zapret-openwrt/{zapret,zapret-mdig,zapret-ip2net,luci-app-zapret}/compile` PKGLIST=`echo package/zapret-openwrt/{zapret,luci-app-zapret}/compile`
else else
PKGLIST=`echo package/zapret-openwrt/{zapret,zapret-mdig,zapret-ip2net}/compile` PKGLIST=`echo package/zapret-openwrt/zapret/compile`
fi fi
if [ "$MAX_SPEED" = "false" ]; then if [ "$MAX_SPEED" = "false" ]; then
make $PKGLIST V=s CONFIG_CCACHE=1 BUILD_LOG=1 make $PKGLIST V=s CONFIG_CCACHE=1 BUILD_LOG=1
@@ -261,11 +264,11 @@ jobs:
else else
OUT_DIR=./bin/packages/dev_x/base OUT_DIR=./bin/packages/dev_x/base
mkdir -p $OUT_DIR mkdir -p $OUT_DIR
touch $OUT_DIR/zapret2_$PKGVER-$ARCH.$PKGTYPE touch $OUT_DIR/zapret_$PKGVER-$ARCH.$PKGTYPE
touch $OUT_DIR/luci-app-zapret2_$PKGVER-all.$PKGTYPE touch $OUT_DIR/luci-app-zapret_$PKGVER-all.$PKGTYPE
fi fi
find ./bin/packages/*/base -type f ! -regex ".*\(zapret2\).*\.[ai]pk$" -delete find ./bin/packages/*/base -type f ! -regex ".*\(zapret\).*\.[ai]pk$" -delete
#echo ">>>>>>> build a repository index to make the output directory usable as local OPKG source" #echo ">>>>>>> build a repository index to make the output directory usable as local OPKG source"
#ln -s `which usign` staging_dir/host/bin/usign #ln -s `which usign` staging_dir/host/bin/usign
@@ -336,7 +339,7 @@ jobs:
find ./sorted -mindepth 1 -maxdepth 1 -type d -exec cp -f "$LUCI_IPK" "{}/" \; find ./sorted -mindepth 1 -maxdepth 1 -type d -exec cp -f "$LUCI_IPK" "{}/" \;
find ./sorted -mindepth 2 -maxdepth 2 -type d -name "apk" -exec cp -f "$LUCI_APK" "{}/" \; find ./sorted -mindepth 2 -maxdepth 2 -type d -name "apk" -exec cp -f "$LUCI_APK" "{}/" \;
mkdir -p public mkdir -p public
find ./sorted -mindepth 1 -maxdepth 1 -type d -exec sh -c '7z a ./public/zapret2_v${PKGVER}_$(basename "{}" | cut -d, -f3).zip {}/*' \; find ./sorted -mindepth 1 -maxdepth 1 -type d -exec sh -c '7z a ./public/zapret_v${PKGVER}_$(basename "{}" | cut -d, -f3).zip {}/*' \;
ls -lh ./public/*.zip ls -lh ./public/*.zip
- name: Upload assets - name: Upload assets
@@ -348,7 +351,7 @@ jobs:
draft: ${{ env.TEST_BUILD == 'true' || env.FAKE_BUILD == 'true' }} draft: ${{ env.TEST_BUILD == 'true' || env.FAKE_BUILD == 'true' }}
prerelease: true prerelease: true
tag_name: v${{ needs.build.outputs.pkgver }}${{ env.TAG_SUFFIX }} tag_name: v${{ needs.build.outputs.pkgver }}${{ env.TAG_SUFFIX }}
name: zapret2 v${{ needs.build.outputs.pkgver }} name: zapret v${{ needs.build.outputs.pkgver }}
body: | body: |
zapret2 v${{ needs.build.outputs.pkgver }} for OpenWrt zapret v${{ needs.build.outputs.pkgver }} for OpenWrt
files: ./public/*.zip files: ./public/*.zip

View File

@@ -2,13 +2,12 @@
[![Github All Releases](https://img.shields.io/github/downloads/remittor/zapret-openwrt/total.svg)](https://github.com/remittor/zapret-openwrt/releases) [![Github All Releases](https://img.shields.io/github/downloads/remittor/zapret-openwrt/total.svg)](https://github.com/remittor/zapret-openwrt/releases)
[![Github Latest Release](https://img.shields.io/github/downloads/remittor/zapret-openwrt/latest/total.svg)](https://github.com/remittor/zapret-openwrt/releases) [![Github Latest Release](https://img.shields.io/github/downloads/remittor/zapret-openwrt/latest/total.svg)](https://github.com/remittor/zapret-openwrt/releases)
[![ViewCount](https://views.whatilearened.today/views/github/remittor/zapret-openwrt.svg)](https://github.com/remittor/zapret-openwrt) [![ViewCount](https://views.whatilearened.today/views/github/remittor/zapret-openwrt.svg)](https://github.com/remittor/zapret-openwrt)
[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fremittor%2Fzapret-openwrt&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://github.com/remittor/zapret-openwrt/releases)
[![Donations Page](https://github.com/andry81-cache/gh-content-static-cache/raw/master/common/badges/donate/donate.svg)](https://github.com/remittor/donate) [![Donations Page](https://github.com/andry81-cache/gh-content-static-cache/raw/master/common/badges/donate/donate.svg)](https://github.com/remittor/donate)
# zapret-openwrt # zapret-openwrt
Zapret2 is not a VPN! Zapret2 is an Anti-DPI utility! Zapret is not a VPN! Zapret is an Anti-DPI utility!
[Instructions for installing](https://github.com/remittor/zapret-openwrt/wiki/Installing-zapretopenwrt-package) [Instructions for installing](https://github.com/remittor/zapret-openwrt/wiki)
[Download page](https://github.com/remittor/zapret-openwrt/releases) [Download page](https://github.com/remittor/zapret-openwrt/releases)

View File

@@ -4,14 +4,14 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-zapret2 PKG_NAME:=luci-app-zapret
PKG_VERSION:=0.7.20251224 PKG_VERSION:=72.20260108
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_LICENSE:=MIT PKG_LICENSE:=MIT
PKG_MAINTAINER:=remittor <https://github.com/remittor> PKG_MAINTAINER:=remittor <https://github.com/remittor>
LUCI_TITLE:=LuCI support for zapret2 LUCI_TITLE:=LuCI support for zapret
LUCI_DEPENDS:=+zapret2 LUCI_DEPENDS:=+zapret
LUCI_PKGARCH:=all LUCI_PKGARCH:=all
define Package/$(PKG_NAME)/postinst define Package/$(PKG_NAME)/postinst

View File

@@ -5,13 +5,13 @@
'require poll'; 'require poll';
'require uci'; 'require uci';
'require ui'; 'require ui';
'require view.zapret2.tools as tools'; 'require view.zapret.tools as tools';
return view.extend({ return view.extend({
retrieveLog: async function() { retrieveLog: async function() {
return Promise.all([ return Promise.all([
L.resolveDefault(fs.stat('/bin/cat'), null), L.resolveDefault(fs.stat('/bin/cat'), null),
fs.exec('/usr/bin/find', [ '/tmp', '-maxdepth', '1', '-type', 'f', '-name', 'zapret2+*.log' ]), fs.exec('/usr/bin/find', [ '/tmp', '-maxdepth', '1', '-type', 'f', '-name', 'zapret+*.log' ]),
uci.load(tools.appName), uci.load(tools.appName),
]).then(function(status_array) { ]).then(function(status_array) {
var filereader = status_array[0] ? status_array[0].path : null; var filereader = status_array[0] ? status_array[0].path : null;
@@ -130,7 +130,7 @@ return view.extend({
return; return;
} }
var h2 = E('div', {'class' : 'cbi-title-section'}, [ var h2 = E('div', {'class' : 'cbi-title-section'}, [
E('h2', {'class': 'cbi-title-field'}, [ _('Zapret2') + ' - ' + _('Log Viewer') ]), E('h2', {'class': 'cbi-title-field'}, [ _('Zapret') + ' - ' + _('Log Viewer') ]),
]); ]);
var tabs = E('div', {}, E('div')); var tabs = E('div', {}, E('div'));
@@ -140,7 +140,7 @@ return view.extend({
var logfn = logdata[log_num].filename; var logfn = logdata[log_num].filename;
let filename = logfn.replace(/.*\//, ''); let filename = logfn.replace(/.*\//, '');
let fname = filename.split('.')[0]; let fname = filename.split('.')[0];
fname = fname.replace(/^(zapret2\+)/, ''); fname = fname.replace(/^(zapret\+)/, '');
let fn = fname.split('+'); let fn = fname.split('+');
let tabNameText = fname.replace(/\+/g, ' '); let tabNameText = fname.replace(/\+/g, ' ');

View File

@@ -4,8 +4,8 @@
'require uci'; 'require uci';
'require ui'; 'require ui';
'require view'; 'require view';
'require view.zapret2.tools as tools'; 'require view.zapret.tools as tools';
'require view.zapret2.updater as updater'; 'require view.zapret.updater as updater';
const btn_style_neutral = 'btn'; const btn_style_neutral = 'btn';
const btn_style_action = 'btn cbi-button-action'; const btn_style_action = 'btn cbi-button-action';
@@ -55,7 +55,7 @@ return view.extend({
]).catch(e => { ]).catch(e => {
ui.addNotification(null, E('p', _('Unable to execute or read contents') ui.addNotification(null, E('p', _('Unable to execute or read contents')
+ ': %s [ %s | %s | %s ]'.format( + ': %s [ %s | %s | %s ]'.format(
e.message, tools.execPath, 'tools.getInitState', 'uci.zapret2' e.message, tools.execPath, 'tools.getInitState', 'uci.zapret'
))); )));
}); });
}, },
@@ -249,8 +249,8 @@ return view.extend({
strat_list.push( E('option', { value: 'strat_' + id }, [ strat ] ) ); strat_list.push( E('option', { value: 'strat_' + id }, [ strat ] ) );
} }
let nfqws_strat = E('label', [ let nfqws_strat = E('label', [
_('NFQWS2_OPT strategy: '), _('NFQWS_OPT strategy: '),
E('select', { id: 'cfg_nfqws2_strat' }, strat_list) E('select', { id: 'cfg_nfqws_strat' }, strat_list)
]); ]);
let cancel_button = E('button', { let cancel_button = E('button', {
@@ -274,7 +274,7 @@ return view.extend({
opt_flags += '(set_mode_autohostlist)'; opt_flags += '(set_mode_autohostlist)';
}; };
//console.log('RESET: opt_flags = ' + opt_flags); //console.log('RESET: opt_flags = ' + opt_flags);
let sel_strat = document.getElementById('cfg_nfqws2_strat'); let sel_strat = document.getElementById('cfg_nfqws_strat');
let opt_strat = sel_strat.options[sel_strat.selectedIndex].text; let opt_strat = sel_strat.options[sel_strat.selectedIndex].text;
//console.log('RESET: strat = ' + opt_strat); //console.log('RESET: strat = ' + opt_strat);
opt_flags += '(sync)'; opt_flags += '(sync)';
@@ -399,23 +399,23 @@ return view.extend({
poll.add(L.bind(this.statusPoll, this)); poll.add(L.bind(this.statusPoll, this));
let page_title = _('Zapret2'); let page_title = _('Zapret');
let pkgdict = tools.decode_pkg_list(pkg_list.stdout, false); let pkgdict = tools.decode_pkg_list(pkg_list.stdout, false);
page_title += ' &nbsp '; page_title += ' &nbsp ';
if (pkgdict['zapret2'] === undefined || pkgdict['zapret2'] == '') { if (pkgdict['zapret'] === undefined || pkgdict['zapret'] == '') {
page_title += 'unknown version'; page_title += 'unknown version';
} else { } else {
page_title += 'v' + pkgdict['zapret2']; page_title += 'v' + pkgdict['zapret'];
} }
let aux1 = E('em'); let aux1 = E('em');
let aux2 = E('em'); let aux2 = E('em');
if (pkgdict['zapret2'] != pkgdict['luci-app-zapret2']) { if (pkgdict['zapret'] != pkgdict['luci-app-zapret']) {
let errtxt = 'LuCI APP v' + pkgdict['luci-app-zapret2'] + ' [ incorrect version! ]'; let errtxt = 'LuCI APP v' + pkgdict['luci-app-zapret'] + ' [ incorrect version! ]';
aux1 = E('div', { 'class': 'label-status error' }, errtxt); aux1 = E('div', { 'class': 'label-status error' }, errtxt);
aux2 = E('div', { }, '&nbsp'); aux2 = E('div', { }, '&nbsp');
} }
let url1 = 'https://github.com/bol-van/zapret2'; let url1 = 'https://github.com/bol-van/zapret';
let url2 = 'https://github.com/remittor/zapret-openwrt'; let url2 = 'https://github.com/remittor/zapret-openwrt';
return E([ return E([

View File

@@ -5,7 +5,7 @@
'require uci'; 'require uci';
'require ui'; 'require ui';
'require view'; 'require view';
'require view.zapret2.tools as tools'; 'require view.zapret.tools as tools';
return view.extend({ return view.extend({
parsers: { }, parsers: { },
@@ -48,7 +48,7 @@ return view.extend({
let m, s, o, tabname; let m, s, o, tabname;
m = new form.Map(tools.appName, _('Zapret2') + ' - ' + _('Settings')); m = new form.Map(tools.appName, _('Zapret') + ' - ' + _('Settings'));
s = m.section(form.NamedSection, 'config'); s = m.section(form.NamedSection, 'config');
s.anonymous = true; s.anonymous = true;
@@ -106,8 +106,8 @@ return view.extend({
/* NFQWS_OPT_DESYNC tab */ /* NFQWS_OPT_DESYNC tab */
tabname = 'nfqws2_params'; tabname = 'nfqws_params';
s.tab(tabname, _('NFQWS2 options')); s.tab(tabname, _('NFQWS options'));
let add_delim = function(sec, url = null) { let add_delim = function(sec, url = null) {
let o = sec.taboption(tabname, form.DummyValue, '_hr'); let o = sec.taboption(tabname, form.DummyValue, '_hr');
@@ -154,7 +154,7 @@ return view.extend({
btn.onclick = () => new tools.longstrEditDialog('config', param, param, desc, rows, multiline).show(); btn.onclick = () => new tools.longstrEditDialog('config', param, param, desc, rows, multiline).show();
}; };
o = s.taboption(tabname, form.Flag, 'NFQWS2_ENABLE', _('NFQWS2_ENABLE')); o = s.taboption(tabname, form.Flag, 'NFQWS_ENABLE', _('NFQWS_ENABLE'));
o.rmempty = false; o.rmempty = false;
o.default = 1; o.default = 1;
@@ -173,40 +173,40 @@ return view.extend({
o.validate = function(section_id, value) { return true; }; o.validate = function(section_id, value) { return true; };
o.write = function(section_id, value) { return form.Value.prototype.write.call(this, section_id, (value == null || value.trim() == '') ? "\t" : value.trim()); }; o.write = function(section_id, value) { return form.Value.prototype.write.call(this, section_id, (value == null || value.trim() == '') ? "\t" : value.trim()); };
o = s.taboption(tabname, form.Value, 'NFQWS2_PORTS_TCP', _('NFQWS2_PORTS_TCP')); o = s.taboption(tabname, form.Value, 'NFQWS_PORTS_TCP', _('NFQWS_PORTS_TCP'));
o.rmempty = false; o.rmempty = false;
o.datatype = 'string'; o.datatype = 'string';
o = s.taboption(tabname, form.Value, 'NFQWS2_PORTS_UDP', _('NFQWS2_PORTS_UDP')); o = s.taboption(tabname, form.Value, 'NFQWS_PORTS_UDP', _('NFQWS_PORTS_UDP'));
o.rmempty = false; o.rmempty = false;
o.datatype = 'string'; o.datatype = 'string';
o = s.taboption(tabname, form.Value, 'NFQWS2_TCP_PKT_OUT', _('NFQWS2_TCP_PKT_OUT')); o = s.taboption(tabname, form.Value, 'NFQWS_TCP_PKT_OUT', _('NFQWS_TCP_PKT_OUT'));
o.rmempty = false; o.rmempty = false;
o.datatype = 'string'; o.datatype = 'string';
o = s.taboption(tabname, form.Value, 'NFQWS2_TCP_PKT_IN', _('NFQWS2_TCP_PKT_IN')); o = s.taboption(tabname, form.Value, 'NFQWS_TCP_PKT_IN', _('NFQWS_TCP_PKT_IN'));
o.rmempty = false; o.rmempty = false;
o.datatype = 'string'; o.datatype = 'string';
o = s.taboption(tabname, form.Value, 'NFQWS2_UDP_PKT_OUT', _('NFQWS2_UDP_PKT_OUT')); o = s.taboption(tabname, form.Value, 'NFQWS_UDP_PKT_OUT', _('NFQWS_UDP_PKT_OUT'));
o.rmempty = false; o.rmempty = false;
o.datatype = 'string'; o.datatype = 'string';
o = s.taboption(tabname, form.Value, 'NFQWS2_UDP_PKT_IN', _('NFQWS2_UDP_PKT_IN')); o = s.taboption(tabname, form.Value, 'NFQWS_UDP_PKT_IN', _('NFQWS_UDP_PKT_IN'));
o.rmempty = false; o.rmempty = false;
o.datatype = 'string'; o.datatype = 'string';
o = s.taboption(tabname, form.Value, 'NFQWS2_PORTS_TCP_KEEPALIVE', _('NFQWS2_PORTS_TCP_KEEPALIVE')); o = s.taboption(tabname, form.Value, 'NFQWS_PORTS_TCP_KEEPALIVE', _('NFQWS_PORTS_TCP_KEEPALIVE'));
o.rmempty = false; o.rmempty = false;
o.datatype = 'uinteger'; o.datatype = 'uinteger';
o = s.taboption(tabname, form.Value, 'NFQWS2_PORTS_UDP_KEEPALIVE', _('NFQWS2_PORTS_UDP_KEEPALIVE')); o = s.taboption(tabname, form.Value, 'NFQWS_PORTS_UDP_KEEPALIVE', _('NFQWS_PORTS_UDP_KEEPALIVE'));
o.rmempty = false; o.rmempty = false;
o.datatype = 'uinteger'; o.datatype = 'uinteger';
add_delim(s, tools.nfqws_opt_url); add_delim(s, tools.nfqws_opt_url);
add_param(s, 'NFQWS2_OPT', null, 21, 2); add_param(s, 'NFQWS_OPT', null, 21, 2);
/* AutoHostList settings */ /* AutoHostList settings */
@@ -226,14 +226,6 @@ return view.extend({
o.write = function(section_id, value) { o.write = function(section_id, value) {
return uci.set(tools.appName, section_id, 'MODE_FILTER', value === '1' ? 'autohostlist' : 'hostlist'); return uci.set(tools.appName, section_id, 'MODE_FILTER', value === '1' ? 'autohostlist' : 'hostlist');
}; };
o = s.taboption(tabname, form.Value, 'AUTOHOSTLIST_INCOMING_MAXSEQ', _('INCOMING_MAXSEQ'));
o.rmempty = false;
o.datatype = 'uinteger';
o = s.taboption(tabname, form.Value, 'AUTOHOSTLIST_RETRANS_MAXSEQ', _('RETRANS_MAXSEQ'));
o.rmempty = false;
o.datatype = 'uinteger';
o = s.taboption(tabname, form.Value, 'AUTOHOSTLIST_RETRANS_THRESHOLD', _('RETRANS_THRESHOLD')); o = s.taboption(tabname, form.Value, 'AUTOHOSTLIST_RETRANS_THRESHOLD', _('RETRANS_THRESHOLD'));
o.rmempty = false; o.rmempty = false;
@@ -247,14 +239,6 @@ return view.extend({
o.rmempty = false; o.rmempty = false;
o.datatype = 'uinteger'; o.datatype = 'uinteger';
o = s.taboption(tabname, form.Value, 'AUTOHOSTLIST_UDP_IN', _('UDP_IN'));
o.rmempty = false;
o.datatype = 'uinteger';
o = s.taboption(tabname, form.Value, 'AUTOHOSTLIST_UDP_OUT', _('UDP_OUT'));
o.rmempty = false;
o.datatype = 'uinteger';
o = s.taboption(tabname, form.Button, '_auto_host_btn', _('Auto host list entries')); o = s.taboption(tabname, form.Button, '_auto_host_btn', _('Auto host list entries'));
o.inputtitle = _('Edit'); o.inputtitle = _('Edit');
o.inputstyle = 'edit btn'; o.inputstyle = 'edit btn';

View File

@@ -36,31 +36,32 @@ document.head.append(E('style', {'type': 'text/css'},
return baseclass.extend({ return baseclass.extend({
packager : null, packager : null,
appName : 'zapret2', appName : 'zapret',
execPath : '/etc/init.d/zapret2', execPath : '/etc/init.d/zapret',
syncCfgPath : '/opt/zapret2/sync_config.sh', syncCfgPath : '/opt/zapret/sync_config.sh',
defCfgPath : '/opt/zapret2/def-cfg.sh', defCfgPath : '/opt/zapret/def-cfg.sh',
defaultCfgPath : '/opt/zapret2/restore-def-cfg.sh', defaultCfgPath : '/opt/zapret/restore-def-cfg.sh',
hostsGoogleFN : '/opt/zapret2/ipset/zapret-hosts-google.txt', hostsGoogleFN : '/opt/zapret/ipset/zapret-hosts-google.txt',
hostsUserFN : '/opt/zapret2/ipset/zapret-hosts-user.txt', hostsUserFN : '/opt/zapret/ipset/zapret-hosts-user.txt',
hostsUserExcludeFN: '/opt/zapret2/ipset/zapret-hosts-user-exclude.txt', hostsUserExcludeFN: '/opt/zapret/ipset/zapret-hosts-user-exclude.txt',
iplstExcludeFN : '/opt/zapret2/ipset/zapret-ip-exclude.txt', iplstExcludeFN : '/opt/zapret/ipset/zapret-ip-exclude.txt',
iplstUserFN : '/opt/zapret2/ipset/zapret-ip-user.txt', iplstUserFN : '/opt/zapret/ipset/zapret-ip-user.txt',
iplstUserExcludeFN: '/opt/zapret2/ipset/zapret-ip-user-exclude.txt', iplstUserExcludeFN: '/opt/zapret/ipset/zapret-ip-user-exclude.txt',
custFileMax : 4, custFileMax : 4,
custFileTemplate : '/opt/zapret2/ipset/cust%s.txt', custFileTemplate : '/opt/zapret/ipset/cust%s.txt',
customdPrefixList : [ 10, 20, 50, 60, 90 ] , customdPrefixList : [ 10, 20, 50, 60, 90 ] ,
customdFileFormat : '/opt/zapret2/init.d/openwrt/custom.d/%s-script.sh', customdFileFormat : '/opt/zapret/init.d/openwrt/custom.d/%s-script.sh',
discord_num : 50, discord_num : 50,
discord_url : [ 'https://github.com/bol-van/zapret2/blob/master/init.d/custom.d.examples.linux/50-discord-media', discord_url : [ 'https://github.com/bol-van/zapret/blob/4e8e3a9ed9dbeb1156db68dfaa7b353051c13797/init.d/custom.d.examples.linux/50-discord',
'https://github.com/bol-van/zapret2/blob/master/init.d/custom.d.examples.linux/50-stun4all', 'https://github.com/bol-van/zapret/blob/b251ea839cc8f04c45090314ef69fce69f2c00f2/init.d/custom.d.examples.linux/50-discord-media',
'https://github.com/bol-van/zapret2/tree/master/init.d/custom.d.examples.linux' 'https://github.com/bol-van/zapret/blob/b251ea839cc8f04c45090314ef69fce69f2c00f2/init.d/custom.d.examples.linux/50-stun4all',
'https://github.com/bol-van/zapret/tree/master/init.d/custom.d.examples.linux'
], ],
nfqws_opt_url : 'https://github.com/remittor/zapret-openwrt/discussions/', nfqws_opt_url : 'https://github.com/remittor/zapret-openwrt/discussions/168',
autoHostListFN : '/opt/zapret2/ipset/zapret-hosts-auto.txt', autoHostListFN : '/opt/zapret/ipset/zapret-hosts-auto.txt',
autoHostListDbgFN : '/opt/zapret2/ipset/zapret-hosts-auto-debug.log', autoHostListDbgFN : '/opt/zapret/ipset/zapret-hosts-auto-debug.log',
infoLabelRunning : '<span class="label-status running">' + _('Running') + '</span>', infoLabelRunning : '<span class="label-status running">' + _('Running') + '</span>',
infoLabelStarting : '<span class="label-status starting">' + _('Starting') + '</span>', infoLabelStarting : '<span class="label-status starting">' + _('Starting') + '</span>',
@@ -105,11 +106,11 @@ return baseclass.extend({
if (L.hasSystemFeature('apk')) { if (L.hasSystemFeature('apk')) {
this.packager.name = 'apk'; this.packager.name = 'apk';
this.packager.path = '/usr/bin/apk'; this.packager.path = '/usr/bin/apk';
this.packager.args = [ 'list', '-I', '*zapret2*' ]; this.packager.args = [ 'list', '-I', '*zapret*' ];
} else { } else {
this.packager.name = 'opkg'; this.packager.name = 'opkg';
this.packager.path = '/bin/opkg'; this.packager.path = '/bin/opkg';
this.packager.args = [ 'list-installed', '*zapret2*' ]; this.packager.args = [ 'list-installed', '*zapret*' ];
} }
//console.log('PACKAGER: ' + this.packager.name); //console.log('PACKAGER: ' + this.packager.name);
} }
@@ -270,9 +271,9 @@ return baseclass.extend({
return -4; return -4;
} }
let jdata = svc_info; let jdata = svc_info;
if (typeof(jdata.zapret2) == 'object') { if (typeof(jdata.zapret) == 'object') {
result.dmn.inited = true; result.dmn.inited = true;
let dmn_list = jdata.zapret2.instances; let dmn_list = jdata.zapret.instances;
if (typeof(dmn_list) == 'object') { if (typeof(dmn_list) == 'object') {
for (const [dmn_name, daemon] of Object.entries(dmn_list)) { for (const [dmn_name, daemon] of Object.entries(dmn_list)) {
result.dmn.total += 1; result.dmn.total += 1;
@@ -403,13 +404,13 @@ return baseclass.extend({
E('button', { E('button', {
'id': 'btn_save', 'id': 'btn_save',
'class': 'btn cbi-button-positive important', 'class': 'btn cbi-button-positive important',
'click': ui.createHandlerFn(this, this.handleSave), 'click': ui.createHandlerFn(this, this.handleSaveAdv),
}, _('Save')), }, _('Save')),
]), ]),
]); ]);
}, },
handleSave: function(ev) { handleSaveAdv: function(ev) {
let txt = document.getElementById('widget.modal_content'); let txt = document.getElementById('widget.modal_content');
let value = txt.value.trim().replace(/\r\n/g, '\n') + '\n'; let value = txt.value.trim().replace(/\r\n/g, '\n') + '\n';
@@ -469,7 +470,7 @@ return baseclass.extend({
}, },
load: function() { load: function() {
let value = uci.get('zapret2', this.cfgsec, this.cfgparam); let value = uci.get('zapret', this.cfgsec, this.cfgparam);
if (typeof(value) === 'string') { if (typeof(value) === 'string') {
value = value.trim(); value = value.trim();
if (this.multiline == 2) { if (this.multiline == 2) {
@@ -514,13 +515,13 @@ return baseclass.extend({
E('button', { E('button', {
'id': 'btn_save', 'id': 'btn_save',
'class': 'btn cbi-button-positive important', 'class': 'btn cbi-button-positive important',
'click': ui.createHandlerFn(this, this.handleSave), 'click': ui.createHandlerFn(this, this.handleSaveAdv),
}, _('Save')), }, _('Save')),
]), ]),
]); ]);
}, },
handleSave: function(ev) { handleSaveAdv: function(ev) {
let txt = document.getElementById('widget.modal_content'); let txt = document.getElementById('widget.modal_content');
let value = txt.value.trim(); let value = txt.value.trim();
if (this.multiline) { if (this.multiline) {
@@ -543,32 +544,33 @@ return baseclass.extend({
} }
value = value.replace(/˂/g, '<'); value = value.replace(/˂/g, '<');
value = value.replace(/˃/g, '>'); value = value.replace(/˃/g, '>');
let elem = document.getElementById("cbi-zapret-" + this.cfgsec + "-_" + this.cfgparam); try {
if (elem) { let elem2 = null;
let val = value.trim(); let elem = document.getElementById("cbi-zapret-" + this.cfgsec + "-_" + this.cfgparam);
if (this.multiline) { if (elem) {
val = val.replace(/</g, '˂'); if (!elem2) {
val = val.replace(/>/g, '˃'); elem2 = elem.querySelector('div');
val = val.replace(/\n/g, '<br/>'); }
elem.querySelector('div').innerHTML = val; if (!elem2) {
} else { elem2 = elem.querySelector('output');
elem.querySelector('div').textContent = val; }
} }
if (elem2) {
let val = value.trim();
if (this.multiline) {
val = val.replace(/</g, '˂');
val = val.replace(/>/g, '˃');
val = val.replace(/\n/g, '<br/>');
elem2.innerHTML = val;
} else {
elem2.textContent = val;
}
}
} catch(e) {
console.error('ERROR: cannot found elem for ' + this.cfgparam);
} }
uci.set('zapret', this.cfgsec, this.cfgparam, value); uci.set('zapret', this.cfgsec, this.cfgparam, value);
uci.save().then(() => window.location.reload()); uci.save().then(ui.hideModal);
/*
return uci.save()
.then(L.bind(ui.changes.init, ui.changes))
.then(L.bind(ui.changes.displayChanges, ui.changes))
//.then(L.bind(ui.changes.apply, ui.changes))
.then(ui.addNotification(null, E('p', _('Contents have been saved.')), 'info'))
.catch(e => {
ui.addNotification(null, E('p', _('Unable to save the contents') + ': %s'.format(e.message)));
}).finally(() => {
ui.hideModal();
});
*/
}, },
error: function(e) { error: function(e) {
@@ -587,13 +589,17 @@ return baseclass.extend({
}, },
show: function() { show: function() {
//ui.showModal(null, E('p', { 'class': 'spinning' }, _('Loading')) ); ui.showModal(null,
let content = this.load(); E('p', { 'class': 'spinning' }, _('Loading'))
//ui.hideModal(); );
if (content === null) { L.resolveDefault(this.load(), null)
return this.error('Cannot load parameter'); .then(content => {
} ui.hideModal();
return this.render(content); return this.render(content);
}).catch(e => {
ui.hideModal();
return this.error(e);
})
}, },
}), }),

View File

@@ -5,7 +5,7 @@
'require uci'; 'require uci';
'require ui'; 'require ui';
'require view'; 'require view';
'require view.zapret2.tools as tools'; 'require view.zapret.tools as tools';
const btn_style_neutral = 'btn'; const btn_style_neutral = 'btn';
const btn_style_action = 'btn cbi-button-action'; const btn_style_action = 'btn cbi-button-action';
@@ -14,7 +14,7 @@ const btn_style_negative = 'btn cbi-button-reset important';
const btn_style_warning = 'btn cbi-button-negative'; const btn_style_warning = 'btn cbi-button-negative';
const btn_style_success = 'btn cbi-button-success important'; const btn_style_success = 'btn cbi-button-success important';
const fn_update_pkg_sh = '/opt/zapret2/update-pkg.sh'; const fn_update_pkg_sh = '/opt/zapret/update-pkg.sh';
return baseclass.extend({ return baseclass.extend({
releasesUrlPrefix : 'https://raw.githubusercontent.com/remittor/zapret-openwrt/gh-pages/releases/', releasesUrlPrefix : 'https://raw.githubusercontent.com/remittor/zapret-openwrt/gh-pages/releases/',
@@ -104,7 +104,7 @@ return baseclass.extend({
} }
let rpc_opt = { timeout: 5*1000 } let rpc_opt = { timeout: 5*1000 }
//rpc_opt.uid = 0; // run under root //rpc_opt.uid = 0; // run under root
const logFile = '/tmp/zapret2_pkg_install.log'; const logFile = '/tmp/zapret_pkg_install.log';
const rcFile = logFile + '.rc'; const rcFile = logFile + '.rc';
try { try {
await fs.exec('/bin/busybox', [ 'rm', '-f', logFile + '*' ], null, rpc_opt); await fs.exec('/bin/busybox', [ 'rm', '-f', logFile + '*' ], null, rpc_opt);
@@ -118,7 +118,7 @@ return baseclass.extend({
let opt = [ logFile, fn_update_pkg_sh ]; let opt = [ logFile, fn_update_pkg_sh ];
//opt.push('-t'); opt.push('0'); // only for testing //opt.push('-t'); opt.push('0'); // only for testing
opt.push(...opt_list); opt.push(...opt_list);
let res = await fs.exec('/opt/zapret2/script-exec.sh', opt, null, rpc_opt); let res = await fs.exec('/opt/zapret/script-exec.sh', opt, null, rpc_opt);
if (res.code == 0) { if (res.code == 0) {
this.appendLog('Process started...'); this.appendLog('Process started...');
} else { } else {
@@ -132,7 +132,11 @@ return baseclass.extend({
} }
let lastLen = 0; let lastLen = 0;
let retCode = -1; let retCode = -1;
let timerBusy = false;
let timer = setInterval(async () => { let timer = setInterval(async () => {
if (timerBusy)
return; // skip iteration
timerBusy = true;
try { try {
let res = await fs.exec('/bin/cat', [ logFile ], null, rpc_opt); let res = await fs.exec('/bin/cat', [ logFile ], null, rpc_opt);
if (res.stdout && res.stdout.length > lastLen) { if (res.stdout && res.stdout.length > lastLen) {
@@ -167,9 +171,16 @@ return baseclass.extend({
this.setStage(999); this.setStage(999);
} }
} catch (e) { } catch (e) {
if (e.message?.includes('RPC call to file/exec failed with error -32000: Object not found')) {
console.warn('WARN: installUpdates: ' + e.message);
return; // goto next timer iteration
}
clearInterval(timer); clearInterval(timer);
this.appendLog('ERROR: installUpdates: ' + e.message); this.appendLog('ERROR: installUpdates: ' + e.message);
this.appendLog('ERROR: installUpdates: ' + e.stack?.trim().split('\n')[0]);
this.setStage(999); this.setStage(999);
} finally {
timerBusy = false;
} }
}, 500); }, 500);
}, },

View File

@@ -0,0 +1,46 @@
{
"admin/services/zapret": {
"title": "Zapret",
"order": 61,
"action": {
"type": "alias",
"path": "admin/services/zapret/service"
},
"depends": {
"acl": [ "luci-app-zapret" ],
"fs": {
"/opt/zapret/sync_config.sh": "executable",
"/opt/zapret/restore-def-cfg.sh": "executable",
"/etc/init.d/zapret": "executable"
},
"uci": { "zapret": true }
}
},
"admin/services/zapret/service": {
"title": "Service",
"order": 10,
"action": {
"type": "view",
"path": "zapret/service"
}
},
"admin/services/zapret/settings": {
"title": "Settings",
"order": 20,
"action": {
"type": "view",
"path": "zapret/settings"
}
},
"admin/services/zapret/dmnlog": {
"title": "Log Viewer",
"order": 30,
"action": {
"type": "view",
"path": "zapret/dmnlog"
}
}
}

View File

@@ -1,41 +0,0 @@
{
"admin/services/zapret2": {
"title": "Zapret2",
"order": 62,
"action": {
"type": "alias",
"path": "admin/services/zapret2/service"
},
"depends": {
"acl": [ "luci-app-zapret2" ],
"uci": { "zapret2": true }
}
},
"admin/services/zapret2/service": {
"title": "Service",
"order": 10,
"action": {
"type": "view",
"path": "zapret2/service"
}
},
"admin/services/zapret2/settings": {
"title": "Settings",
"order": 20,
"action": {
"type": "view",
"path": "zapret2/settings"
}
},
"admin/services/zapret2/dmnlog": {
"title": "Log Viewer",
"order": 30,
"action": {
"type": "view",
"path": "zapret2/dmnlog"
}
}
}

View File

@@ -0,0 +1,40 @@
{
"luci-app-zapret": {
"description": "Grant access to zapret procedures",
"read": {
"cgi-io": [ "exec" ],
"file": {
"/opt/zapret/config": [ "read" ],
"/opt/zapret/ipset/*": [ "read" ],
"/opt/zapret/init.d/openwrt/custom.d/*": [ "read" ],
"/etc/crontabs/root": [ "read" ],
"/tmp/zapret*": [ "read" ],
"/etc/init.d/zapret*": [ "exec" ],
"/bin/ps*": [ "exec" ],
"/bin/cat*": [ "exec" ],
"/bin/busybox*": [ "exec" ],
"/bin/opkg*": [ "exec" ],
"/usr/bin/apk*": [ "exec" ],
"/usr/bin/find*": [ "exec" ],
"/opt/zapret/restore-def-cfg.sh*": [ "exec" ],
"/opt/zapret/script-exec.sh*": [ "exec" ],
"/opt/zapret/update-pkg.sh*": [ "exec" ],
"/opt/zapret/sync_config.sh*": [ "exec" ]
},
"uci": [ "zapret", "network" ],
"ubus": {
"luci": [ "getInitList", "setInitAction" ],
"service": [ "list" ]
}
},
"write": {
"file": {
"/opt/zapret/config": [ "write" ],
"/opt/zapret/ipset/*": [ "write" ],
"/opt/zapret/init.d/openwrt/custom.d/*": [ "write" ],
"/etc/crontabs/root": [ "write" ]
},
"uci": [ "zapret" ]
}
}
}

View File

@@ -1,40 +0,0 @@
{
"luci-app-zapret2": {
"description": "Grant access to zapret2 procedures",
"read": {
"cgi-io": [ "exec" ],
"file": {
"/opt/zapret2/config": [ "read" ],
"/opt/zapret2/ipset/*": [ "read" ],
"/opt/zapret2/init.d/openwrt/custom.d/*": [ "read" ],
"/etc/crontabs/root": [ "read" ],
"/tmp/zapret*": [ "read" ],
"/etc/init.d/zapret2*": [ "exec" ],
"/bin/ps*": [ "exec" ],
"/bin/cat*": [ "exec" ],
"/bin/busybox*": [ "exec" ],
"/bin/opkg*": [ "exec" ],
"/usr/bin/apk*": [ "exec" ],
"/usr/bin/find*": [ "exec" ],
"/opt/zapret2/restore-def-cfg.sh*": [ "exec" ],
"/opt/zapret2/script-exec.sh*": [ "exec" ],
"/opt/zapret2/update-pkg.sh*": [ "exec" ],
"/opt/zapret2/sync_config.sh*": [ "exec" ]
},
"uci": [ "zapret2", "network" ],
"ubus": {
"luci": [ "getInitList", "setInitAction" ],
"service": [ "list" ]
}
},
"write": {
"file": {
"/opt/zapret2/config": [ "write" ],
"/opt/zapret2/ipset/*": [ "write" ],
"/opt/zapret2/init.d/openwrt/custom.d/*": [ "write" ],
"/etc/crontabs/root": [ "write" ]
},
"uci": [ "zapret2" ]
}
}
}

View File

@@ -1,45 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=zapret2-ip2net
PKG_VERSION:=0.7.20251224
PKG_RELEASE:=1
PKG_MAINTAINER:=bol-van
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=docs/LICENSE.txt
PKG_SOURCE_URL:=https://github.com/bol-van/zapret2.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=505e8ff82ca92457d18daf90671d0f589929405b
PKG_SOURCE_DATE:=2025-12-24
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
#PKG_SOURCE_URL:=https://github.com/bol-van/zapret2/archive/refs/tags/v$(PKG_VERSION).tar.gz?
#PKG_HASH:=skip
include $(INCLUDE_DIR)/package.mk
#TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
#TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
MAKE_PATH:=ip2net
define Package/$(PKG_NAME)
SECTION:=net
CATEGORY:=Network
TITLE:=ip2net
SUBMENU:=Zapret2
DEPENDS:=+zlib +zapret2
endef
define Build/Prepare
$(Build/Prepare/Default)
rm -f $(PKG_BUILD_DIR)/$(MAKE_PATH)/ip2net
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/opt/zapret2/ip2net
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/ip2net $(1)/opt/zapret2/ip2net/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@@ -1,45 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=zapret2-mdig
PKG_VERSION:=0.7.20251224
PKG_RELEASE:=1
PKG_MAINTAINER:=bol-van
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=docs/LICENSE.txt
PKG_SOURCE_URL:=https://github.com/bol-van/zapret2.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=505e8ff82ca92457d18daf90671d0f589929405b
PKG_SOURCE_DATE:=2025-12-24
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
#PKG_SOURCE_URL:=https://github.com/bol-van/zapret2/archive/refs/tags/v$(PKG_VERSION).tar.gz?
#PKG_HASH:=skip
include $(INCLUDE_DIR)/package.mk
#TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
#TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
MAKE_PATH:=mdig
define Package/$(PKG_NAME)
SECTION:=net
CATEGORY:=Network
TITLE:=mdig
SUBMENU:=Zapret2
DEPENDS:=+zlib +zapret2
endef
define Build/Prepare
$(Build/Prepare/Default)
rm -f $(PKG_BUILD_DIR)/$(MAKE_PATH)/mdig
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/opt/zapret2/mdig
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/mdig $(1)/opt/zapret2/mdig/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@@ -1,55 +1,40 @@
# #
# Copyright (c) 2025 remittor # Copyright (c) 2024 remittor
# #
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=zapret2 PKG_NAME:=zapret
PKG_VERSION:=0.7.20251224 PKG_VERSION:=72.20260108
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=bol-van PKG_MAINTAINER:=bol-van
PKG_LICENSE:=MIT PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=docs/LICENSE.txt PKG_LICENSE_FILES:=docs/LICENSE.txt
PKG_SOURCE_URL:=https://github.com/bol-van/zapret2.git PKG_SOURCE_URL:=https://github.com/bol-van/zapret.git
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=505e8ff82ca92457d18daf90671d0f589929405b PKG_SOURCE_VERSION:=16ac0587a4c7d823be4d947d2bbebdbf445d770c
PKG_SOURCE_DATE:=2025-12-24 PKG_SOURCE_DATE:=2026-01-08
#PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz #PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
#PKG_SOURCE_URL:=https://github.com/bol-van/zapret2/archive/refs/tags/v$(PKG_VERSION).tar.gz? #PKG_SOURCE_URL:=https://github.com/bol-van/zapret/archive/refs/tags/v$(PKG_VERSION).tar.gz?
#PKG_HASH:=skip #PKG_HASH:=skip
LUA_JIT?=1
ifeq ($(LUA_JIT),1)
LUAJIT_VER?=2.1
LUA_VER?=5.1
LUA_DEPEND:=luajit
LUA_INCLUDE:=-I$(STAGING_DIR)/usr/include/luajit-$(LUAJIT_VER)
LUA_LIBRARY:=-L$(STAGING_DIR)/usr/lib -lluajit-$(LUA_VER)
else
LUA_VER?=5.3
LUA_DEPEND:=lua$(LUA_VER)
LUA_INCLUDE:=-I$(STAGING_DIR)/usr/include/lua$(LUA_VER)
LUA_LIBRARY:=-L$(STAGING_DIR)/usr/lib -llua$(LUA_VER)
endif
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
#TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS) #TAR_OPTIONS:=--strip-components 1 $(TAR_OPTIONS)
#TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS) #TAR_CMD=$(HOST_TAR) -C $(1) $(TAR_OPTIONS)
MAKE_PATH:=nfq2 MAKE_PATH:=nfq
define Package/$(PKG_NAME) define Package/$(PKG_NAME)
SECTION:=net SECTION:=net
CATEGORY:=Network CATEGORY:=Network
TITLE:=$(PKG_NAME) TITLE:=$(PKG_NAME)
SUBMENU:=Zapret2 SUBMENU:=Zapret
URL:=https://github.com/bol-van/zapret2 URL:=https://github.com/bol-van/zapret
DEPENDS:= +nftables +curl +gzip +$(LUA_DEPEND) DEPENDS:= +nftables +curl +gzip
DEPENDS+= +coreutils +coreutils-sort +coreutils-sleep DEPENDS+= +coreutils +coreutils-sort +coreutils-sleep
DEPENDS+= +kmod-nft-nat +kmod-nft-offload +kmod-nft-queue DEPENDS+= +kmod-nft-nat +kmod-nft-offload +kmod-nft-queue
DEPENDS+= +libnetfilter-queue +libcap +zlib DEPENDS+= +libnetfilter-queue +libcap +zlib
@@ -57,96 +42,111 @@ endef
define Build/Prepare define Build/Prepare
$(Build/Prepare/Default) $(Build/Prepare/Default)
rm -f $(PKG_BUILD_DIR)/$(MAKE_PATH)/nfqws2 rm -f $(PKG_BUILD_DIR)/$(MAKE_PATH)/nfqws
rm -f $(PKG_BUILD_DIR)/ip2net/ip2net
rm -f $(PKG_BUILD_DIR)/mdig/mdig
endef endef
#define Build/Configure #define Build/Configure
#endef #endef
define Build/Compile define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) $(TARGET_CONFIGURE_OPTS) LUA_CFLAGS="$(LUA_INCLUDE)" LUA_LIB="$(LUA_LIBRARY)" $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) $(TARGET_CONFIGURE_OPTS)
$(MAKE) -C $(PKG_BUILD_DIR)/ip2net $(TARGET_CONFIGURE_OPTS)
$(MAKE) -C $(PKG_BUILD_DIR)/mdig $(TARGET_CONFIGURE_OPTS)
endef endef
define Package/$(PKG_NAME)/conffiles define Package/$(PKG_NAME)/conffiles
/etc/config/zapret2 /etc/config/zapret
/opt/zapret2/config /opt/zapret/config
/opt/zapret2/ipset/ /opt/zapret/ipset/
/opt/zapret2/init.d/openwrt/custom.d/ /opt/zapret/init.d/openwrt/custom.d/
endef endef
define Package/$(PKG_NAME)/install define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/opt/zapret2 $(INSTALL_DIR) $(1)/opt/zapret
$(INSTALL_DIR) $(1)/opt/zapret2/$(MAKE_PATH) $(INSTALL_DIR) $(1)/opt/zapret/$(MAKE_PATH)
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/nfqws2 $(1)/opt/zapret2/$(MAKE_PATH)/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/$(MAKE_PATH)/nfqws $(1)/opt/zapret/$(MAKE_PATH)/
$(INSTALL_DIR) $(1)/opt/zapret2/common $(INSTALL_DIR) $(1)/opt/zapret/ip2net
$(CP) $(PKG_BUILD_DIR)/common/* $(1)/opt/zapret2/common/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip2net/ip2net $(1)/opt/zapret/ip2net/
$(INSTALL_DIR) $(1)/opt/zapret2/lua $(INSTALL_DIR) $(1)/opt/zapret/mdig
$(CP) $(PKG_BUILD_DIR)/lua/* $(1)/opt/zapret2/lua/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/mdig/mdig $(1)/opt/zapret/mdig/
#$(INSTALL_DIR) $(1)/opt/zapret2/docs $(INSTALL_DIR) $(1)/opt/zapret/common
#$(CP) $(PKG_BUILD_DIR)/docs/* $(1)/opt/zapret2/docs/ $(CP) $(PKG_BUILD_DIR)/common/* $(1)/opt/zapret/common/
$(INSTALL_DIR) $(1)/opt/zapret2/files #$(INSTALL_DIR) $(1)/opt/zapret/docs
$(CP) $(PKG_BUILD_DIR)/files/* $(1)/opt/zapret2/files/ #$(CP) $(PKG_BUILD_DIR)/docs/* $(1)/opt/zapret/docs/
$(CP) ./files/* $(1)/opt/zapret2/files/ $(INSTALL_DIR) $(1)/opt/zapret/files
$(INSTALL_DIR) $(1)/opt/zapret2/ipset $(CP) $(PKG_BUILD_DIR)/files/* $(1)/opt/zapret/files/
$(CP) $(PKG_BUILD_DIR)/ipset/* $(1)/opt/zapret2/ipset/ $(CP) ./files/* $(1)/opt/zapret/files/
$(INSTALL_DIR) $(1)/opt/zapret2/blockcheck2.d $(INSTALL_DIR) $(1)/opt/zapret/ipset
$(CP) $(PKG_BUILD_DIR)/blockcheck2.d/* $(1)/opt/zapret2/blockcheck2.d/ $(CP) $(PKG_BUILD_DIR)/ipset/* $(1)/opt/zapret/ipset/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/blockcheck2.sh $(1)/opt/zapret2/blockcheck2.sh $(INSTALL_BIN) $(PKG_BUILD_DIR)/blockcheck.sh $(1)/opt/zapret/blockcheck.sh
#$(INSTALL_DATA) $(PKG_BUILD_DIR)/config.default $(1)/opt/zapret2/config.default #$(INSTALL_DATA) $(PKG_BUILD_DIR)/config.default $(1)/opt/zapret/config.default
$(INSTALL_DIR) $(1)/opt/zapret2/tmp $(INSTALL_DIR) $(1)/opt/zapret/tmp
$(INSTALL_DIR) $(1)/opt/zapret2/init.d/openwrt $(INSTALL_DIR) $(1)/opt/zapret/init.d/openwrt
$(CP) $(PKG_BUILD_DIR)/init.d/openwrt/* $(1)/opt/zapret2/init.d/openwrt/ $(CP) $(PKG_BUILD_DIR)/init.d/openwrt/* $(1)/opt/zapret/init.d/openwrt/
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/openwrt/90-zapret2 $(1)/etc/hotplug.d/iface/90-zapret2 $(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/openwrt/90-zapret $(1)/etc/hotplug.d/iface/90-zapret
$(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./init.d.sh $(1)/etc/init.d/zapret2 $(INSTALL_BIN) ./init.d.sh $(1)/etc/init.d/zapret
$(INSTALL_DATA) ./config.default $(1)/opt/zapret2/config.default $(INSTALL_DATA) ./config.default $(1)/opt/zapret/config.default
$(INSTALL_DATA) ./ipset/zapret-hosts-google.txt $(1)/opt/zapret2/ipset/zapret-hosts-google.txt $(INSTALL_DATA) ./ipset/zapret-hosts-google.txt $(1)/opt/zapret/ipset/zapret-hosts-google.txt
$(INSTALL_DATA) ./ipset/zapret-hosts-user.txt $(1)/opt/zapret2/ipset/zapret-hosts-user.txt $(INSTALL_DATA) ./ipset/zapret-hosts-user.txt $(1)/opt/zapret/ipset/zapret-hosts-user.txt
$(INSTALL_DATA) ./ipset/zapret-hosts-user-exclude.txt $(1)/opt/zapret2/ipset/zapret-hosts-user-exclude.txt $(INSTALL_DATA) ./ipset/zapret-hosts-user-exclude.txt $(1)/opt/zapret/ipset/zapret-hosts-user-exclude.txt
$(INSTALL_DATA) ./ipset/zapret-ip-exclude.txt $(1)/opt/zapret2/ipset/zapret-ip-exclude.txt $(INSTALL_DATA) ./ipset/zapret-ip-exclude.txt $(1)/opt/zapret/ipset/zapret-ip-exclude.txt
$(INSTALL_DIR) $(1)/opt/zapret2/ipset_def $(INSTALL_DIR) $(1)/opt/zapret/ipset_def
$(INSTALL_DATA) ./ipset/zapret-hosts-google.txt $(1)/opt/zapret2/ipset_def/zapret-hosts-google.txt $(INSTALL_DATA) ./ipset/zapret-hosts-google.txt $(1)/opt/zapret/ipset_def/zapret-hosts-google.txt
$(INSTALL_DATA) ./ipset/zapret-hosts-user.txt $(1)/opt/zapret2/ipset_def/zapret-hosts-user.txt $(INSTALL_DATA) ./ipset/zapret-hosts-user.txt $(1)/opt/zapret/ipset_def/zapret-hosts-user.txt
$(INSTALL_DATA) ./ipset/zapret-hosts-user-exclude.txt $(1)/opt/zapret2/ipset_def/zapret-hosts-user-exclude.txt $(INSTALL_DATA) ./ipset/zapret-hosts-user-exclude.txt $(1)/opt/zapret/ipset_def/zapret-hosts-user-exclude.txt
$(INSTALL_DATA) ./ipset/zapret-ip-exclude.txt $(1)/opt/zapret2/ipset_def/zapret-ip-exclude.txt $(INSTALL_DATA) ./ipset/zapret-ip-exclude.txt $(1)/opt/zapret/ipset_def/zapret-ip-exclude.txt
$(INSTALL_DIR) $(1)/opt/zapret2/init.d $(INSTALL_DIR) $(1)/opt/zapret/init.d
$(INSTALL_DIR) $(1)/opt/zapret2/init.d/openwrt $(INSTALL_DIR) $(1)/opt/zapret/init.d/openwrt
$(INSTALL_DIR) $(1)/opt/zapret2/init.d/openwrt/custom.d $(INSTALL_DIR) $(1)/opt/zapret/init.d/openwrt/custom.d
$(CP) ./custom.d/* $(1)/opt/zapret2/init.d/openwrt/custom.d/ $(CP) ./custom.d/* $(1)/opt/zapret/init.d/openwrt/custom.d/
$(INSTALL_DIR) $(1)/etc/uci-defaults $(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./uci-def-cfg.sh $(1)/etc/uci-defaults/zapret2-uci-def-cfg.sh $(INSTALL_BIN) ./uci-def-cfg.sh $(1)/etc/uci-defaults/zapret-uci-def-cfg.sh
$(INSTALL_BIN) ./uci-def-cfg.sh $(1)/opt/zapret2/uci-def-cfg.sh $(INSTALL_BIN) ./uci-def-cfg.sh $(1)/opt/zapret/uci-def-cfg.sh
$(INSTALL_BIN) ./comfunc.sh $(1)/opt/zapret2/comfunc.sh $(INSTALL_BIN) ./comfunc.sh $(1)/opt/zapret/comfunc.sh
$(INSTALL_BIN) ./def-cfg.sh $(1)/opt/zapret2/def-cfg.sh $(INSTALL_BIN) ./def-cfg.sh $(1)/opt/zapret/def-cfg.sh
$(INSTALL_BIN) ./renew-cfg.sh $(1)/opt/zapret2/renew-cfg.sh $(INSTALL_BIN) ./renew-cfg.sh $(1)/opt/zapret/renew-cfg.sh
$(INSTALL_BIN) ./restore-def-cfg.sh $(1)/opt/zapret2/restore-def-cfg.sh $(INSTALL_BIN) ./restore-def-cfg.sh $(1)/opt/zapret/restore-def-cfg.sh
$(INSTALL_BIN) ./sync_config.sh $(1)/opt/zapret2/sync_config.sh $(INSTALL_BIN) ./sync_config.sh $(1)/opt/zapret/sync_config.sh
$(INSTALL_BIN) ./script-exec.sh $(1)/opt/zapret2/script-exec.sh $(INSTALL_BIN) ./script-exec.sh $(1)/opt/zapret/script-exec.sh
$(INSTALL_BIN) ./update-pkg.sh $(1)/opt/zapret2/update-pkg.sh $(INSTALL_BIN) ./update-pkg.sh $(1)/opt/zapret/update-pkg.sh
# Fix permisions # Fix permisions
chmod 644 $(1)/opt/zapret2/ipset/*.txt chmod 644 $(1)/opt/zapret/ipset/*.txt
chmod 644 $(1)/opt/zapret2/ipset_def/*.txt chmod 644 $(1)/opt/zapret/ipset_def/*.txt
chmod 644 $(1)/opt/zapret2/init.d/openwrt/custom.d/*.sh chmod 644 $(1)/opt/zapret/init.d/openwrt/custom.d/*.sh
chmod 644 $(1)/opt/zapret2/config.default chmod 644 $(1)/opt/zapret/config.default
chmod 755 $(1)/opt/zapret2/*.sh chmod 755 $(1)/opt/zapret/*.sh
chmod 755 $(1)/opt/zapret/$(MAKE_PATH)/*
chmod 755 $(1)/opt/zapret/ip2net/*
chmod 755 $(1)/opt/zapret/mdig/*
endef endef
define Package/$(PKG_NAME)/preinst define Package/$(PKG_NAME)/preinst
#!/bin/sh #!/bin/sh
# check if we are on real system # check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then if [ -z "$${IPKG_INSTROOT}" ]; then
if [ -f "/etc/init.d/zapret2" ]; then if [ -f "/etc/init.d/zapret" ]; then
SCRIPT=$$( readlink /etc/init.d/zapret2 ) SCRIPT=$$( readlink /etc/init.d/zapret )
if [ -n "$${SCRIPT}" ]; then if [ -n "$${SCRIPT}" ]; then
echo "Please uninstall original zapret2 utility!" echo "Please uninstall original zapret utility!"
exit 44 exit 44
fi fi
fi fi
if [ "$${PKG_UPGRADE}" = "1" ]; then if [ "$${PKG_UPGRADE}" = "1" ]; then
# stop service if PKG_UPGRADE # stop service if PKG_UPGRADE
if [ -x "/etc/init.d/zapret2" ]; then if [ -x "/etc/init.d/zapret" ]; then
/etc/init.d/zapret2 running && /etc/init.d/zapret2 stop >/dev/null 2>&1 /etc/init.d/zapret running && /etc/init.d/zapret stop >/dev/null 2>&1
fi
fi
if [ ! -f "/opt/zapret/ipset/zapret-hosts-google.txt" ]; then
if [ -f "/opt/zapret/ipset/zapret-hosts-user.txt" ]; then
CFGLISTHASH=$$( md5sum "/opt/zapret/ipset/zapret-hosts-user.txt" | awk '{print $$1;}' )
if [ "$${CFGLISTHASH}" = "79e35df62b0d1ae455d0a7e04c4cecac" ]; then
rm -f "/opt/zapret/ipset/zapret-hosts-user.txt"
fi
fi fi
fi fi
fi fi
@@ -157,32 +157,40 @@ define Package/$(PKG_NAME)/postinst
#!/bin/sh #!/bin/sh
# check if we are on real system # check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then if [ -z "$${IPKG_INSTROOT}" ]; then
ZAPRET_CONFIG=/opt/zapret2/config ZAPRET_CONFIG=/opt/zapret/config
ZAPRET_CONFIG_DEF="/opt/zapret2/config.default" ZAPRET_CONFIG_DEF="/opt/zapret/config.default"
# creating main config if its not exists # creating main config if its not exists
if [ ! -f "$${ZAPRET_CONFIG}" ]; then if [ ! -f "$${ZAPRET_CONFIG}" ]; then
cp -f "$${ZAPRET_CONFIG_DEF}" "$${ZAPRET_CONFIG}" cp -f "$${ZAPRET_CONFIG_DEF}" "$${ZAPRET_CONFIG}"
fi fi
# check obsolete format for main config
if grep -qE "^NFQWS_OPT_DESYNC=|^MODE_HTTP=|^MODE_HTTPS=|^MODE_QUIC=|^MODE=" "$${ZAPRET_CONFIG}" ; then
echo "Detect obsolute format for main config!"
ZAPRET_CONFIG_BACKUP="$${ZAPRET_CONFIG}.backup"
cp -f "$${ZAPRET_CONFIG}" "$${ZAPRET_CONFIG_BACKUP}"
echo "Current file $${ZAPRET_CONFIG} backuped to $${ZAPRET_CONFIG_BACKUP}"
cp -f "$${ZAPRET_CONFIG_DEF}" "$${ZAPRET_CONFIG}"
fi
# check existing uci-config # check existing uci-config
[ -f "/etc/config/zapret2" ] && ZAPRET_CFG_EXISTS=1 || ZAPRET_CFG_EXISTS=0 [ -f "/etc/config/zapret" ] && ZAPRET_CFG_EXISTS=1 || ZAPRET_CFG_EXISTS=0
# create or merge uci-config # create or merge uci-config
/opt/zapret2/uci-def-cfg.sh /opt/zapret/uci-def-cfg.sh
[ "$${ZAPRET_CFG_EXISTS}" = "1" ] && echo "Config /etc/config/zapret2 merged with default uci-config" [ "$${ZAPRET_CFG_EXISTS}" = "1" ] && echo "Config /etc/config/zapret merged with default uci-config"
# remove uci-default script from system dir (used into /etc/init.d/boot) # remove uci-default script from system dir (used into /etc/init.d/boot)
rm -f /etc/uci-defaults/zapret2-uci-def-cfg.sh rm -f /etc/uci-defaults/zapret-uci-def-cfg.sh
# copy (sync) all params from uci-config to main config # copy (sync) all params from uci-config to main config
/opt/zapret2/sync_config.sh /opt/zapret/sync_config.sh
# check main config # check main config
sh -n "$${ZAPRET_CONFIG}" 2>/dev/null || cp -f "$${ZAPRET_CONFIG_DEF}" "$${ZAPRET_CONFIG}" sh -n "$${ZAPRET_CONFIG}" 2>/dev/null || cp -f "$${ZAPRET_CONFIG_DEF}" "$${ZAPRET_CONFIG}"
sh -n "$${ZAPRET_CONFIG}" 2>/dev/null || exit 58 sh -n "$${ZAPRET_CONFIG}" 2>/dev/null || exit 58
# enable main service # enable main service
/etc/init.d/zapret2 enable /etc/init.d/zapret enable
# stop all # stop all
/etc/init.d/zapret2 stop_fw /etc/init.d/zapret stop_fw
/etc/init.d/zapret2 stop_daemons /etc/init.d/zapret stop_daemons
ps w | grep '/opt/zapret2/nfq2/nfqws2' | grep -v grep | awk '{print $$1}' | xargs -r kill -9 ps w | grep '/opt/zapret/nfq/nfqws' | grep -v grep | awk '{print $$1}' | xargs -r kill -9
# start main service # start main service
/etc/init.d/zapret2 start /etc/init.d/zapret start
# restart firewall # restart firewall
[ -x /sbin/fw4 ] && fw4 -q restart || fw3 -q restart [ -x /sbin/fw4 ] && fw4 -q restart || fw3 -q restart
fi fi
@@ -193,15 +201,15 @@ define Package/$(PKG_NAME)/prerm
#!/bin/sh #!/bin/sh
# check if we are on real system # check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then if [ -z "$${IPKG_INSTROOT}" ]; then
EXEDIR=/opt/zapret2 EXEDIR=/opt/zapret
ZAPRET_BASE=/opt/zapret2 ZAPRET_BASE=/opt/zapret
ZAPRET_CONFIG=/opt/zapret2/config ZAPRET_CONFIG=/opt/zapret/config
ZAPRET_CONFIG_DEF="/opt/zapret2/config.default" ZAPRET_CONFIG_DEF="/opt/zapret/config.default"
OPENWRT_FW_INCLUDE=/etc/firewall.zapret2 OPENWRT_FW_INCLUDE=/etc/firewall.zapret
# check main config # check main config
sh -n "$${ZAPRET_CONFIG}" 2>/dev/null || cp -f "$${ZAPRET_CONFIG_DEF}" "$${ZAPRET_CONFIG}" sh -n "$${ZAPRET_CONFIG}" 2>/dev/null || cp -f "$${ZAPRET_CONFIG_DEF}" "$${ZAPRET_CONFIG}"
if ! sh -n "$${ZAPRET_CONFIG}" 2>/dev/null ; then if ! sh -n "$${ZAPRET_CONFIG}" 2>/dev/null ; then
ps w | grep '/opt/zapret2/nfq2/nfqws2' | grep -v grep | awk '{print $$1}' | xargs -r kill -9 ps w | grep '/opt/zapret/nfq/nfqws' | grep -v grep | awk '{print $$1}' | xargs -r kill -9
exit 0 exit 0
fi fi
. "$${ZAPRET_CONFIG}" . "$${ZAPRET_CONFIG}"
@@ -209,9 +217,9 @@ if [ -z "$${IPKG_INSTROOT}" ]; then
. "$${ZAPRET_BASE}/common/fwtype.sh" . "$${ZAPRET_BASE}/common/fwtype.sh"
. "$${ZAPRET_BASE}/common/nft.sh" . "$${ZAPRET_BASE}/common/nft.sh"
. "$${ZAPRET_BASE}/common/installer.sh" . "$${ZAPRET_BASE}/common/installer.sh"
/etc/init.d/zapret2 running && /etc/init.d/zapret2 stop /etc/init.d/zapret running && /etc/init.d/zapret stop
/etc/init.d/zapret2 disable /etc/init.d/zapret disable
ps w | grep '/opt/zapret2/nfq2/nfqws2' | grep -v grep | awk '{print $$1}' | xargs -r kill -9 ps w | grep '/opt/zapret/nfq/nfqws' | grep -v grep | awk '{print $$1}' | xargs -r kill -9
remove_openwrt_firewall remove_openwrt_firewall
nft_del_table nft_del_table
restart_openwrt_firewall restart_openwrt_firewall
@@ -223,10 +231,10 @@ define Package/$(PKG_NAME)/postrm
#!/bin/sh #!/bin/sh
# check if we are on real system # check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then if [ -z "$${IPKG_INSTROOT}" ]; then
[ -f "/etc/config/zapret2-opkg" ] && rm -f "/etc/config/zapret2-opkg" [ -f "/etc/config/zapret-opkg" ] && rm -f "/etc/config/zapret-opkg"
[ -f "/opt/zapret2/config" ] && cp -f /opt/zapret2/config "/opt/zapret2/config.backup" [ -f "/opt/zapret/config" ] && cp -f /opt/zapret/config "/opt/zapret/config.backup"
#rm -rf /opt/zapret2 #rm -rf /opt/zapret
#echo "Directory /opt/zapret2 removed!" #echo "Directory /opt/zapret removed!"
fi fi
exit 0 exit 0
endef endef

View File

@@ -1,19 +1,22 @@
#!/bin/sh #!/bin/sh
# Copyright (c) 2024 remittor # Copyright (c) 2024 remittor
EXEDIR=/opt/zapret2 EXEDIR=/opt/zapret
ZAPRET_BASE=/opt/zapret2 ZAPRET_BASE=/opt/zapret
ZAPRET_INITD=/etc/init.d/zapret2 ZAPRET_INITD=/etc/init.d/zapret
ZAPRET_ORIG_INITD="$ZAPRET_BASE/init.d/openwrt/zapret2" ZAPRET_ORIG_INITD="$ZAPRET_BASE/init.d/openwrt/zapret"
ZAP_LOG_TAG=ZAPRET
ZAPRET_CONFIG="$ZAPRET_BASE/config" ZAPRET_CONFIG="$ZAPRET_BASE/config"
ZAPRET_CONFIG_NEW="$ZAPRET_BASE/config.new" ZAPRET_CONFIG_NEW="$ZAPRET_BASE/config.new"
ZAPRET_CONFIG_DEF="$ZAPRET_BASE/config.default" ZAPRET_CONFIG_DEF="$ZAPRET_BASE/config.default"
ZAPRET_CFG=/etc/config/zapret2 ZAPRET_CFG=/etc/config/zapret
ZAPRET_CFG_NAME=zapret2 ZAPRET_CFG_NAME=zapret
ZAPRET_CFG_SEC_NAME="$( uci -q get $ZAPRET_CFG_NAME.config )" ZAPRET_CFG_SEC=$ZAPRET_CFG_NAME.config
ZAPRET_CFG_SEC_NAME="$( uci -q get $ZAPRET_CFG_SEC )"
. $ZAPRET_BASE/def-cfg.sh . $ZAPRET_BASE/def-cfg.sh
@@ -148,7 +151,7 @@ function merge_cfg_with_def_values
local cfgname=${1:-$ZAPRET_CFG_NAME} local cfgname=${1:-$ZAPRET_CFG_NAME}
local force=$2 local force=$2
local cfgfile=/etc/config/$cfgname local cfgfile=/etc/config/$cfgname
local NEWCFGNAME="zapret2-default" local NEWCFGNAME="$ZAPRET_CFG_NAME-default"
local NEWCFGFILE="/etc/config/$NEWCFGNAME" local NEWCFGFILE="/etc/config/$NEWCFGNAME"
local cfg_sec_name="$( uci -q get $ZAPRET_CFG_NAME.config )" local cfg_sec_name="$( uci -q get $ZAPRET_CFG_NAME.config )"
@@ -168,7 +171,7 @@ function merge_cfg_with_def_values
function remove_cron_task_logs function remove_cron_task_logs
{ {
if [ -f "$CRONTAB_FILE" ]; then if [ -f "$CRONTAB_FILE" ]; then
sed -i "/-name 'zapret2+\*.log' -size +/d" "$CRONTAB_FILE" sed -i "/-name '$ZAPRET_CFG_NAME+\*.log' -size +/d" "$CRONTAB_FILE"
fi fi
} }
@@ -176,8 +179,8 @@ function insert_cron_task_logs
{ {
[ ! -f "$CRONTAB_FILE" ] && touch "$CRONTAB_FILE" [ ! -f "$CRONTAB_FILE" ] && touch "$CRONTAB_FILE"
[ ! -f "$CRONTAB_FILE" ] && return 1 [ ! -f "$CRONTAB_FILE" ] && return 1
if ! grep -q -e "-name 'zapret2\*\.log' -size \+" "$CRONTAB_FILE"; then if ! grep -q -e "-name '$ZAPRET_CFG_NAME\*\.log' -size \+" "$CRONTAB_FILE"; then
echo "*/2 * * * * /usr/bin/find /tmp -maxdepth 1 -type f -name 'zapret2+*.log' -size +2600k -exec rm -f {} \;" >> "$CRONTAB_FILE" echo "*/2 * * * * /usr/bin/find /tmp -maxdepth 1 -type f -name '$ZAPRET_CFG_NAME+*.log' -size +2600k -exec rm -f {} \;" >> "$CRONTAB_FILE"
/etc/init.d/cron restart 2> /dev/null /etc/init.d/cron restart 2> /dev/null
fi fi
return 0 return 0
@@ -190,7 +193,7 @@ function init_before_start
[ ! -f "$HOSTLIST_FN" ] && touch "$HOSTLIST_FN" [ ! -f "$HOSTLIST_FN" ] && touch "$HOSTLIST_FN"
chmod 644 $ZAPRET_BASE/ipset/*.txt chmod 644 $ZAPRET_BASE/ipset/*.txt
chmod 666 $ZAPRET_BASE/ipset/*.log chmod 666 $ZAPRET_BASE/ipset/*.log
rm -f /tmp/zapret2+*.log rm -f /tmp/$ZAPRET_CFG_NAME+*.log
#*/ #*/
if [ "$DAEMON_LOG_ENABLE" = "1" ]; then if [ "$DAEMON_LOG_ENABLE" = "1" ]; then
insert_cron_task_logs insert_cron_task_logs

View File

@@ -30,15 +30,9 @@ IP2NET_OPT4="--prefix-length=22-30 --v4-threshold=3/4"
IP2NET_OPT6="--prefix-length=56-64 --v6-threshold=5" IP2NET_OPT6="--prefix-length=56-64 --v6-threshold=5"
# options for auto hostlist # options for auto hostlist
# NOTE : in order for these adjustment to work it's required to redirect enough starting packets
# NOTE : set PKT_IN, PKT_OUT variables appropriately
AUTOHOSTLIST_INCOMING_MAXSEQ=4096
AUTOHOSTLIST_RETRANS_MAXSEQ=32768
AUTOHOSTLIST_RETRANS_THRESHOLD=3 AUTOHOSTLIST_RETRANS_THRESHOLD=3
AUTOHOSTLIST_FAIL_THRESHOLD=3 AUTOHOSTLIST_FAIL_THRESHOLD=3
AUTOHOSTLIST_FAIL_TIME=60 AUTOHOSTLIST_FAIL_TIME=60
AUTOHOSTLIST_UDP_IN=1
AUTOHOSTLIST_UDP_OUT=4
# 1 = debug autohostlist positives to ipset/zapret-hosts-auto-debug.log # 1 = debug autohostlist positives to ipset/zapret-hosts-auto-debug.log
AUTOHOSTLIST_DEBUGLOG=0 AUTOHOSTLIST_DEBUGLOG=0
@@ -69,31 +63,47 @@ DESYNC_MARK_POSTNAT=0x20000000
FILTER_MARK="" FILTER_MARK=""
NFQWS2_ENABLE=1 TPWS_SOCKS_ENABLE=0
# tpws socks listens on this port on localhost and LAN interfaces
TPPORT_SOCKS=987
# use <HOSTLIST> and <HOSTLIST_NOAUTO> placeholders to engage standard hostlists and autohostlist in ipset dir
# hostlist markers are replaced to empty string if MODE_FILTER does not satisfy
# <HOSTLIST_NOAUTO> appends ipset/zapret-hosts-auto.txt as normal list
TPWS_SOCKS_OPT="--filter-tcp=80 --methodeol <HOSTLIST> --new --filter-tcp=443 --split-tls=sni --disorder <HOSTLIST>"
TPWS_ENABLE=0
TPWS_PORTS="80,443"
# use <HOSTLIST> and <HOSTLIST_NOAUTO> placeholders to engage standard hostlists and autohostlist in ipset dir
# hostlist markers are replaced to empty string if MODE_FILTER does not satisfy
# <HOSTLIST_NOAUTO> appends ipset/zapret-hosts-auto.txt as normal list
TPWS_OPT="--filter-tcp=80 --methodeol <HOSTLIST> --new --filter-tcp=443 --split-tls=sni --disorder <HOSTLIST>"
NFQWS_ENABLE=1
# redirect outgoing traffic with connbytes limiter applied in both directions. # redirect outgoing traffic with connbytes limiter applied in both directions.
NFQWS2_PORTS_TCP="80,443" NFQWS_PORTS_TCP="80,443"
NFQWS2_PORTS_UDP="443" NFQWS_PORTS_UDP="443"
# PKT_OUT means connbytes dir original # PKT_OUT means connbytes dir original
# PKT_IN means connbytes dir reply # PKT_IN means connbytes dir reply
# this is --dpi-desync-cutoff=nX kernel mode implementation for linux. it saves a lot of CPU. # this is --dpi-desync-cutoff=nX kernel mode implementation for linux. it saves a lot of CPU.
NFQWS2_TCP_PKT_OUT="9" NFQWS_TCP_PKT_OUT="9"
NFQWS2_TCP_PKT_IN="3" NFQWS_TCP_PKT_IN="3"
NFQWS2_UDP_PKT_OUT="9" NFQWS_UDP_PKT_OUT="9"
NFQWS2_UDP_PKT_IN="0" NFQWS_UDP_PKT_IN="0"
# redirect outgoing traffic without connbytes limiter and incoming with connbytes limiter # redirect outgoing traffic without connbytes limiter and incoming with connbytes limiter
# normally it's needed only for stateless DPI that matches every packet in a single TCP session # normally it's needed only for stateless DPI that matches every packet in a single TCP session
# typical example are plain HTTP keep alives # typical example are plain HTTP keep alives
# this mode can be very CPU consuming. enable with care ! # this mode can be very CPU consuming. enable with care !
NFQWS2_PORTS_TCP_KEEPALIVE="" NFQWS_PORTS_TCP_KEEPALIVE=""
NFQWS2_PORTS_UDP_KEEPALIVE="" NFQWS_PORTS_UDP_KEEPALIVE=""
# use <HOSTLIST> and <HOSTLIST_NOAUTO> placeholders to engage standard hostlists and autohostlist in ipset dir # use <HOSTLIST> and <HOSTLIST_NOAUTO> placeholders to engage standard hostlists and autohostlist in ipset dir
# hostlist markers are replaced to empty string if MODE_FILTER does not satisfy # hostlist markers are replaced to empty string if MODE_FILTER does not satisfy
# <HOSTLIST_NOAUTO> appends ipset/zapret-hosts-auto.txt as normal list # <HOSTLIST_NOAUTO> appends ipset/zapret-hosts-auto.txt as normal list
NFQWS2_OPT="--filter-tcp=80 --filter-l7=http <HOSTLIST> --payload=http_req --lua-desync=fake:blob=fake_default_http:tcp_md5 --lua-desync=multisplit:pos=method+2 --new --filter-tcp=443 --filter-l7=tls <HOSTLIST> --payload=tls_client_hello --lua-desync=fake:blob=fake_default_tls:tcp_md5:tcp_seq=-10000 --lua-desync=multidisorder:pos=1,midsld --new --filter-udp=443 --filter-l7=quic <HOSTLIST_NOAUTO> --payload=quic_initial --lua-desync=fake:blob=fake_default_quic:repeats=6" NFQWS_OPT="--filter-tcp=80 <HOSTLIST> --dpi-desync=fake,fakedsplit --dpi-desync-autottl=2 --dpi-desync-fooling=badsum --new --filter-tcp=443 --hostlist=/opt/zapret/ipset/zapret-hosts-google.txt --dpi-desync=fake,multidisorder --dpi-desync-split-pos=1,midsld --dpi-desync-repeats=11 --dpi-desync-fooling=badsum --dpi-desync-fake-tls-mod=rnd,dupsid,sni=www.google.com --new --filter-udp=443 --hostlist=/opt/zapret/ipset/zapret-hosts-google.txt --dpi-desync=fake --dpi-desync-repeats=11 --dpi-desync-fake-quic=/opt/zapret/files/fake/quic_initial_www_google_com.bin --new --filter-udp=443 <HOSTLIST_NOAUTO> --dpi-desync=fake --dpi-desync-repeats=11 --new --filter-tcp=443 <HOSTLIST> --dpi-desync=multidisorder --dpi-desync-split-pos=1,sniext+1,host+1,midsld-2,midsld,midsld+2,endhost-1"
DISABLE_CUSTOM=1 DISABLE_CUSTOM=1
@@ -111,8 +121,9 @@ FLOWOFFLOAD=none
# for routers based on desktop linux and macos. has no effect in openwrt. # for routers based on desktop linux and macos. has no effect in openwrt.
# CHOOSE LAN and optinally WAN/WAN6 NETWORK INTERFACES # CHOOSE LAN and optinally WAN/WAN6 NETWORK INTERFACES
# or leave them commented if its not router # or leave them commented if its not router
# it's possible to specify multiple interfaces like this : IFACE_WAN="eth0 eth1 eth2" # it's possible to specify multiple interfaces like this : IFACE_LAN="eth0 eth1 eth2"
# if IFACE_WAN6 is not defined it take the value of IFACE_WAN # if IFACE_WAN6 is not defined it take the value of IFACE_WAN
#IFACE_LAN=eth0
#IFACE_WAN=eth1 #IFACE_WAN=eth1
#IFACE_WAN6="ipsec0 wireguard0 he_net" #IFACE_WAN6="ipsec0 wireguard0 he_net"
@@ -121,10 +132,10 @@ FLOWOFFLOAD=none
INIT_APPLY_FW=1 INIT_APPLY_FW=1
# firewall apply hooks # firewall apply hooks
#INIT_FW_PRE_UP_HOOK="/etc/firewall.zapret2.hook.pre_up" #INIT_FW_PRE_UP_HOOK="/etc/firewall.zapret.hook.pre_up"
#INIT_FW_POST_UP_HOOK="/etc/firewall.zapret2.hook.post_up" #INIT_FW_POST_UP_HOOK="/etc/firewall.zapret.hook.post_up"
#INIT_FW_PRE_DOWN_HOOK="/etc/firewall.zapret2.hook.pre_down" #INIT_FW_PRE_DOWN_HOOK="/etc/firewall.zapret.hook.pre_down"
#INIT_FW_POST_DOWN_HOOK="/etc/firewall.zapret2.hook.post_down" #INIT_FW_POST_DOWN_HOOK="/etc/firewall.zapret.hook.post_down"
# do not work with ipv4 # do not work with ipv4
DISABLE_IPV4=0 DISABLE_IPV4=0
@@ -145,4 +156,4 @@ FILTER_TTL_EXPIRED_ICMP=1
DAEMON_LOG_ENABLE=0 DAEMON_LOG_ENABLE=0
DAEMON_LOG_FILE="/tmp/zapret2+<DAEMON_NAME>+<DAEMON_IDNUM>+<DAEMON_CFGNAME>.log" DAEMON_LOG_FILE="/tmp/zapret+<DAEMON_NAME>+<DAEMON_IDNUM>+<DAEMON_CFGNAME>.log"

View File

@@ -3,7 +3,7 @@
# NOTE: @ih requires nft 1.0.1+ and updated kernel version. it's confirmed to work on 5.15 (openwrt 23) and not work on 5.10 (openwrt 22) # NOTE: @ih requires nft 1.0.1+ and updated kernel version. it's confirmed to work on 5.15 (openwrt 23) and not work on 5.10 (openwrt 22)
# can override in config : # can override in config :
NFQWS_OPT_DESYNC_STUN="${NFQWS_OPT_DESYNC_STUN:---payload stun --lua-desync=fake:blob=0x00000000000000000000000000000000:repeats=2}" NFQWS_OPT_DESYNC_STUN="${NFQWS_OPT_DESYNC_STUN:---dpi-desync=fake --dpi-desync-repeats=2}"
alloc_dnum DNUM_STUN4ALL alloc_dnum DNUM_STUN4ALL
alloc_qnum QNUM_STUN4ALL alloc_qnum QNUM_STUN4ALL
@@ -17,14 +17,14 @@ zapret_custom_daemons()
} }
zapret_custom_firewall() zapret_custom_firewall()
{ {
# $1 - 1 - run, 0 - stop # $1 - 1 - run, 0 - stop
local f='-p udp -m u32 --u32' local f='-p udp -m u32 --u32'
fw_nfqws_post $1 "$f 0>>22&0x3C@4>>16=28:65535&&0>>22&0x3C@12=0x2112A442&&0>>22&0x3C@8&0xC0000003=0" "$f 44>>16=28:65535&&52=0x2112A442&&48&0xC0000003=0" $QNUM_STUN4ALL fw_nfqws_post $1 "$f 0>>22&0x3C@4>>16=28:65535&&0>>22&0x3C@12=0x2112A442&&0>>22&0x3C@8&0xC0000003=0" "$f 44>>16=28:65535&&52=0x2112A442&&48&0xC0000003=0" $QNUM_STUN4ALL
} }
zapret_custom_firewall_nft() zapret_custom_firewall_nft()
{ {
# stop logic is not required # stop logic is not required
local f="udp length >= 28 @ih,32,32 0x2112A442 @ih,0,2 0 @ih,30,2 0" local f="udp length >= 28 @ih,32,32 0x2112A442 @ih,0,2 0 @ih,30,2 0"
nft_fw_nfqws_post "$f" "$f" $QNUM_STUN4ALL nft_fw_nfqws_post "$f" "$f" $QNUM_STUN4ALL

View File

@@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# Copyright (c) 2025 remittor # Copyright (c) 2024 remittor
function set_cfg_reset_values function set_cfg_reset_values
{ {
@@ -19,29 +19,25 @@ function set_cfg_reset_values
set $cfgname.config.DISABLE_CUSTOM='1' set $cfgname.config.DISABLE_CUSTOM='1'
set $cfgname.config.WS_USER='daemon' set $cfgname.config.WS_USER='daemon'
set $cfgname.config.DAEMON_LOG_ENABLE='0' set $cfgname.config.DAEMON_LOG_ENABLE='0'
set $cfgname.config.DAEMON_LOG_FILE='/tmp/zapret2+<DAEMON_NAME>+<DAEMON_IDNUM>+<DAEMON_CFGNAME>.log' set $cfgname.config.DAEMON_LOG_FILE='/tmp/zapret+<DAEMON_NAME>+<DAEMON_IDNUM>+<DAEMON_CFGNAME>.log'
# autohostlist options # autohostlist options
set $cfgname.config.AUTOHOSTLIST_INCOMING_MAXSEQ='4096'
set $cfgname.config.AUTOHOSTLIST_RETRANS_MAXSEQ='32768'
set $cfgname.config.AUTOHOSTLIST_RETRANS_THRESHOLD='3' set $cfgname.config.AUTOHOSTLIST_RETRANS_THRESHOLD='3'
set $cfgname.config.AUTOHOSTLIST_FAIL_THRESHOLD='3' set $cfgname.config.AUTOHOSTLIST_FAIL_THRESHOLD='3'
set $cfgname.config.AUTOHOSTLIST_FAIL_TIME='60' set $cfgname.config.AUTOHOSTLIST_FAIL_TIME='60'
set $cfgname.config.AUTOHOSTLIST_UDP_IN='1'
set $cfgname.config.AUTOHOSTLIST_UDP_OUT='4'
set $cfgname.config.AUTOHOSTLIST_DEBUGLOG='0' set $cfgname.config.AUTOHOSTLIST_DEBUGLOG='0'
# nfqws options # nfqws options
set $cfgname.config.NFQWS2_ENABLE='1' set $cfgname.config.NFQWS_ENABLE='1'
set $cfgname.config.DESYNC_MARK='0x40000000' set $cfgname.config.DESYNC_MARK='0x40000000'
set $cfgname.config.DESYNC_MARK_POSTNAT='0x20000000' set $cfgname.config.DESYNC_MARK_POSTNAT='0x20000000'
set $cfgname.config.FILTER_MARK='$TAB' set $cfgname.config.FILTER_MARK='$TAB'
set $cfgname.config.NFQWS2_PORTS_TCP='80,443' set $cfgname.config.NFQWS_PORTS_TCP='80,443'
set $cfgname.config.NFQWS2_PORTS_UDP='443' set $cfgname.config.NFQWS_PORTS_UDP='443'
set $cfgname.config.NFQWS2_TCP_PKT_OUT='9' set $cfgname.config.NFQWS_TCP_PKT_OUT='9'
set $cfgname.config.NFQWS2_TCP_PKT_IN='3' set $cfgname.config.NFQWS_TCP_PKT_IN='3'
set $cfgname.config.NFQWS2_UDP_PKT_OUT='9' set $cfgname.config.NFQWS_UDP_PKT_OUT='9'
set $cfgname.config.NFQWS2_UDP_PKT_IN='0' set $cfgname.config.NFQWS_UDP_PKT_IN='0'
set $cfgname.config.NFQWS2_PORTS_TCP_KEEPALIVE='0' set $cfgname.config.NFQWS_PORTS_TCP_KEEPALIVE='0'
set $cfgname.config.NFQWS2_PORTS_UDP_KEEPALIVE='0' set $cfgname.config.NFQWS_PORTS_UDP_KEEPALIVE='0'
# save changes # save changes
commit $cfgname commit $cfgname
EOF EOF
@@ -54,9 +50,9 @@ function clear_nfqws_strat
local TAB="$( echo -n -e '\t' )" local TAB="$( echo -n -e '\t' )"
uci batch <<-EOF uci batch <<-EOF
set $cfgname.config.MODE_FILTER='hostlist' set $cfgname.config.MODE_FILTER='hostlist'
set $cfgname.config.NFQWS2_PORTS_TCP='80,443' set $cfgname.config.NFQWS_PORTS_TCP='80,443'
set $cfgname.config.NFQWS2_PORTS_UDP='443' set $cfgname.config.NFQWS_PORTS_UDP='443'
set $cfgname.config.NFQWS2_OPT='$TAB' set $cfgname.config.NFQWS_OPT='$TAB'
commit $cfgname commit $cfgname
EOF EOF
} }
@@ -74,58 +70,302 @@ function set_cfg_nfqws_strat
if [ "$strat" = "empty" ]; then if [ "$strat" = "empty" ]; then
clear_nfqws_strat $cfgname clear_nfqws_strat $cfgname
fi fi
if [ "$strat" = "default" ]; then if [ "$strat" = "v1_by_StressOzz" ]; then
uci batch <<-EOF uci batch <<-EOF
set $cfgname.config.NFQWS2_PORTS_TCP='80,443' set $cfgname.config.NFQWS_PORTS_TCP='80,443'
set $cfgname.config.NFQWS2_PORTS_UDP='443' set $cfgname.config.NFQWS_PORTS_UDP='443'
set $cfgname.config.NFQWS2_OPT=" set $cfgname.config.NFQWS_OPT="
# Strategy $strat # Strategy $strat
--filter-tcp=80 --filter-tcp=443 <HOSTLIST>
--filter-l7=http <HOSTLIST> --hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--payload=http_req --dpi-desync=fake,multidisorder
--lua-desync=fake:blob=fake_default_http:tcp_md5 --dpi-desync-split-seqovl=681
--lua-desync=multisplit:pos=method+2 --dpi-desync-split-pos=1
--dpi-desync-fooling=badseq
--new --dpi-desync-badseq-increment=10000000
--filter-tcp=443 --dpi-desync-repeats=2
--filter-l7=tls <HOSTLIST> --dpi-desync-split-seqovl-pattern=/opt/zapret/files/fake/tls_clienthello_www_google_com.bin
--payload=tls_client_hello --dpi-desync-fake-tls-mod=rnd,dupsid,sni=fonts.google.com
--lua-desync=fake:blob=fake_default_tls:tcp_md5:tcp_seq=-10000
--lua-desync=multidisorder:pos=1,midsld
--new --new
--filter-udp=443 --filter-udp=443
--filter-l7=quic <HOSTLIST_NOAUTO> --hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--payload=quic_initial --hostlist-exclude=/opt/zapret/ipset/zapret-hosts-user-exclude.txt
--lua-desync=fake:blob=fake_default_quic:repeats=6 --dpi-desync=fake
--dpi-desync-repeats=6
--dpi-desync-fake-quic=/opt/zapret/files/fake/quic_initial_www_google_com.bin
" "
commit $cfgname commit $cfgname
EOF EOF
fi fi
if [ "$strat" = "v1_by_Schiz23" ]; then if [ "$strat" = "v2_by_StressOzz" ]; then
uci batch <<-EOF uci batch <<-EOF
set $cfgname.config.NFQWS2_PORTS_TCP='80,443' set $cfgname.config.NFQWS_PORTS_TCP='80,443'
set $cfgname.config.NFQWS2_PORTS_UDP='443' set $cfgname.config.NFQWS_PORTS_UDP='443'
set $cfgname.config.NFQWS2_OPT=" set $cfgname.config.NFQWS_OPT="
# Strategy $strat # Strategy $strat
--filter-tcp=80 --filter-tcp=443 <HOSTLIST>
--filter-l7=http <HOSTLIST> --hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--payload=http_req --hostlist-exclude-domains=openwrt.org
--lua-desync=fake:blob=fake_default_http:tcp_md5 --dpi-desync=fake,fakeddisorder
--lua-desync=multisplit:pos=method+2 --dpi-desync-split-pos=10,midsld
--dpi-desync-fake-tls=/opt/zapret/files/fake/tls_clienthello_www_google_com.bin
--new --dpi-desync-fake-tls-mod=rnd,dupsid,sni=fonts.google.com
--filter-tcp=443 --dpi-desync-fake-tls=0x0F0F0F0F
--filter-l7=tls <HOSTLIST> --dpi-desync-fake-tls-mod=none
--lua-desync=fake:blob=fake_default_tls:ip_ttl=1:ip6_ttl=1:tls_mod=rnd,rndsni,padencap --dpi-desync-fakedsplit-pattern=/opt/zapret/files/fake/tls_clienthello_vk_com.bin
--lua-desync=multidisorder:payload=tls_client_hello:pos=3 --dpi-desync-split-seqovl=336
--dpi-desync-split-seqovl-pattern=/opt/zapret/files/fake/tls_clienthello_gosuslugi_ru.bin
--dpi-desync-fooling=badseq,badsum
--dpi-desync-badseq-increment=0
--new --new
--filter-udp=443 --filter-udp=443
--filter-l7=quic <HOSTLIST_NOAUTO> --hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--lua-desync=fake:blob=fake_default_quic:repeats=11:payload=all:out_range=-d10 --hostlist-exclude=/opt/zapret/ipset/zapret-hosts-user-exclude.txt
--dpi-desync=fake
--dpi-desync-repeats=6
--dpi-desync-fake-quic=/opt/zapret/files/fake/quic_initial_www_google_com.bin
"
commit $cfgname
EOF
fi
if [ "$strat" = "v3_by_StressOzz" ]; then
uci batch <<-EOF
set $cfgname.config.NFQWS_PORTS_TCP='80,443'
set $cfgname.config.NFQWS_PORTS_UDP='443'
set $cfgname.config.NFQWS_OPT="
# Strategy $strat
--filter-tcp=443 <HOSTLIST>
--hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--hostlist-exclude-domains=openwrt.org
--dpi-desync=fake,fakeddisorder
--dpi-desync-split-pos=10,midsld
--dpi-desync-fake-tls=/opt/zapret/files/fake/t2.bin
--dpi-desync-fake-tls-mod=rnd,dupsid,sni=m.ok.ru
--dpi-desync-fake-tls=0x0F0F0F0F
--dpi-desync-fake-tls-mod=none
--dpi-desync-fakedsplit-pattern=/opt/zapret/files/fake/tls_clienthello_vk_com.bin
--dpi-desync-split-seqovl=336
--dpi-desync-split-seqovl-pattern=/opt/zapret/files/fake/tls_clienthello_gosuslugi_ru.bin
--dpi-desync-fooling=badseq,badsum
--dpi-desync-badseq-increment=0
--new
--filter-udp=443
--hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--hostlist-exclude=/opt/zapret/ipset/zapret-hosts-user-exclude.txt
--dpi-desync=fake
--dpi-desync-repeats=6
--dpi-desync-fake-quic=/opt/zapret/files/fake/quic_initial_www_google_com.bin
"
commit $cfgname
EOF
fi
if [ "$strat" = "v4_by_StressOzz" ]; then
uci batch <<-EOF
set $cfgname.config.NFQWS_PORTS_TCP='80,443'
set $cfgname.config.NFQWS_PORTS_UDP='443'
set $cfgname.config.NFQWS_OPT="
# Strategy $strat
--filter-tcp=443
--hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--hostlist-exclude=/opt/zapret/ipset/zapret-hosts-user-exclude.txt
--hostlist-exclude-domains=openwrt.org
--dpi-desync=fake,multisplit
--dpi-desync-split-pos=2,sld
--dpi-desync-fake-tls=0x0F0F0F0F
--dpi-desync-fake-tls=/opt/zapret/files/fake/tls_clienthello_www_google_com.bin
--dpi-desync-fake-tls-mod=rnd,dupsid,sni=google.com
--dpi-desync-split-seqovl=2108
--dpi-desync-split-seqovl-pattern=/opt/zapret/files/fake/tls_clienthello_www_google_com.bin
--dpi-desync-fooling=badseq
--new
--filter-tcp=443 <HOSTLIST>
--hostlist-exclude-domains=openwrt.org
--dpi-desync-any-protocol=1
--dpi-desync-cutoff=n5
--dpi-desync=multisplit
--dpi-desync-split-seqovl=582
--dpi-desync-split-pos=1
--dpi-desync-split-seqovl-pattern=/opt/zapret/files/fake/4pda.bin
--new
--filter-udp=443
--hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--hostlist-exclude=/opt/zapret/ipset/zapret-hosts-user-exclude.txt
--dpi-desync=fake
--dpi-desync-repeats=6
--dpi-desync-fake-quic=/opt/zapret/files/fake/quic_initial_www_google_com.bin
"
commit $cfgname
EOF
fi
if [ "$strat" = "v5_by_StressOzz" ]; then
uci batch <<-EOF
set $cfgname.config.NFQWS_PORTS_TCP='80,443'
set $cfgname.config.NFQWS_PORTS_UDP='443'
set $cfgname.config.NFQWS_OPT="
# Strategy $strat
--filter-tcp=443
--hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--hostlist-exclude=/opt/zapret/ipset/zapret-hosts-user-exclude.txt
--hostlist-exclude-domains=openwrt.org
--ip-id=zero
--dpi-desync=multisplit
--dpi-desync-split-seqovl=681
--dpi-desync-split-pos=1
--dpi-desync-split-seqovl-pattern=/opt/zapret/files/fake/tls_clienthello_www_google_com.bin
--new
--filter-tcp=443 <HOSTLIST>
--hostlist-exclude-domains=openwrt.org
--dpi-desync=fake,fakeddisorder
--dpi-desync-split-pos=10,midsld
--dpi-desync-fake-tls=/opt/zapret/files/fake/max.bin
--dpi-desync-fake-tls-mod=rnd,dupsid
--dpi-desync-fake-tls=0x0F0F0F0F
--dpi-desync-fake-tls-mod=none
--dpi-desync-fakedsplit-pattern=/opt/zapret/files/fake/tls_clienthello_vk_com.bin
--dpi-desync-fooling=badseq,badsum
--dpi-desync-badseq-increment=0
--new
--filter-udp=443
--hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--hostlist-exclude=/opt/zapret/ipset/zapret-hosts-user-exclude.txt
--dpi-desync=fake
--dpi-desync-repeats=6
--dpi-desync-fake-quic=/opt/zapret/files/fake/quic_initial_www_google_com.bin
"
commit $cfgname
EOF
fi
if [ "$strat" = "v6_by_StressOzz" ]; then
uci batch <<-EOF
set $cfgname.config.NFQWS_PORTS_TCP='80,443,2053,2083,2087,2096,8443'
set $cfgname.config.NFQWS_PORTS_UDP='443,19294-19344,50000-50100'
set $cfgname.config.NFQWS_OPT="
# Strategy $strat
--filter-tcp=443
--hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--dpi-desync=multisplit
--dpi-desync-split-pos=1,sniext+1
--dpi-desync-split-seqovl=1
--new
--filter-tcp=443 ˂HOSTLIST˃
--dpi-desync=hostfakesplit
--dpi-desync-hostfakesplit-mod=host=rzd.ru
--dpi-desync-hostfakesplit-midhost=host-2
--dpi-desync-split-seqovl=726
--dpi-desync-fooling=badsum,badseq
--dpi-desync-badseq-increment=0
--new
--filter-udp=443 ˂HOSTLIST_NOAUTO˃
--dpi-desync=fake
--dpi-desync-repeats=6
--dpi-desync-fake-quic=/opt/zapret/files/fake/quic_initial_www_google_com.bin
--new
--filter-udp=19294-19344,50000-50100
--filter-l7=discord,stun
--dpi-desync=fake
--dpi-desync-repeats=6
--new
--filter-tcp=2053,2083,2087,2096,8443
--hostlist-domains=discord.media
--dpi-desync=multisplit
--dpi-desync-split-seqovl=652
--dpi-desync-split-pos=2
--dpi-desync-split-seqovl-pattern=/opt/zapret/files/fake/tls_clienthello_www_google_com.bin
"
commit $cfgname
EOF
fi
if [ "$strat" = "ALT7_by_Flowseal" ]; then
uci batch <<-EOF
set $cfgname.config.NFQWS_PORTS_TCP='80,443'
set $cfgname.config.NFQWS_PORTS_UDP='443'
set $cfgname.config.NFQWS_OPT="
# Strategy $strat
--filter-tcp=443
--hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--hostlist-exclude=/opt/zapret/ipset/zapret-hosts-user-exclude.txt
--hostlist-exclude-domains=openwrt.org
--ip-id=zero
--dpi-desync=multisplit
--dpi-desync-split-pos=2,sniext+1
--dpi-desync-split-seqovl=679
--dpi-desync-split-seqovl-pattern=/opt/zapret/files/fake/tls_clienthello_www_google_com.bin
--new
--filter-tcp=80,443 <HOSTLIST>
--hostlist-exclude-domains=openwrt.org
--dpi-desync=multisplit
--dpi-desync-split-pos=2,sniext+1
--dpi-desync-split-seqovl=679
--dpi-desync-split-seqovl-pattern=/opt/zapret/files/fake/tls_clienthello_www_google_com.bin
--new
--filter-udp=443
--hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--hostlist-exclude=/opt/zapret/ipset/zapret-hosts-user-exclude.txt
--dpi-desync=fake
--dpi-desync-repeats=6
--dpi-desync-fake-quic=/opt/zapret/files/fake/quic_initial_www_google_com.bin
"
commit $cfgname
EOF
fi
if [ "$strat" = "TLS_AUTO_ALT3_by_Flowseal" ]; then
uci batch <<-EOF
set $cfgname.config.NFQWS_PORTS_TCP='80,443'
set $cfgname.config.NFQWS_PORTS_UDP='443'
set $cfgname.config.NFQWS_OPT="
# Strategy $strat
--filter-tcp=443
--hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--hostlist-exclude=/opt/zapret/ipset/zapret-hosts-user-exclude.txt
--hostlist-exclude-domains=openwrt.org
--ip-id=zero
--dpi-desync=fake,multisplit
--dpi-desync-split-seqovl=681
--dpi-desync-split-pos=1
--dpi-desync-fooling=ts
--dpi-desync-repeats=8
--dpi-desync-split-seqovl-pattern=/opt/zapret/files/fake/tls_clienthello_www_google_com.bin
--dpi-desync-fake-tls-mod=rnd,dupsid,sni=www.google.com
--new
--filter-tcp=80,443 <HOSTLIST>
--hostlist-exclude-domains=openwrt.org
--dpi-desync=fake,multisplit
--dpi-desync-split-seqovl=681
--dpi-desync-split-pos=1
--dpi-desync-fooling=ts
--dpi-desync-repeats=8
--dpi-desync-split-seqovl-pattern=/opt/zapret/files/fake/tls_clienthello_www_google_com.bin
--dpi-desync-fake-tls-mod=rnd,dupsid,sni=www.google.com
--new
--filter-udp=443
--hostlist=/opt/zapret/ipset/zapret-hosts-google.txt
--hostlist-exclude=/opt/zapret/ipset/zapret-hosts-user-exclude.txt
--dpi-desync=fake
--dpi-desync-repeats=11
--dpi-desync-fake-quic=/opt/zapret/files/fake/quic_initial_www_google_com.bin
" "
commit $cfgname commit $cfgname
EOF EOF
@@ -136,7 +376,7 @@ function set_cfg_nfqws_strat
function set_cfg_default_values function set_cfg_default_values
{ {
local opt_flags=${1:--} local opt_flags=${1:--}
local opt_strat=${2:-default} local opt_strat=${2:-v6_by_StressOzz}
local cfgname=${3:-$ZAPRET_CFG_NAME} local cfgname=${3:-$ZAPRET_CFG_NAME}
if ! echo "$opt_flags" | grep -q "(skip_base)"; then if ! echo "$opt_flags" | grep -q "(skip_base)"; then

Binary file not shown.

View File

@@ -7,17 +7,17 @@ START=21
SCRIPT_FILENAME=$1 SCRIPT_FILENAME=$1
. /opt/zapret2/comfunc.sh . /opt/zapret/comfunc.sh
if ! is_valid_config ; then if ! is_valid_config ; then
logger -p err -t ZAPRET2 "Wrong main config: $ZAPRET_CONFIG" logger -p err -t $ZAP_LOG_TAG "Wrong main config: $ZAPRET_CONFIG"
exit 91 exit 91
fi fi
. $ZAPRET_ORIG_INITD . $ZAPRET_ORIG_INITD
EXEDIR=/opt/zapret2 EXEDIR=/opt/$ZAPRET_CFG_NAME
ZAPRET_BASE=/opt/zapret2 ZAPRET_BASE=/opt/$ZAPRET_CFG_NAME
is_run_on_boot && IS_RUN_ON_BOOT=1 || IS_RUN_ON_BOOT=0 is_run_on_boot && IS_RUN_ON_BOOT=1 || IS_RUN_ON_BOOT=0
@@ -30,13 +30,13 @@ function enable
if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then
run_on_boot=$( get_run_on_boot_option ) run_on_boot=$( get_run_on_boot_option )
if [ $run_on_boot != 1 ]; then if [ $run_on_boot != 1 ]; then
logger -p notice -t ZAPRET2 "Attempt to enable service, but service blocked!" logger -p notice -t $ZAP_LOG_TAG "Attempt to enable service, but service blocked!"
return 61 return 61
fi fi
fi fi
fi fi
if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then
uci set $ZAPRET_CFG_NAME.config.run_on_boot=1 uci set $ZAPRET_CFG_SEC.run_on_boot=1
uci commit uci commit
fi fi
/bin/sh /etc/rc.common $ZAPRET_ORIG_INITD enable /bin/sh /etc/rc.common $ZAPRET_ORIG_INITD enable
@@ -49,7 +49,7 @@ function enabled
run_on_boot=$( get_run_on_boot_option ) run_on_boot=$( get_run_on_boot_option )
if [ $run_on_boot != 1 ]; then if [ $run_on_boot != 1 ]; then
if [ "$IS_RUN_ON_BOOT" = "1" ]; then if [ "$IS_RUN_ON_BOOT" = "1" ]; then
logger -p notice -t ZAPRET2 "Service is blocked!" logger -p notice -t $ZAP_LOG_TAG "Service is blocked!"
fi fi
return 61 return 61
fi fi
@@ -65,7 +65,7 @@ function boot
if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then if [ -n "$ZAPRET_CFG_SEC_NAME" ]; then
run_on_boot=$( get_run_on_boot_option ) run_on_boot=$( get_run_on_boot_option )
if [ $run_on_boot != 1 ]; then if [ $run_on_boot != 1 ]; then
logger -p notice -t ZAPRET2 "Attempt to run service on boot! Service is blocked!" logger -p notice -t $ZAP_LOG_TAG "Attempt to run service on boot! Service is blocked!"
return 61 return 61
fi fi
fi fi

View File

@@ -25,10 +25,10 @@ index 0af19c0..41c0967 100644
done done
} }
} }
diff --git a/init.d/openwrt/zapret b/init.d/openwrt/zapret2 diff --git a/init.d/openwrt/zapret b/init.d/openwrt/zapret
index 8d6d3a9..fcb1e91 100755 index 8d6d3a9..fcb1e91 100755
--- a/init.d/openwrt/zapret2 --- a/init.d/openwrt/zapret
+++ b/init.d/openwrt/zapret2 +++ b/init.d/openwrt/zapret
@@ -58,12 +58,29 @@ run_daemon() @@ -58,12 +58,29 @@ run_daemon()
# use $PIDDIR/$DAEMONBASE$1.pid as pidfile # use $PIDDIR/$DAEMONBASE$1.pid as pidfile
local DAEMONBASE="$(basename "$2")" local DAEMONBASE="$(basename "$2")"
@@ -51,15 +51,15 @@ index 8d6d3a9..fcb1e91 100755
procd_open_instance procd_open_instance
- procd_set_param command $2 $3 - procd_set_param command $2 $3
+ procd_set_param command $DAEMON_PATH $DAEMON_ARGS + procd_set_param command $DAEMON_PATH $DAEMON_ARGS
procd_set_param pidfile $PIDDIR/${DAEMONBASE}_$1.pid procd_set_param pidfile $PIDDIR/$DAEMONBASE$1.pid
procd_close_instance procd_close_instance
} }
+DAEMON_CFGNAME="main" +DAEMON_CFGNAME="main"
+ +
run_nfqws() run_tpws()
{ {
run_daemon $1 "$NFQWS2" "$NFQWS2_OPT_BASE $2" [ "$DISABLE_IPV4" = "1" ] && [ "$DISABLE_IPV6" = "1" ] && return 0
-- --
2.41.0.windows.3 2.41.0.windows.3

View File

@@ -1,7 +1,9 @@
#!/bin/sh #!/bin/sh
# Copyright (c) 2024 remittor # Copyright (c) 2024 remittor
. /opt/zapret2/comfunc.sh EXE_DIR=$(cd "$(dirname "$0")" 2>/dev/null || exit 1; pwd)
. $EXE_DIR/comfunc.sh
merge_cfg_with_def_values merge_cfg_with_def_values
@@ -12,5 +14,5 @@ CONFIGS_SYNC=0
if [ "$CONFIGS_SYNC" = "1" ]; then if [ "$CONFIGS_SYNC" = "1" ]; then
# renew main config # renew main config
/opt/zapret2/sync_config.sh $ZAPRET_BASE/sync_config.sh
fi fi

View File

@@ -1,9 +1,11 @@
#!/bin/sh #!/bin/sh
# Copyright (c) 2024 remittor # Copyright (c) 2024 remittor
. /opt/zapret2/comfunc.sh EXE_DIR=$(cd "$(dirname "$0")" 2>/dev/null || exit 1; pwd)
cfg_run_on_boot="$( uci -q get $ZAPRET_CFG_NAME.config.run_on_boot )" . $EXE_DIR/comfunc.sh
cfg_run_on_boot="$( uci -q get $ZAPRET_CFG_SEC.run_on_boot )"
opt_flags=${1:--} opt_flags=${1:--}
opt_strat=$2 opt_strat=$2
@@ -15,7 +17,7 @@ fi
create_default_cfg "$opt_flags" "$opt_strat" create_default_cfg "$opt_flags" "$opt_strat"
if [ "$cfg_run_on_boot" = "1" ]; then if [ "$cfg_run_on_boot" = "1" ]; then
uci set $ZAPRET_CFG_NAME.config.run_on_boot=1 uci set $ZAPRET_CFG_SEC.run_on_boot=1
uci commit uci commit
fi fi
@@ -29,5 +31,5 @@ fi
if [ "$ZAPRET_SYNC_CONFIG" = "1" ]; then if [ "$ZAPRET_SYNC_CONFIG" = "1" ]; then
# renew main config # renew main config
/opt/zapret2/sync_config.sh $ZAPRET_BASE/sync_config.sh
fi fi

View File

@@ -1,7 +1,9 @@
#!/bin/sh #!/bin/sh
# Copyright (c) 2024 remittor # Copyright (c) 2024 remittor
. /opt/zapret2/comfunc.sh EXE_DIR=$(cd "$(dirname "$0")" 2>/dev/null || exit 1; pwd)
. $EXE_DIR/comfunc.sh
function uncomment_param function uncomment_param
{ {
@@ -41,16 +43,22 @@ function sync_param
{ {
local param=$1 local param=$1
local vtype=$2 local vtype=$2
local value="$( uci -q get zapret2.config.$param )" local value="$( uci -q get $ZAPRET_CFG_SEC.$param )"
uncomment_param $param uncomment_param $param
append_param $param append_param $param
local TAB="$( echo -n -e '\t' )" local TAB="$( echo -n -e '\t' )"
if [ "$value" = "$TAB" ]; then if [ "$value" = "$TAB" ]; then
value="" value=""
fi fi
if [ "$param" = "NFQWS_PORTS_TCP_KEEPALIVE" -o "$param" = "NFQWS_PORTS_UDP_KEEPALIVE" ]; then
[ "$value" = "0" ] && value=""
fi
if [ "$param" = "NFQWS2_PORTS_TCP_KEEPALIVE" -o "$param" = "NFQWS2_PORTS_UDP_KEEPALIVE" ]; then if [ "$param" = "NFQWS2_PORTS_TCP_KEEPALIVE" -o "$param" = "NFQWS2_PORTS_UDP_KEEPALIVE" ]; then
[ "$value" = "0" ] && value="" [ "$value" = "0" ] && value=""
fi fi
if [ "$param" = "NFQWS_OPT" -a "$value" != "" ]; then
value=$( echo -n "$value" | sed '/^#/d' )
fi
if [ "$param" = "NFQWS2_OPT" -a "$value" != "" ]; then if [ "$param" = "NFQWS2_OPT" -a "$value" != "" ]; then
value=$( echo -n "$value" | sed '/^#/d' ) value=$( echo -n "$value" | sed '/^#/d' )
fi fi
@@ -90,21 +98,42 @@ sync_param DAEMON_LOG_FILE str
sync_param AUTOHOSTLIST_RETRANS_THRESHOLD sync_param AUTOHOSTLIST_RETRANS_THRESHOLD
sync_param AUTOHOSTLIST_FAIL_THRESHOLD sync_param AUTOHOSTLIST_FAIL_THRESHOLD
sync_param AUTOHOSTLIST_FAIL_TIME sync_param AUTOHOSTLIST_FAIL_TIME
if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
sync_param AUTOHOSTLIST_INCOMING_MAXSEQ
sync_param AUTOHOSTLIST_RETRANS_MAXSEQ
sync_param AUTOHOSTLIST_UDP_IN
sync_param AUTOHOSTLIST_UDP_OUT
fi
sync_param AUTOHOSTLIST_DEBUGLOG sync_param AUTOHOSTLIST_DEBUGLOG
sync_param NFQWS2_ENABLE
sync_param DESYNC_MARK sync_param DESYNC_MARK
sync_param DESYNC_MARK_POSTNAT sync_param DESYNC_MARK_POSTNAT
sync_param FILTER_MARK str sync_param FILTER_MARK str
sync_param NFQWS2_PORTS_TCP str
sync_param NFQWS2_PORTS_UDP str if [ $ZAPRET_CFG_NAME = "zapret" ]; then
sync_param NFQWS2_TCP_PKT_OUT str sync_param NFQWS_ENABLE
sync_param NFQWS2_TCP_PKT_IN str sync_param NFQWS_PORTS_TCP str
sync_param NFQWS2_UDP_PKT_OUT str sync_param NFQWS_PORTS_UDP str
sync_param NFQWS2_UDP_PKT_IN str sync_param NFQWS_TCP_PKT_OUT str
sync_param NFQWS2_PORTS_TCP_KEEPALIVE str sync_param NFQWS_TCP_PKT_IN str
sync_param NFQWS2_PORTS_UDP_KEEPALIVE str sync_param NFQWS_UDP_PKT_OUT str
sync_param NFQWS2_OPT str sync_param NFQWS_UDP_PKT_IN str
sync_param NFQWS_PORTS_TCP_KEEPALIVE str
sync_param NFQWS_PORTS_UDP_KEEPALIVE str
sync_param NFQWS_OPT str
fi
if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
sync_param NFQWS2_ENABLE
sync_param NFQWS2_PORTS_TCP str
sync_param NFQWS2_PORTS_UDP str
sync_param NFQWS2_TCP_PKT_OUT str
sync_param NFQWS2_TCP_PKT_IN str
sync_param NFQWS2_UDP_PKT_OUT str
sync_param NFQWS2_UDP_PKT_IN str
sync_param NFQWS2_PORTS_TCP_KEEPALIVE str
sync_param NFQWS2_PORTS_UDP_KEEPALIVE str
sync_param NFQWS2_OPT str
fi
ZAPRET_CONFIG="$ZAPRET_CONFIG__SAVED" ZAPRET_CONFIG="$ZAPRET_CONFIG__SAVED"

View File

@@ -1,17 +1,17 @@
#!/bin/sh #!/bin/sh
# Copyright (c) 2024 remittor # Copyright (c) 2024 remittor
. /opt/zapret2/comfunc.sh . /opt/zapret/comfunc.sh
# create empty txt files into ipset directory # create empty txt files into ipset directory
[ ! -f "/opt/zapret2/ipset/zapret-hosts-google.txt" ] && touch "/opt/zapret2/ipset/zapret-hosts-google.txt" [ ! -f "$ZAPRET_BASE/ipset/zapret-hosts-google.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-hosts-google.txt"
#[ ! -f "/opt/zapret2/ipset/zapret-hosts-auto.txt" ] && touch "/opt/zapret2/ipset/zapret-hosts-auto.txt" #[ ! -f "$ZAPRET_BASE/ipset/zapret-hosts-auto.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-hosts-auto.txt"
[ ! -f "/opt/zapret2/ipset/zapret-hosts-user.txt" ] && touch "/opt/zapret2/ipset/zapret-hosts-user.txt" [ ! -f "$ZAPRET_BASE/ipset/zapret-hosts-user.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-hosts-user.txt"
[ ! -f "/opt/zapret2/ipset/zapret-hosts-user-ipban.txt" ] && touch "/opt/zapret2/ipset/zapret-hosts-user-ipban.txt" [ ! -f "$ZAPRET_BASE/ipset/zapret-hosts-user-ipban.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-hosts-user-ipban.txt"
#[ ! -f "/opt/zapret2/ipset/zapret-ip.txt" ] && touch "/opt/zapret2/ipset/zapret-ip.txt" #[ ! -f "$ZAPRET_BASE/ipset/zapret-ip.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-ip.txt"
[ ! -f "/opt/zapret2/ipset/zapret-ip-user.txt" ] && touch "/opt/zapret2/ipset/zapret-ip-user.txt" [ ! -f "$ZAPRET_BASE/ipset/zapret-ip-user.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-ip-user.txt"
[ ! -f "/opt/zapret2/ipset/zapret-ip-user-exclude.txt" ] && touch "/opt/zapret2/ipset/zapret-ip-user-exclude.txt" [ ! -f "$ZAPRET_BASE/ipset/zapret-ip-user-exclude.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-ip-user-exclude.txt"
[ ! -f "/opt/zapret2/ipset/zapret-ip-user-ipban.txt" ] && touch "/opt/zapret2/ipset/zapret-ip-user-ipban.txt" [ ! -f "$ZAPRET_BASE/ipset/zapret-ip-user-ipban.txt" ] && touch "$ZAPRET_BASE/ipset/zapret-ip-user-ipban.txt"
# create or merge uci-config # create or merge uci-config
$ZAPRET_BASE/renew-cfg.sh $ZAPRET_BASE/renew-cfg.sh

View File

@@ -1,9 +1,7 @@
#!/bin/sh #!/bin/sh
# Copyright (c) 2025 remittor # Copyright (c) 2025 remittor
. /opt/zapret2/comfunc.sh EXE_DIR=$(cd "$(dirname "$0")" 2>/dev/null || exit 1; pwd)
. /usr/share/libubox/jshn.sh
. /etc/openwrt_release
opt_check= opt_check=
opt_prerelease= opt_prerelease=
@@ -14,14 +12,34 @@ opt_test=
while getopts "cu:pft:" opt; do while getopts "cu:pft:" opt; do
case $opt in case $opt in
c) opt_check=true;; c) opt_check=true;;
p) opt_prerelease=true;; p) opt_prerelease="true";;
u) opt_update="$OPTARG";; u) opt_update="$OPTARG";;
f) opt_forced=true;; f) opt_forced="true";;
t) opt_test="$OPTARG";; t) opt_test="$OPTARG";;
esac esac
done done
ZAP_PKG_DIR=/tmp/zapret2_pkg if [ "$EXE_DIR" = "/tmp" ]; then
ZAPRET_CFG_NAME="zapret"
if [ "$opt_update" = "1" ]; then
ZAPRET_CFG_NAME="zapret"
opt_update="@"
opt_forced="true"
fi
if [ "$opt_update" = "2" ]; then
ZAPRET_CFG_NAME="zapret2"
opt_update="@"
opt_forced="true"
fi
else
[ -f "$EXE_DIR/comfunc.sh" ] || { echo "ERROR: file $EXE_DIR/comfunc.sh not founded!"; exit 1; }
. $EXE_DIR/comfunc.sh
fi
. /usr/share/libubox/jshn.sh
. /etc/openwrt_release
ZAP_PKG_DIR=/tmp/$ZAPRET_CFG_NAME-pkg
if [ "$opt_test" != "" ]; then if [ "$opt_test" != "" ]; then
echo 1; sleep 2; echo 1; sleep 2;
@@ -33,9 +51,14 @@ if [ "$opt_test" != "" ]; then
return "$opt_test" return "$opt_test"
fi fi
ZAP_CPU_ARCH=$(get_cpu_arch) ZAP_CPU_ARCH="$DISTRIB_ARCH"
ZAP_REL_URL="https://raw.githubusercontent.com/remittor/zapret-openwrt/gh-pages/releases/releases_zap2_$ZAP_CPU_ARCH.json"
if [ $ZAPRET_CFG_NAME = "zapret" ]; then
ZAP_REL_URL="https://raw.githubusercontent.com/remittor/zapret-openwrt/gh-pages/releases/releases_zap1_$ZAP_CPU_ARCH.json"
fi
if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
ZAP_REL_URL="https://raw.githubusercontent.com/remittor/zapret-openwrt/gh-pages/releases/releases_zap2_$ZAP_CPU_ARCH.json"
fi
CURL_TIMEOUT=5 CURL_TIMEOUT=5
CURL_HEADER1="Accept: application/json" CURL_HEADER1="Accept: application/json"
CURL_HEADER2="Cache-Control: no-cache" CURL_HEADER2="Cache-Control: no-cache"
@@ -62,11 +85,73 @@ fi
# ------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------
function download_json function get_distrib_param
{ {
local url="$1" local parname=$1
curl -s -L --max-time $CURL_TIMEOUT -H "$CURL_HEADER1" -H "$CURL_HEADER2" "$url" 2>/dev/null local value="__unknown__"
return $? if [ -f /etc/openwrt_release ]; then
while IFS='=' read -r key val; do
val="${val#\'}"
val="${val%\'}"
val="${val#\"}"
val="${val%\"}"
if [ "$key" = "$parname" ]; then
value="$val"
break
fi
done < /etc/openwrt_release
fi
printf '%s' "$value"
}
function pkg_mgr_update
{
local forced=$1
if [ "$PKG_MGR" = "opkg" ]; then
PKG_TOTAL=$( opkg list | wc -l )
PKG_INSTALLED=$( opkg list-installed | wc -l )
if [ "$PKG_TOTAL" = "$PKG_INSTALLED" ]; then
echo ">>> OPKG update..."
opkg update
return $?
fi
else
PKG_AVAIL=$( apk list --available 2>/dev/null | wc -l )
if [ "$PKG_AVAIL" -lt 100 ]; then
echo ">>> APK update..."
apk update
return $?
fi
fi
return 0
}
function curl_install
{
if command -v curl >/dev/null 2>&1; then
return 0
fi
pkg_mgr_update || { echo "ERROR: cannot update packages list"; return 1; }
echo ">>> Package curl not found, installing..."
if [ "$PKG_MGR" = "opkg" ]; then
opkg install curl
else
apk add curl
fi
}
function unzip_install
{
if command -v unzip >/dev/null 2>&1; then
return 0
fi
pkg_mgr_update || { echo "ERROR: cannot update packages list"; return 1; }
echo ">>> Package unzip not found, installing..."
if [ "$PKG_MGR" = "opkg" ]; then
opkg install unzip
else
apk add unzip
fi
} }
function get_pkg_version function get_pkg_version
@@ -81,7 +166,7 @@ function get_pkg_version
fi fi
fi fi
if [ "$PKG_MGR" = apk ]; then if [ "$PKG_MGR" = apk ]; then
line=$( apk info -e "$pkg_name" 2>/dev/null || true ) line=$( apk info -s "$pkg_name" 2>/dev/null | head -n 1 | awk '{print $1}' || true )
if [ -n "$line" ]; then if [ -n "$line" ]; then
base=${line%-r[0-9]*} base=${line%-r[0-9]*}
ver=${base##*-} ver=${base##*-}
@@ -117,11 +202,16 @@ function normalize_version
;; ;;
esac esac
old_ifs="$IFS" ; IFS='.' ; set -- $base ; IFS="$old_ifs" old_ifs="$IFS" ; IFS='.' ; set -- $base ; IFS="$old_ifs"
rel=${rel:-1}
major=${1:-0} major=${1:-0}
minor=${2:-0} minor=${2:-0}
build=${3:-0} if [ $ZAPRET_CFG_NAME = "zapret" ]; then
rel=${rel:-1} echo "$major.$minor.$rel"
echo "$major.$minor.$build.$rel" fi
if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
build=${3:-0}
echo "$major.$minor.$build.$rel"
fi
} }
function pkg_version_cmp function pkg_version_cmp
@@ -139,14 +229,22 @@ function pkg_version_cmp
x2=$( echo "$ver2" | cut -d. -f2 ) x2=$( echo "$ver2" | cut -d. -f2 )
[ "$x1" -gt "$x2" ] && { echo -n "G"; return 0; } [ "$x1" -gt "$x2" ] && { echo -n "G"; return 0; }
[ "$x1" -lt "$x2" ] && { echo -n "L"; return 0; } [ "$x1" -lt "$x2" ] && { echo -n "L"; return 0; }
# build if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
x1=$( echo "$ver1" | cut -d. -f3 ) # build
x2=$( echo "$ver2" | cut -d. -f3 ) x1=$( echo "$ver1" | cut -d. -f3 )
[ "$x1" -gt "$x2" ] && { echo -n "G"; return 0; } x2=$( echo "$ver2" | cut -d. -f3 )
[ "$x1" -lt "$x2" ] && { echo -n "L"; return 0; } [ "$x1" -gt "$x2" ] && { echo -n "G"; return 0; }
[ "$x1" -lt "$x2" ] && { echo -n "L"; return 0; }
fi
# release # release
x1=$( echo "$ver1" | cut -d. -f4 ) if [ $ZAPRET_CFG_NAME = "zapret" ]; then
x2=$( echo "$ver2" | cut -d. -f4 ) x1=$( echo "$ver1" | cut -d. -f3 )
x2=$( echo "$ver2" | cut -d. -f3 )
fi
if [ $ZAPRET_CFG_NAME = "zapret2" ]; then
x1=$( echo "$ver1" | cut -d. -f4 )
x2=$( echo "$ver2" | cut -d. -f4 )
fi
[ "$x1" -gt "$x2" ] && { echo -n "G"; return 0; } [ "$x1" -gt "$x2" ] && { echo -n "G"; return 0; }
[ "$x1" -lt "$x2" ] && { echo -n "L"; return 0; } [ "$x1" -lt "$x2" ] && { echo -n "L"; return 0; }
echo -n "E" echo -n "E"
@@ -154,18 +252,28 @@ function pkg_version_cmp
function download_releases_info function download_releases_info
{ {
local txt txtlen txtlines generated_at local fname resp hdr txt txtlen txtlines generated_at
REL_JSON= REL_JSON=
echo "Download releases info..." echo "Download releases info..."
txt=$(download_json $ZAP_REL_URL) fname="${ZAP_REL_URL##*/}"
resp=$( curl -s -D - --max-time $CURL_TIMEOUT -H "$CURL_HEADER1" -H "$CURL_HEADER2" "$ZAP_REL_URL" 2>/dev/null )
hdr="${resp%%$'\r\n\r\n'*}"
status=$( printf '%s\n' "$hdr" | head -n 1 | awk '{print $2}' )
if [ "$status" != 200 ]; then
echo "ERROR: Cannot download file \"$ZAP_REL_URL\" (status = $status)"
return 103
fi
txtlen=$( printf '%s\n' "$hdr" | awk -F': ' 'BEGIN{IGNORECASE=1} $1=="Content-Length"{print $2}' | tr -d '\r' )
echo "Content-Length: $txtlen bytes"
txt="${resp#*$'\r\n\r\n'}"
txtlen=${#txt} txtlen=${#txt}
txtlines=$(printf '%s\n' "$txt" | wc -l) txtlines=$(printf '%s\n' "$txt" | wc -l)
if [[ $txtlen -lt 64 ]]; then if [[ $txtlen -lt 64 ]]; then
echo "ERROR: Cannot download releases info!" echo "ERROR: Cannot download releases info! (size = $txtlen)"
return 104 return 104
fi fi
echo "Releases info downloaded! Size = $txtlen, Lines = $txtlines" echo "Releases info downloaded! Size = $txtlen, Lines = $txtlines"
generated_at=$(printf '%s\n' "$txt" | grep -m1 -o '"generated_at"[[:space:]]*:[[:space:]]*".*"' | cut -d'"' -f4) generated_at=$( printf '%s\n' "$txt" | grep -m1 -o '"generated_at"[[:space:]]*:[[:space:]]*".*"' | cut -d'"' -f4 )
if [[ "$generated_at" = "" ]]; then if [[ "$generated_at" = "" ]]; then
echo "ERROR: Cannot download releases info! (incorrect generated_at)" echo "ERROR: Cannot download releases info! (incorrect generated_at)"
return 105 return 105
@@ -229,7 +337,7 @@ function get_actual_release
done done
json_cleanup json_cleanup
echo "ERROR: latest release for arch \"$ZAP_CPU_ARCH\" not founded!" echo "ERROR: latest release for arch \"$ZAP_CPU_ARCH\" not founded!"
return 1 # release not founded return 150 # release not founded
} }
# ------------------------------------------------------------------------------------------------------- # -------------------------------------------------------------------------------------------------------
@@ -245,11 +353,16 @@ fi
#echo "DISTRIB_ID: $DISTRIB_ID" #echo "DISTRIB_ID: $DISTRIB_ID"
echo "DISTRIB_RELEASE: $DISTRIB_RELEASE" echo "DISTRIB_RELEASE: $DISTRIB_RELEASE"
echo "DISTRIB_DESCRIPTION:" $(get_distrib_param DISTRIB_DESCRIPTION) echo "DISTRIB_DESCRIPTION:" $( get_distrib_param DISTRIB_DESCRIPTION )
echo "DISTRIB_ARCH:" $(get_distrib_param DISTRIB_ARCH) echo "DISTRIB_ARCH:" $( get_distrib_param DISTRIB_ARCH )
if ! command -v curl >/dev/null 2>&1; then if ! command -v curl >/dev/null 2>&1; then
echo "ERROR: package \"curl\" not installed!" if [ "$opt_forced" = true ]; then
curl_install
fi
fi
if ! command -v curl >/dev/null 2>&1; then
echo "ERROR: Required package \"curl\" not installed!"
return 10 return 10
fi fi
CURL_INFO=$( curl -V ) CURL_INFO=$( curl -V )
@@ -271,6 +384,11 @@ if [ "$opt_check" = "true" ]; then
fi fi
get_actual_release get_actual_release
ZAP_ERR=$? ZAP_ERR=$?
if [ $ZAP_ERR = 150 ] && [ "$opt_prerelease" != true ] && [ "$opt_forced" = true ]; then
opt_prerelease="true"
get_actual_release
ZAP_ERR=$?
fi
if [ $ZAP_ERR -ne 0 ]; then if [ $ZAP_ERR -ne 0 ]; then
echo "ERROR: Func get_actual_release return error code: $ZAP_ERR" echo "ERROR: Func get_actual_release return error code: $ZAP_ERR"
return $ZAP_ERR return $ZAP_ERR
@@ -286,7 +404,7 @@ ZAP_PKG_FN=
ZAP_PKG_BASE_FN= ZAP_PKG_BASE_FN=
ZAP_PKG_LUCI_FN= ZAP_PKG_LUCI_FN=
ZAP_CUR_PKG_VER=$( get_pkg_version zapret2 ) ZAP_CUR_PKG_VER=$( get_pkg_version $ZAPRET_CFG_NAME )
echo "Current installed version: $ZAP_CUR_PKG_VER" echo "Current installed version: $ZAP_CUR_PKG_VER"
if [ "$opt_update" = "" ]; then if [ "$opt_update" = "" ]; then
@@ -341,8 +459,8 @@ if [ "$opt_update" != "" ]; then
return 0 return 0
fi fi
fi fi
ZAP_PKG_DIR=/tmp/zapret2_pkg ZAP_PKG_DIR=/tmp/$ZAPRET_CFG_NAME-pkg
rm -rf $ZAP_PKG_DIR rm -rf $ZAP_PKG_DIR 2>/dev/null
ZAP_PKG_HDRS=$( curl -s -I -L --max-time $CURL_TIMEOUT -H "$CURL_HEADER2" "$ZAP_PKG_URL" ) ZAP_PKG_HDRS=$( curl -s -I -L --max-time $CURL_TIMEOUT -H "$CURL_HEADER2" "$ZAP_PKG_URL" )
ZAP_PKG_SIZE=$( echo "$ZAP_PKG_HDRS" | grep -i 'content-length: ' | tail -n1 | awk '{print $2}' | tr -d '\r' ) ZAP_PKG_SIZE=$( echo "$ZAP_PKG_HDRS" | grep -i 'content-length: ' | tail -n1 | awk '{print $2}' | tr -d '\r' )
echo "Downloded ZIP-file size = $ZAP_PKG_SIZE bytes" echo "Downloded ZIP-file size = $ZAP_PKG_SIZE bytes"
@@ -363,38 +481,50 @@ if [ "$opt_update" != "" ]; then
echo "ERROR: downloaded package is incorrect! (size = $ZAP_PKG_SZ)" echo "ERROR: downloaded package is incorrect! (size = $ZAP_PKG_SZ)"
return 216 return 216
fi fi
if ! command -v unzip >/dev/null 2>&1; then
if [ "$opt_forced" = true ]; then
unzip_install
fi
fi
if ! command -v unzip >/dev/null 2>&1; then if ! command -v unzip >/dev/null 2>&1; then
echo "ERROR: package \"upzip\" not installed!" echo "ERROR: package \"upzip\" not installed!"
return 218 return 218
fi fi
unzip -q "$ZAP_PKG_FN" -d $ZAP_PKG_DIR unzip -q "$ZAP_PKG_FN" -d $ZAP_PKG_DIR
rm -f "$ZAP_PKG_FN" rm -f "$ZAP_PKG_FN" 2>/dev/null
if [ "$PKG_MGR" = "apk" ]; then if [ "$PKG_MGR" = "apk" ]; then
if [ ! -d "$ZAP_PKG_DIR/apk" ]; then if [ ! -d "$ZAP_PKG_DIR/apk" ]; then
echo "ERROR: APK-files not founded" echo "ERROR: APK-files not founded"
return 221 return 221
fi fi
rm -f "$ZAP_PKG_DIR/*.ipk" rm -f $ZAP_PKG_DIR/*.ipk 2>/dev/null
mv "$ZAP_PKG_DIR/apk/*" "$ZAP_PKG_DIR/" mv $ZAP_PKG_DIR/apk/* $ZAP_PKG_DIR/
else else
rm -rf "$ZAP_PKG_DIR/apk" rm -rf $ZAP_PKG_DIR/apk 2>/dev/null
fi fi
ZAP_PKG_LIST=$( ls -1 "$ZAP_PKG_DIR" ) ZAP_PKG_LIST=$( ls -1 "$ZAP_PKG_DIR" )
echo "------ Downloaded packages:" echo "------ Downloaded packages:"
echo "$ZAP_PKG_LIST" echo "$ZAP_PKG_LIST"
echo "------" echo "------"
ZAP_PKG_BASE_FN=$( find "$ZAP_PKG_DIR" -maxdepth 1 -type f -name "zapret2_*.${ZAP_PKG_EXT}" | head -n 1 ) if [ "$PKG_MGR" != "apk" ]; then
ZAP_PKG_LUCI_FN=$( find "$ZAP_PKG_DIR" -maxdepth 1 -type f -name "luci-app-*.${ZAP_PKG_EXT}" | head -n 1 ) ZAP_PKG_BASE_FN=$( find "$ZAP_PKG_DIR" -maxdepth 1 -type f -name "${ZAPRET_CFG_NAME}_*.${ZAP_PKG_EXT}" | head -n 1 )
else
ZAP_PKG_BASE_FN=$( find "$ZAP_PKG_DIR" -maxdepth 1 -type f -name "${ZAPRET_CFG_NAME}-[0-9]*.?*.${ZAP_PKG_EXT}" | head -n 1 )
fi
ZAP_PKG_LUCI_FN=$( find "$ZAP_PKG_DIR" -maxdepth 1 -type f -name "luci-app-${ZAPRET_CFG_NAME}*.${ZAP_PKG_EXT}" | head -n 1 )
if [ ! -f "$ZAP_PKG_BASE_FN" ]; then if [ ! -f "$ZAP_PKG_BASE_FN" ]; then
echo "ERROR: File \"zapret2_*.${ZAP_PKG_EXT}\" not found!" echo "ERROR: File \"${ZAPRET_CFG_NAME}*.${ZAP_PKG_EXT}\" not found!"
return 231 return 231
fi fi
echo "ZAP_PKG_BASE_FN = $ZAP_PKG_BASE_FN" echo "ZAP_PKG_BASE_FN = $ZAP_PKG_BASE_FN"
if [ ! -f "$ZAP_PKG_LUCI_FN" ]; then if [ ! -f "$ZAP_PKG_LUCI_FN" ]; then
echo "ERROR: File \"luci-app-*.${ZAP_PKG_EXT}\" not found!" echo "ERROR: File \"luci-app-${ZAPRET_CFG_NAME}*.${ZAP_PKG_EXT}\" not found!"
return 232 return 232
fi fi
echo "ZAP_PKG_LUCI_FN = $ZAP_PKG_LUCI_FN" echo "ZAP_PKG_LUCI_FN = $ZAP_PKG_LUCI_FN"
if [ "$opt_forced" = true ]; then
pkg_mgr_update
fi
echo "Install downloaded packages..." echo "Install downloaded packages..."
if [ "$PKG_MGR" != "apk" ]; then if [ "$PKG_MGR" != "apk" ]; then
opkg install --force-reinstall "$ZAP_PKG_BASE_FN" opkg install --force-reinstall "$ZAP_PKG_BASE_FN"