From b75d75931d2a6872eebb535cf501b8fa0cf8950f Mon Sep 17 00:00:00 2001 From: Stitch505 <–Gleb@stitch505.su> Date: Sun, 10 May 2026 19:20:21 +0400 Subject: [PATCH] feat: add GitHub, Telegram, Steam to lists + .service/hosts + PROJECT.md docs: rewrite README.md with 8 distro install guides fix: hosts_update now reads local .service/hosts and appends to /etc/hosts --- .service/hosts | 61 +++++++++++++++ PROJECT.md | 171 +++++++++++++++++++++++++++++++++++++++++ lists/list-general.txt | 23 ++++++ service.sh | 48 ++++++++---- 4 files changed, 289 insertions(+), 14 deletions(-) create mode 100644 .service/hosts create mode 100644 PROJECT.md diff --git a/.service/hosts b/.service/hosts new file mode 100644 index 0000000..7ac59fc --- /dev/null +++ b/.service/hosts @@ -0,0 +1,61 @@ +# Статичные IP для hosts-файла (аналог .service/hosts из Windows-версии zapret-discord-youtube) +# Добавьте эти строки в /etc/hosts если нужен фикс для Telegram, GitHub, Discord +# Linux: sudo nano /etc/hosts +# +# GitHub (резервные IP из CDN, помогают при DNS-спуфинге) +185.199.109.133 raw.githubusercontent.com +185.199.109.133 release-assets.githubusercontent.com +185.199.108.133 private-user-images.githubusercontent.com +185.199.108.133 gist.githubusercontent.com +185.199.108.133 avatars.githubusercontent.com +140.82.121.3 github.com +140.82.121.4 github.com +140.82.113.3 gist.github.com +# Note: GitHub IPs меняются. Для надёжности — используйте DoH/DoT. +# +# Telegram +149.154.167.220 my.telegram.org +149.154.167.220 oauth.telegram.org +149.154.167.220 cdn.telesco.pe +149.154.167.220 cdn1.telesco.pe +149.154.167.220 cdn2.telesco.pe +149.154.167.220 cdn3.telesco.pe +149.154.167.220 cdn4.telesco.pe +149.154.167.220 cdn5.telesco.pe +149.154.167.220 core.telegram.org +149.154.167.220 zws4.web.telegram.org +149.154.167.220 vesta.web.telegram.org +149.154.167.220 vesta-1.web.telegram.org +149.154.167.220 venus-1.web.telegram.org +149.154.167.220 telegram.me +149.154.167.220 telegram.dog +149.154.167.220 telegram.space +149.154.167.220 telesco.pe +149.154.167.220 tg.dev +149.154.167.220 telegram.org +149.154.167.220 t.me +149.154.167.220 api.telegram.org +149.154.167.220 td.telegram.org +149.154.167.220 venus.web.telegram.org +149.154.167.220 web.telegram.org +149.154.167.220 kws2-1.web.telegram.org +149.154.167.220 kws2.web.telegram.org +149.154.167.220 kws4-1.web.telegram.org +149.154.167.220 kws4.web.telegram.org +149.154.167.220 zws2-1.web.telegram.org +149.154.167.220 zws2.web.telegram.org +149.154.167.220 zws4-1.web.telegram.org +# +# Discord media (резервные для голосовых каналов) +104.25.158.178 finland10000.discord.media +104.25.158.178 finland10001.discord.media +104.25.158.178 finland10002.discord.media +104.25.158.178 finland10003.discord.media +104.25.158.178 finland10004.discord.media +104.25.158.178 finland10005.discord.media +104.25.158.178 finland10006.discord.media +104.25.158.178 finland10007.discord.media +104.25.158.178 finland10008.discord.media +104.25.158.178 finland10009.discord.media +104.25.158.178 finland10010.discord.media +104.25.158.178 finland10011.discord.media diff --git a/PROJECT.md b/PROJECT.md new file mode 100644 index 0000000..38dd397 --- /dev/null +++ b/PROJECT.md @@ -0,0 +1,171 @@ +# Zapret Discord + YouTube for Linux — Project Documentation + +## Overview + +Linux-перенос проекта [Flowseal/zapret-discord-youtube](https://github.com/Flowseal/zapret-discord-youtube) (v1.9.8c) с полной автоматизацией установки, тестирования и обновления. + +**Архитектура:** +- `nfqws` (bol-van/zapret) — ядерный обработчик пакетов +- iptables/nftables + NFQUEUE — перехват трафика +- 20 стратегий обхода DPI (fake, multisplit, fakedsplit, hostfakesplit, syndata и др.) +- systemd — сервисы и таймеры + +--- + +## Directory Map + +``` +zapret/ +├── bin/ # nfqws + fake .bin пакеты (собираются при install) +├── lib/functions.sh # Общие: firewall setup/cleanup, colors, distro detect +├── lists/ # Домены и IP для обхода +│ ├── list-general.txt # Discord, YouTube, Google, GitHub, Telegram, Steam +│ ├── list-google.txt # Google-специфичные домены +│ ├── list-exclude.txt # Что НЕ трогать (банки, госуслуги) +│ ├── ipset-all.txt # IP-диапазоны (placeholder → обновляется) +│ └── ipset-exclude.txt # локальные диапазоны +├── .service/ # Runtime-конфигурация + hosts +│ ├── version.txt # Текущая версия +│ ├── installed_strategy # Какая стратегия в systemd +│ ├── hosts # Статичные IP для hosts (GitHub, Telegram, Discord) +│ ├── game_filter_enabled # Флаг +│ └── check_updates_enabled +├── systemd/ +│ ├── zapret.service +│ ├── zapret-update.service +│ └── zapret-update.timer +├── utils/ +│ ├── test_zapret.sh # curl-проверка доступности +│ └── targets.txt # Цели теста +├── general*.sh # 20 обёрток → run_strategy.sh +├── run_strategy.sh # Единый движок: собирает аргументы nfqws +├── autotest.sh # Автоподбор: запускает каждую, тестит curl, ставит systemd +├── install.sh # Входная точка: setup + build + autotest + systemd +├── service.sh # Меню управления (аналог service.bat) +├── setup.sh # Зависимости по дистру, модуль ядра, user lists +├── install_nfqws.sh # git clone bol-van/zapret → make nfqws → fake .bin +└── update.sh # Pipeline: check version → update files → rebuild → autotest +``` + +--- + +## Core Scripts Deep Dive + +### `run_strategy.sh ` +- Принимает имя стратегии (`general`, `ALT`, `ALT2`, ...) +- Определяет `RULE1` (UDP 443 general), `RULE2` (Discord/stun), `RULE3-9` (стратегия-специфичные) +- Собирает финальный массив аргументов для `nfqws` +- Вызывает `run_nfqws()` из `lib/functions.sh` + +### `lib/functions.sh` +- `setup_firewall()` — nftables или iptables правила для портов 80,443,2053,2083,2087,2096,8443, UDP 443, 19294-19344, 50000-50100 +- `cleanup_firewall()` — удаляет правила, убивает nfqws +- `run_nfqws()` — проверяет бинарник, очищает старые правила, поднимает новые, запускает nfqws +- `get_game_filter()` — читает `.service/game_filter_enabled`, меняет порты на 1024:65535 +- `describe_strategy()` — человекочитаемые описания + +### `autotest.sh [--auto]` +- Перебирает STRATEGIES[] по порядку +- Каждую запускает (`sudo ./general*.sh &`) +- Ждёт 3 сек +- Тестит `youtube.com` и `discord.com` через curl (timeout 8s) +- При успехе: + - `--auto` → сразу создаёт systemd unit, enable, start + - интерактив → ждёт подтверждения + +### `update.sh [--auto|--full-auto]` +``` +Step 1: curl GitHub API → проверка версии +Step 2: update_files() → lists + lib + utils (atomic: .tmp + mv) +Step 3: rebuild_nfqws() → install_nfqws.sh + verify --help +Step 4: run_autotest_pipeline() → cleanup → autotest.sh --auto → systemd install +``` + +--- + +## Strategy Parameters (nfqws) + +Каждая стратегия — это комбинация фильтров `--filter-tcp`, `--filter-udp`, `--filter-l7` с DPI обходом: + +| Параметр | Описание | +|----------|----------| +| `--dpi-desync=fake` | Отправка фейкового пакета | +| `--dpi-desync=multisplit` | Разделение пакета | +| `--dpi-desync=fakedsplit` | Фейк + разделение | +| `--dpi-desync=hostfakesplit` | Фейк по хосту | +| `--dpi-desync=syndata` | SYN data | +| `--dpi-desync=multidisorder` | Множественное нарушение порядка | +| `--dpi-desync-repeats=N` | Повторить N раз | +| `--dpi-desync-fooling=ts` | TCP timestamp fooling | +| `--dpi-desync-fooling=badseq` | Bad sequence number | +| `--dpi-desync-fake-tls="file.bin"` | Фейковый TLS ClientHello | +| `--dpi-desync-fake-quic="file.bin"` | Фейковый QUIC initial | +| `--ip-id=zero` | Обнулить IP ID field | +| `--dpi-desync-any-protocol=1` | Применять к любому протоколу UDP | + +--- + +## Firewall Backend + +**Priority:** nftables → iptables fallback + +```bash +# nftables (if nft available) +nft add table ip zapret +nft add chain ip zapret postrouting { type filter hook postrouting priority mangle; } +nft add rule ip zapret postrouting tcp dport 443 counter queue num 200 + +# iptables fallback +iptables -t mangle -I POSTROUTING -p tcp --dport 443 -j NFQUEUE --queue-num 200 +``` + +Queue num: 200. nfqws: `--qnum=200`. + +--- + +## Supported Distros + +- Ubuntu / Debian / Linux Mint / Pop!_OS / Zorin / Kali +- Arch / Manjaro / EndeavourOS / Garuda / Artix / Arco +- Fedora / RHEL / CentOS / AlmaLinux / Rocky +- Alpine Linux +- Gentoo / Funtoo +- openSUSE / SUSE +- Void Linux +- NixOS + +Package managers: `apt`, `pacman/yay/paru`, `dnf`, `apk`, `emerge`, `zypper`, `xbps`, `nix`. + +--- + +## Known Resources Included (v1.9.8c) + +**Discord:** все discord.* домены, .gg, .media, .app, .net, .com, статичные IP для Discord media + +**YouTube:** googlevideo.com, youtube.com, ytimg.com, jnn-pa.googleapis.com, play.google.com + +**GitHub** (добавлено в 1.9.8c): github.com, raw.githubusercontent.com, avatars.githubusercontent.com, gist.github.com и др. + +**Telegram** (добавлено в 1.9.8c): t.me, telegram.org, telegram.me, web.telegram.org, api.telegram.org, my.telegram.org + +**Steam:** steampowered.com, steamcommunity.com, steamcontent.com, steamstatic.com + +**Исключения (не трогаем):** Яндекс, ВК, Твич, Сбер, Тинькофф, Госуслуги, банки (полный список в `lists/list-exclude.txt`) + +--- + +## Git / Gitea + +- Repo: `https://giteas.stitch505.su/Stitch505/zapret-discord-youtube-linux` +- Branch: `main` (единственная) +- Version: `1.9.8c-linux` + +--- + +## Contributing / Debug + +Если нужно добавить стратегию: +1. Создать `general_NEW.sh` → вызов `run_strategy.sh NEW` +2. В `run_strategy.sh` добавить `case NEW:` с `RULE3-9` +3. В `lib/functions.sh` добавить `describe_strategy` +4. В `autotest.sh` добавить в массив `STRATEGIES[]` diff --git a/lists/list-general.txt b/lists/list-general.txt index 8c4f5f2..b65a65d 100644 --- a/lists/list-general.txt +++ b/lists/list-general.txt @@ -47,3 +47,26 @@ betterttv.net 7tv.io localizeapi.com klipy.com +github.com +github.io +raw.githubusercontent.com +release-assets.githubusercontent.com +private-user-images.githubusercontent.com +avatars.githubusercontent.com +gist.github.com +steampowered.com +steamcommunity.com +steamcontent.com +steamstatic.com +t.me +telegram.org +telegram.me +telegram.dog +telegram.space +telesco.pe +tg.dev +api.telegram.org +td.telegram.org +web.telegram.org +my.telegram.org +oauth.telegram.org diff --git a/service.sh b/service.sh index 644fcc5..f6c9be3 100644 --- a/service.sh +++ b/service.sh @@ -354,22 +354,42 @@ ipset_update() { # ============================================ hosts_update() { echo "" - echo "[*] Updating hosts file..." - local hosts_url="https://raw.githubusercontent.com/Flowseal/zapret-discord-youtube/main/.service/hosts.txt" - local temp_hosts="/tmp/zapret_hosts_$$.txt" + echo "[*] Hosts File Manager" + echo "" - if curl -sfL "$hosts_url" -o "$temp_hosts" 2>/dev/null; then - echo "" - echo "[*] New hosts entries:" - cat "$temp_hosts" - echo "" - echo "[*] To apply, add these lines to your /etc/hosts manually:" - echo " sudo nano /etc/hosts" - echo "" - rm -f "$temp_hosts" - else - print_red "[!] Failed to fetch hosts file" + local hosts_file="$SCRIPT_DIR/.service/hosts" + + if [[ ! -f "$hosts_file" ]]; then + print_red "[!] Local hosts file not found: $hosts_file" + read -rp "Press Enter to continue..." + return fi + + echo "[*] Local hosts entries (for GitHub, Telegram, Discord):" + echo "" + grep -v '^#' "$hosts_file" | grep -v '^$' | head -n 20 + local total + total=$(grep -v '^#' "$hosts_file" | grep -v '^$' | wc -l) + echo "" + echo "Total entries: $total" + echo "" + + read -rp "Append these entries to /etc/hosts? [y/N]: " ans + if [[ "$ans" == [yY]* ]]; then + # Backup /etc/hosts + sudo cp /etc/hosts "/etc/hosts.backup.$(date +%s)" + echo "" | sudo tee -a /etc/hosts > /dev/null + echo "# --- zapret-discord-youtube-linux hosts ---" | sudo tee -a /etc/hosts > /dev/null + grep -v '^#' "$hosts_file" | grep -v '^$' | sudo tee -a /etc/hosts > /dev/null + echo "# --- end zapret hosts ---" | sudo tee -a /etc/hosts > /dev/null + print_green "[OK] Entries added to /etc/hosts" + echo " Backup saved as /etc/hosts.backup.*" + else + echo "[*] Skipped. To add manually:" + echo " sudo nano /etc/hosts" + echo " Then copy from: $hosts_file" + fi + read -rp "Press Enter to continue..." }