# indeecfox/zapret4rocket architecture

> Architecture diagram of the GitHub repository indeecfox/zapret4rocket, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/indeecfox/zapret4rocket
- Repository: https://github.com/indeecfox/zapret4rocket

## Overview

##### Project type and purpose
- This is an open-source, cross-platform shell-script utility (“z4r”) whose goal is to install and configure the “zapret” blocking-circumvention service on Linux VPS and various router firmwares (OpenWRT, MerlinWRT, Keenetic/Entware).
- It bundles:
- A CLI-driven installer/updater (z4r) with interactive menu and strategy autobuyer
- A library of traffic-diversion strategies (extra_strats)
- Fake-packet binaries (fake/) to simulate TLS/QUIC/SYN handshakes
- Host-lists (lists/) of domains/IPs to route through zapret
- Entrypoint configuration (config.default, 3proxy.cfg)

##### File structure
- Top-level script: z4r (shell), merlin_wan_restart_zapret.sh, extra utility scripts (user_test2.sh, etc.)
- “Entware/” folder: platform-specific bootstrap scripts for routers running Entware
- “extra_strats/”: multiple directories (TCP, UDP) each containing per-strategy text files for RKN, YouTube, User-defined, etc.
- “fake/”: pre-built .bin files used by the installer to generate fake handshake traffic
- “lists/”: domain/IP lists used by zapret config (cloudflare, Telegram CIDRs, etc.)
- README.md: describes installation, update flow, supported platforms, dependencies

##### README for insights
- The installer uses curl (or wget) to pull the latest zapret release from GitHub, unpacks it in memory or /opt, and deploys its config and fakes.
- It detects OS (Ubuntu/Debian vs OpenWRT/Keenetic vs MerlinWRT), applies platform patches (iptables vs nftables, kernel modules), and offers an interactive menu for stopping/starting zapret, selecting strategies, editing config, and uninstalling.

##### Detail and clarity
- Grouping:
[z4r script]
├─ Core Logic (install, update, menu)
├─ Asset Store
└─ Platform Adapters

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User / SSH Operator"]:::user
    subgraph "CLI-Driven Installer"
        CLI_inst["z4r.sh"]:::installer
        CLI_test["z4r_test.sh"]:::installer
        Menu["Interactive Menu & Business Logic"]:::installer
        TestUtil["user_test2.sh"]:::installer
    end
    subgraph "Asset Store"
        ES["extra_strats/"]:::asset
        TCP["extra_strats/TCP/"]:::asset
        UDP["extra_strats/UDP/"]:::asset
        Fake["fake/"]:::asset
        Lists["lists/"]:::asset
        ConfigDef["config.default"]:::asset
        ProxyCfg["3proxy.cfg"]:::asset
    end
    subgraph "Platform Adapters"
        EntwareDir["Entware/"]:::adapter
        E000["000-zapret.sh"]:::adapter
        S00fix["S00fix"]:::adapter
        ZapretEnt["zapret"]:::adapter
        Merlin["merlin_wan_restart_zapret.sh"]:::adapter
    end
    Zapret["zapret Service<br/>(binary & generated conf)"]:::service
    OptionalProxy["3proxy Panel (Optional)"]:::optional
    ExternalGit["GitHub (zapret release)"]:::external
    Internet["Internet / Target Sites"]:::external
    Doc["README.md"]:::doc

    User -->|invoke| CLI_inst
    User -->|invoke| CLI_test
    User -->|invoke| TestUtil

    CLI_inst -->|runs functions| Menu
    Menu -->|download artifacts| ExternalGit
    CLI_inst -->|reads assets| ES
    CLI_inst -->|reads assets| TCP
    CLI_inst -->|reads assets| UDP
    CLI_inst -->|reads assets| Fake
    CLI_inst -->|reads assets| Lists
    CLI_inst -->|uses templates| ConfigDef
    CLI_inst -->|uses templates| ProxyCfg

    Menu -->|detect OS & patch| EntwareDir
    Menu -->|exec| E000
    Menu -->|exec| S00fix
    Menu -->|exec| ZapretEnt
    Menu -->|exec| Merlin

    Menu -->|generate config & control| Zapret
    Menu -->|optional configure| OptionalProxy

    Zapret -->|routes/block traffic| Internet

    CLI_inst -->|reference| Doc

    classDef user fill:#eef,stroke:#333,stroke-width:1px;
    classDef installer fill:#cfc,stroke:#393,stroke-width:1px;
    classDef asset fill:#ccf,stroke:#339,stroke-width:1px;
    classDef adapter fill:#fcf,stroke:#933,stroke-width:1px;
    classDef service fill:#ffc,stroke:#993,stroke-width:1px;
    classDef optional stroke-dasharray: 5 5,fill:#fad,stroke:#a53,stroke-width:1px;
    classDef external fill:#fca,stroke:#a33,stroke-width:1px;
    classDef doc fill:#eee,stroke:#666,stroke-width:1px;

    click CLI_inst "https://github.com/indeecfox/zapret4rocket/blob/master/z4r.sh"
    click CLI_test "https://github.com/indeecfox/zapret4rocket/blob/master/z4r_test.sh"
    click ES "https://github.com/indeecfox/zapret4rocket/tree/master/extra_strats/"
    click TCP "https://github.com/indeecfox/zapret4rocket/tree/master/extra_strats/TCP/"
    click UDP "https://github.com/indeecfox/zapret4rocket/tree/master/extra_strats/UDP/"
    click Fake "https://github.com/indeecfox/zapret4rocket/tree/master/fake/"
    click Lists "https://github.com/indeecfox/zapret4rocket/tree/master/lists/"
    click ConfigDef "https://github.com/indeecfox/zapret4rocket/blob/master/config.default"
    click ProxyCfg "https://github.com/indeecfox/zapret4rocket/blob/master/3proxy.cfg"
    click EntwareDir "https://github.com/indeecfox/zapret4rocket/tree/master/Entware/"
    click E000 "https://github.com/indeecfox/zapret4rocket/blob/master/Entware/000-zapret.sh"
    click S00fix "https://github.com/indeecfox/zapret4rocket/tree/master/Entware/S00fix"
    click ZapretEnt "https://github.com/indeecfox/zapret4rocket/tree/master/Entware/zapret"
    click Merlin "https://github.com/indeecfox/zapret4rocket/blob/master/merlin_wan_restart_zapret.sh"
    click TestUtil "https://github.com/indeecfox/zapret4rocket/blob/master/user_test2.sh"
    click Doc "https://github.com/indeecfox/zapret4rocket/blob/master/README.md"
```
