- service.sh: split service_remove into internal (no prompts) and interactive versions to prevent 'eternal wait' when installing new strategy. Install now calls service_remove_internal > /dev/null instead of service_remove. Also filter strategy list to general*.sh only to avoid clutter. Systemd ExecStart now points to run_strategy.sh <name> consistently. - run_strategy.sh: add SIGTERM/SIGINT trap cleanup_strategy() that kills nfqws and cleans up firewall. Prevents stale nfqws/firewall rules after autotest kill. Also handles nfqws exit gracefully with final cleanup. - autotest.sh: rewritten to test strategies by config name (not wrapper filename). Stop now sends SIGTERM to wrapper (which triggers trap cleanup) instead of bare kill. Added extra sleep after stop to let trap fire. Auto-install ExecStart fixed to run_strategy.sh <strategy>. - setup.sh: added libmnl-dev and zlib1g-dev to Ubuntu/Debian dependency install to prevent build failures (missing libmnl/libmnl.h and zlib.h). - general*.sh: removed UTF-8 BOM (0xEF 0xBB 0xBF) that caused 'exec format error' when running scripts on Linux. All 19 wrappers cleaned. - ensure_wrappers.sh: always rewrite wrappers to ensure no stale BOM or paths. Fixes: eternal wait on menu option 1, nfqws build failure, stale processes after test.
109 lines
2.7 KiB
Bash
Executable File
109 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# utils/test_zapret.sh - Test utility for checking DPI bypass
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. && pwd)"
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
print_green() { echo -e "${GREEN}$1${NC}"; }
|
|
print_red() { echo -e "${RED}$1${NC}"; }
|
|
print_yellow(){ echo -e "${YELLOW}$1${NC}"; }
|
|
|
|
test_website() {
|
|
local url="$1"
|
|
local name="$2"
|
|
local timeout=10
|
|
local result
|
|
|
|
result=$(curl -o /dev/null -s -w "%{http_code}" --max-time "$timeout" -L "$url" 2>/dev/null)
|
|
|
|
if [[ "$result" == "200" ]] || [[ "$result" == "301" ]] || [[ "$result" == "302" ]]; then
|
|
print_green " [OK] $name ($url) - HTTP $result"
|
|
return 0
|
|
elif [[ -z "$result" ]]; then
|
|
print_red " [FAIL] $name ($url) - No response"
|
|
return 1
|
|
else
|
|
print_red " [FAIL] $name ($url) - HTTP $result"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
standard_tests() {
|
|
echo "[*] Standard tests - checking common sites..."
|
|
echo ""
|
|
|
|
local targets_file="$SCRIPT_DIR/utils/targets.txt"
|
|
if [[ ! -f "$targets_file" ]]; then
|
|
targets_file="/dev/stdin"
|
|
echo "ytimg.com"
|
|
echo "discord.com"
|
|
echo "discordapp.com"
|
|
echo "youtube.com"
|
|
echo "googlevideo.com"
|
|
fi
|
|
|
|
local total=0
|
|
local passed=0
|
|
|
|
while IFS= read -r line || [[ -n "$line" ]]; do
|
|
[[ -z "$line" ]] && continue
|
|
[[ "$line" =~ ^# ]] && continue
|
|
total=$((total + 1))
|
|
if test_website "https://$line" "$line"; then
|
|
passed=$((passed + 1))
|
|
fi
|
|
done < "$targets_file"
|
|
|
|
echo ""
|
|
echo "Results: $passed/$total passed"
|
|
if [[ "$passed" -eq "$total" ]]; then
|
|
print_green "All tests passed!"
|
|
else
|
|
print_yellow "Some tests failed. Try a different strategy."
|
|
fi
|
|
}
|
|
|
|
dpi_checkers() {
|
|
echo "[*] DPI checkers - checking various endpoints..."
|
|
echo ""
|
|
|
|
local endpoints=(
|
|
"https://1.1.1.1|Cloudflare"
|
|
"https://8.8.8.8|Google DNS"
|
|
"https://check-host.net|Check-Host"
|
|
)
|
|
|
|
for entry in "${endpoints[@]}"; do
|
|
IFS='|' read -r url name <<< "$entry"
|
|
test_website "$url" "$name"
|
|
done
|
|
|
|
echo ""
|
|
echo "[*] Checking if TCP timestamps are enabled..."
|
|
if [[ -r /proc/sys/net/ipv4/tcp_timestamps ]]; then
|
|
local val
|
|
val=$(cat /proc/sys/net/ipv4/tcp_timestamps)
|
|
if [[ "$val" == "1" ]]; then
|
|
print_green " [OK] tcp_timestamps = 1"
|
|
else
|
|
print_red " [WARN] tcp_timestamps = $val (should be 1)"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
case "${1:-standard}" in
|
|
standard)
|
|
standard_tests
|
|
;;
|
|
dpi)
|
|
dpi_checkers
|
|
;;
|
|
*)
|
|
echo "Usage: $0 [standard|dpi]"
|
|
exit 1
|
|
;;
|
|
esac
|