#!/usr/bin/env bash # Every preset of Flowseal's release, with the arguments and lists the service builds, # checked by its own winws.exe (`--dry-run`) under Wine; then zapret2's command line, by # winws2.exe. # # nix develop --command nix shell nixpkgs#wineWow64Packages.stable -c tools/winws-dry-run.sh STAGE_DIR set -euo pipefail cd "$(dirname "$0")/.." STAGE=${1:?staged components directory} REL="$STAGE/zapret" WORK=$(mktemp -d) export WINEPREFIX=${WINEPREFIX:-$WORK/prefix} WINEDEBUG=-all trap 'wineserver -k 2>/dev/null || true; rm -rf "$WORK"' EXIT cargo build -q -p ps-core --example zapret_args --example zapret2_args win() { echo "Z:$(realpath "$1" | sed 's|/|\\|g')\\"; } # The lists as the service writes them: the release's, and the user's placeholders. mkdir -p "$WORK/lists" && cp "$REL"/lists/*.txt "$WORK/lists/" echo domain.example.abc > "$WORK/lists/list-general-user.txt" echo domain.example.abc > "$WORK/lists/list-exclude-user.txt" echo 203.0.113.113/32 > "$WORK/lists/ipset-exclude-user.txt" fail=0 n=0 while IFS= read -r preset; do for game in null all; do mapfile -t args < <(target/debug/examples/zapret_args "$REL" "$(win "$REL")" "$(win "$WORK/lists")" "$preset" "$game") n=$((n + 1)) if out=$(cd "$REL/bin" && wine ./winws.exe --dry-run "${args[@]}" 2>&1) && grep -q "parameters verified" <<<"$out"; then : else fail=$((fail + 1)); echo "FAIL: $preset ($game)"; grep -v Cygwin <<<"$out" | tail -4 fi done done < <(ls "$REL"/*.bat | xargs -n1 -d '\n' basename | grep -vi '^service' | sed 's/\.bat$//') echo "$((n - fail))/$n preset runs verified by winws.exe" # zapret2: nfqws2-keenetic's strategies as the service renders them, its lists in place. Z2="$STAGE/zapret2" mkdir -p "$WORK/z2/learned" && : > "$WORK/z2/zapret-hosts-user.txt" && : > "$WORK/z2/zapret-hosts-user-exclude.txt" && : > "$WORK/z2/learned/zapret-hosts-auto.txt" mapfile -t args < <(target/debug/examples/zapret2_args "$Z2" "$(win "$Z2")" "$(win "$WORK/z2")") if out=$(cd "$Z2" && wine ./winws2.exe --dry-run "${args[@]}" 2>&1) && grep -q "parameters verified" <<<"$out"; then echo "zapret2: verified by winws2.exe" else fail=$((fail + 1)); echo "FAIL: zapret2"; grep -v -i cygwin <<<"$out" | tail -4 fi [ "$fail" = 0 ]