diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 2c19d66..1ab71c0 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -17,11 +17,6 @@ assignees: '' Укажите вашего провайдера и тип подключения (ppp/ethernet/...) **Выполните команды и приложите их вывод** -`/opt/etc/init.d/S51nfqws version` -``` -<ВСТАВИТЬ СЮДА> -``` - `/opt/etc/init.d/S51nfqws restart` ``` <ВСТАВИТЬ СЮДА> diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..209d405 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,84 @@ +name: Build and publish release + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Bump version + id: bump_version + uses: remorses/bump-version@v8 + with: + version_file: ./VERSION + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build packages + run: make all + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: true + prerelease: false + + - name: Upload Release mips + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./out/nfqws-keenetic_${{ steps.bump_version.outputs.version }}_mips-3.4.ipk + asset_name: nfqws-keenetic_${{ steps.bump_version.outputs.version }}_mips-3.4.ipk + asset_content_type: application/octet-stream + + - name: Upload Release mipsel + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./out/nfqws-keenetic_${{ steps.bump_version.outputs.version }}_mipsel-3.4.ipk + asset_name: nfqws-keenetic_${{ steps.bump_version.outputs.version }}_mipsel-3.4.ipk + asset_content_type: application/octet-stream + + - name: Upload Release aarch64 + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./out/nfqws-keenetic_${{ steps.bump_version.outputs.version }}_aarch64-3.10.ipk + asset_name: nfqws-keenetic_${{ steps.bump_version.outputs.version }}_aarch64-3.10.ipk + asset_content_type: application/octet-stream + + - name: Upload Release armv7 + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./out/nfqws-keenetic_${{ steps.bump_version.outputs.version }}_armv7-3.2.ipk + asset_name: nfqws-keenetic_${{ steps.bump_version.outputs.version }}_armv7-3.2.ipk + asset_content_type: application/octet-stream diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..78e6571 --- /dev/null +++ b/Makefile @@ -0,0 +1,82 @@ +VERSION := $(shell cat VERSION) + +.DEFAULT_GOAL := all + +_clean: + rm -rf out/$(ARCH) + mkdir -p out/$(ARCH)/control + mkdir -p out/$(ARCH)/data + +_conffiles: + echo "/opt/etc/nfqws/nfqws.conf" > out/$(ARCH)/control/conffiles + echo "/opt/etc/nfqws/user.list" >> out/$(ARCH)/control/conffiles + echo "/opt/etc/nfqws/auto.list" >> out/$(ARCH)/control/conffiles + echo "/opt/etc/nfqws/exclude.list" >> out/$(ARCH)/control/conffiles + +_control: + echo "Package: nfqws-keenetic" > out/$(ARCH)/control/control + echo "Version: $(VERSION)" >> out/$(ARCH)/control/control + echo "Depends: busybox, iptables" >> out/$(ARCH)/control/control + echo "License: MIT" >> out/$(ARCH)/control/control + echo "Section: net" >> out/$(ARCH)/control/control + echo "URL: https://github.com/Anonym-tsk/nfqws-keenetic" >> out/$(ARCH)/control/control + echo "Architecture: $(ARCH)-$(KERNEL)" >> out/$(ARCH)/control/control + echo "Description: NFQWS service" >> out/$(ARCH)/control/control + +_scripts: + cp common/ipk/preinst out/$(ARCH)/control/preinst + cp common/ipk/postinst out/$(ARCH)/control/postinst + cp common/ipk/prerm out/$(ARCH)/control/prerm + cp common/ipk/postrm out/$(ARCH)/control/postrm + +_debian-binary: + echo 2.0 > out/$(ARCH)/debian-binary + +_binary: + mkdir -p out/$(ARCH)/data/opt/usr/bin + curl -sSL $(URL) -o out/$(ARCH)/data/opt/usr/bin/nfqws + chmod +x out/$(ARCH)/data/opt/usr/bin/nfqws + +_version: + sed -i "s#VERSION=\"0.0.0\"#VERSION=\"$(VERSION)\"#" out/$(ARCH)/data/opt/etc/init.d/S51nfqws + +_ipk: + # cleanup + make _clean + + # control.tar.gz + make _conffiles + make _control + make _scripts + cd out/$(ARCH)/control; tar czvf ../control.tar.gz .; cd ../../.. + + # data.tar.gz + make _binary + cp -r etc out/$(ARCH)/data/opt/etc + make _version + cd out/$(ARCH)/data; tar czvf ../data.tar.gz .; cd ../../.. + + # ipk + make _debian-binary + #ar -r out/nfqws-keenetic_$(VERSION)_$(ARCH)-3.10.ipk out/$(ARCH)/control.tar.gz out/$(ARCH)/data.tar.gz out/$(ARCH)/debian-binary + cd out/$(ARCH); tar czvf ../nfqws-keenetic_$(VERSION)_$(ARCH)-$(KERNEL).ipk control.tar.gz data.tar.gz debian-binary; cd ../.. + +mipsel: + make ARCH=mipsel KERNEL=3.4 URL="https://raw.githubusercontent.com/bol-van/zapret/master/binaries/mips32r1-lsb/nfqws" _ipk + +mips: + make ARCH=mips KERNEL=3.4 URL="https://raw.githubusercontent.com/bol-van/zapret/master/binaries/mips32r1-msb/nfqws" _ipk + +aarch64: + make ARCH=aarch64 KERNEL=3.10 URL="https://raw.githubusercontent.com/bol-van/zapret/master/binaries/aarch64/nfqws" _ipk + +armv7: + make ARCH=armv7 KERNEL=3.2 URL="https://raw.githubusercontent.com/bol-van/zapret/master/binaries/arm/nfqws" _ipk + +all: mipsel mips aarch64 armv7 + +clean: + rm -rf out/mipsel + rm -rf out/mips + rm -rf out/aarch64 + rm -rf out/armv7 diff --git a/README.md b/README.md index 426b1f4..12ebd95 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ git pull --depth=1 ### Полезное 1. Конфиг-файл `/opt/etc/nfqws/nfqws.conf` -2. Скрипт запуска/остановки `/opt/etc/init.d/S51nfqws {start|stop|restart|reload|status|version}` +2. Скрипт запуска/остановки `/opt/etc/init.d/S51nfqws {start|stop|restart|reload|status}` 3. Вручную добавить домены в список можно в файле `/opt/etc/nfqws/user.list` (один домен на строке, поддомены учитываются автоматически) 4. Автоматически добавленные домены `/opt/etc/nfqws/auto.list` 5. Лог автоматически добавленных доменов `/opt/var/log/nfqws.log` diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..227cea2 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2.0.0 diff --git a/common/install_func.sh b/common/install_func.sh index ec04fdc..113d1f4 100755 --- a/common/install_func.sh +++ b/common/install_func.sh @@ -65,6 +65,7 @@ remove_list_func() { rm -f $LISTFILE rm -f $LISTAUTOFILE rm -f $LISTEXCLUDEFILE + rm -rf $CONFDIR ;; esac } diff --git a/common/ipk/postinst b/common/ipk/postinst new file mode 100755 index 0000000..01ec964 --- /dev/null +++ b/common/ipk/postinst @@ -0,0 +1,106 @@ +#!/bin/sh + +CONFDIR=/opt/etc/nfqws +CONFFILE=$CONFDIR/nfqws.conf +LISTFILE=$CONFDIR/user.list +LISTAUTOFILE=$CONFDIR/auto.list +LISTEXCLUDEFILE=$CONFDIR/exclude.list +LISTLOG=/opt/var/log/nfqws.log +INIT_SCRIPT=/opt/etc/init.d/S51nfqws + +stop_func() { + if [ -f "$INIT_SCRIPT" ]; then + $INIT_SCRIPT stop + fi +} + +start_func() { + if [ -f "$INIT_SCRIPT" ]; then + $INIT_SCRIPT start + fi +} + +show_interfaces_func() { + echo -e "\n----------------------" + ip addr show | awk -F" |/" '{gsub(/^ +/,"")}/inet /{print $(NF), $2}' +} + +config_interface_func() { + if [ -z "$BIND_IFACE" ]; then + echo -e "\nEnter the provider interface name from the list above, e.g. eth3 (default) or nwg1" + echo "You can specify multiple interfaces separated by space, e.g. eth3 nwg1" + read BIND_IFACE + fi + if [ -z "$BIND_IFACE" ]; then + BIND_IFACE="eth3" + fi + echo "Selected interface: $BIND_IFACE" + + sed -i "s#INPUT_ISP_INTERFACE#$BIND_IFACE#" $CONFFILE +} + +config_select_mode_func() { + if [ -z "$MODE" ]; then + echo -e "\nSelect working mode: auto (default), list, all" + echo " auto - automatically detects blocked resources and adds them to the list" + echo " list - applies rules only to domains in the list $LISTFILE" + echo " all - applies rules to all traffic except domains from list $LISTEXCLUDEFILE" + read MODE + fi + + if [ "$MODE" == "list" ]; then + EXTRA_ARGS="--hostlist=$LISTFILE" + elif [ "$MODE" == "all" ]; then + EXTRA_ARGS="--hostlist-exclude=$LISTEXCLUDEFILE" + else + MODE="auto" + EXTRA_ARGS="--hostlist=$LISTFILE --hostlist-auto=$LISTAUTOFILE --hostlist-auto-debug=$LISTLOG --hostlist-exclude=$LISTEXCLUDEFILE" + fi + echo "Selected mode: $MODE" + + sed -i "s#INPUT_EXTRA_ARGS#$EXTRA_ARGS#" $CONFFILE +} + +config_ipv6_func() { + echo -e "\nDisable IPv6 support (enabled by default)? y/N" + read yn + case $yn in + [Yy]* ) + sed -i "s#IPV6_ENABLED=1#IPV6_ENABLED=0#" $CONFFILE + ;; + esac +} + +# Stop service if exist +stop_func + +NFQWS_INSTALL_TYPE="install" +if [ -f "/tmp/nfqws_install_type" ]; then + # Set in preinst script + NFQWS_INSTALL_TYPE=$(cat "/tmp/nfqws_install_type") + rm -f /tmp/nfqws_install_type +fi + +case "$NFQWS_INSTALL_TYPE" in + install) + # Setup ISP interface + show_interfaces_func + config_interface_func + + # Setup working mode + config_select_mode_func + + # Setup IPv6 support + config_ipv6_func + + echo "Installation successful" + ;; + *) + # Do nothing + ;; +esac + +# Starting Services +start_func + +exit 0 diff --git a/common/ipk/postrm b/common/ipk/postrm new file mode 100755 index 0000000..817dfa1 --- /dev/null +++ b/common/ipk/postrm @@ -0,0 +1,29 @@ +#!/bin/sh + +CONFDIR=/opt/etc/nfqws +LISTLOG=/opt/var/log/nfqws.log + +remove_all_files_func() { + rm -f $LISTLOG + echo -e "\nRemove lists and config? y/N" + read yn + case $yn in + [Yy]* ) + rm -rf $CONFDIR + ;; + esac +} + +case "$1" in + upgrade) + # Do nothing + ;; + *) + # Remove all data + remove_all_files_func + + echo "Unnstallation successful" + ;; +esac + +exit 0 diff --git a/common/ipk/preinst b/common/ipk/preinst new file mode 100755 index 0000000..19ea698 --- /dev/null +++ b/common/ipk/preinst @@ -0,0 +1,6 @@ +#!/bin/sh + +# Set `install` or `upgrade` for postinst script +echo "$1" > /tmp/nfqws_install_type + +exit 0 diff --git a/common/ipk/prerm b/common/ipk/prerm new file mode 100755 index 0000000..5acebf2 --- /dev/null +++ b/common/ipk/prerm @@ -0,0 +1,14 @@ +#!/bin/sh + +INIT_SCRIPT=/opt/etc/init.d/S51nfqws + +stop_func() { + if [ -f "$INIT_SCRIPT" ]; then + $INIT_SCRIPT stop + fi +} + +# Stop service if exist +stop_func + +exit 0 diff --git a/etc/init.d/S51nfqws b/etc/init.d/S51nfqws index ced3cde..3a56b19 100755 --- a/etc/init.d/S51nfqws +++ b/etc/init.d/S51nfqws @@ -1,7 +1,5 @@ #!/bin/sh -VERSION="1.2.1" - . /opt/etc/nfqws/nfqws.conf NFQWS_BIN=/opt/usr/bin/nfqws @@ -205,9 +203,6 @@ case "$1" in kernel-modules) kernel_modules_load ;; - version|-v|--version) - echo "nfqws-keenetic version: $VERSION" - ;; *) - echo "Usage: $0 {start|stop|restart|reload|status|version}" + echo "Usage: $0 {start|stop|restart|reload|status}" esac