# cagritaskn/goodbyedpi-turkey architecture

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

- Interactive diagram: https://gitdiagram.com/cagritaskn/goodbyedpi-turkey
- Repository: https://github.com/cagritaskn/goodbyedpi-turkey

## Overview

##### Project type and purpose
- This is a native, user‐mode network tool written in C that bypasses Deep Packet Inspection (DPI) on Windows. It is not a full‐stack web app but a systems/driver‐based utility (“GoodbyeDPI Turkey version”) that hooks into Windows networking via the open‐source WinDivert library to modify, redirect, or inject packets at line speed without VPN overhead.

##### File structure
- Root
- README.md, REVERT.md, LICENSE – documentation and legal notices
- .github – CI/workflow and issue templates
- Makefile (in src/) – build orchestration
- src/
- goodbyedpi.c / goodbyedpi.h – main dispatcher
- dnsredir.c/h – DNS‐redirection module
- ttltrack.c/h – TTL‐tracking module
- fakepackets.c/h – fake‐packet injection module
- blackwhitelist.c/h – allow/block list module
- service.c/h – Windows service wrapper
- utils/ – shared helper functions (string, hash table, I/O)
- External artifacts (not in tree) – WinDivert.dll, WinDivert64.sys driver files, CMD scripts for installation.

##### README for insights
- Describes two launch modes:
- Windows Service – auto‐start at boot (via service_install_*.cmd)
- Batch Script – one‐off execution (turkey_dnsredir.cmd)
- Describes six alternative “modes” for different ISPs / DPI strategies.
- Relies on WinDivert to capture & inject network packets in user mode.

##### Main components & their interactions
a. Components
1. Windows Service Launcher (service.c)
2. User‐Mode Controller / CLI (batch scripts)
3. WinDivert Driver (WinDivert64.sys / WinDivert.dll)
4. Packet‐Processing Engine (goodbyedpi.c)
5. DPI‐Bypass Modules:
– DNS Redirection (dnsredir)
– TTL Tracking (ttltrack)
– Fake Packet Injection (fakepackets)
– Black/Whitelist Filtering (blackwhitelist)
6. Utilities (utils/*)
7. External DNS Servers (Yandex, Cloudflare)
b. Relationships & Data Flow
- Control Flow: User runs .cmd → installs or starts Windows Service → Service loads goodbyedpi.exe
- Packet Flow: All outbound/inbound packets first hit the WinDivert driver → passed to goodbyedpi engine → routed into one (or more) DPI‐bypass modules → modified or re‐injected via WinDivert → reaches normal network stack or application.
- Modules can cooperate: e.g., dnsredir patches DNS queries, ttltrack stamps TTL on SYN/ACK, fakepackets injects dummy traffic to confuse passive DPI.
c. Architectural Patterns & Principles
– Modular decomposition: each bypass technique isolated in its own C module with a clear interface
– Single entry‐point dispatcher (goodbyedpi) that loads/chooses modules based on command‐line flags
– Separation of concerns: service wrapper vs. core logic vs. utilities
– Use of third‐party kernel intercept driver (WinDivert) as abstraction layer
d. Key technologies
– C99 / Win32 API / Windows Service API
– WinDivert (packet capture & injection)
– Makefile for build
– Batch scripts (.cmd) for installation & configuration

##### Detail
- Module as its own sub‐component, don’t collapse everything into “packet modifier.”
- Which utility libraries (utils) feed into all modules.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Orchestration Layer
    subgraph "Orchestration" 
        direction TB
        BatchScripts["Batch Scripts / CLI"]:::orchestration
        Makefile["Build Orchestration (Makefile)"]:::orchestration
        DocsCI["Documentation & CI"]:::orchestration
    end

    %% User Mode Layer
    subgraph "User Mode"
        direction TB
        Service["Windows Service Launcher"]:::usermode
        Engine["GoodbyeDPI Engine"]:::usermode
        subgraph "DPI-Bypass Modules"
            direction TB
            DNS["DNS Redirection Module"]:::usermode
            TTL["TTL Tracking Module"]:::usermode
            Fake["Fake Packet Injection Module"]:::usermode
            BW["Black/Whitelist Filtering Module"]:::usermode
        end
        Utils["Utilities Library"]:::usermode
    end

    %% Kernel Mode Layer
    subgraph "Kernel Mode"
        direction TB
        WinDivert["WinDivert Driver"]:::kernel
        NIC["Network Stack & NIC"]:::kernel
    end

    %% External Systems Layer
    subgraph "External Systems"
        direction TB
        DNSExternal["External DNS Servers"]:::external
        Internet["Internet Servers"]:::external
    end

    %% Control Flow
    BatchScripts -->|installs/starts| Service
    BatchScripts -->|direct launch| Engine
    Service -->|launches| Engine

    %% Packet Flow
    NIC -->|outbound packets| WinDivert
    WinDivert -->|intercept| Engine
    Engine -->|routes to modules| DNS
    Engine -->|routes to modules| TTL
    Engine -->|routes to modules| Fake
    Engine -->|routes to modules| BW
    DNS -->|modify/re-inject| WinDivert
    TTL -->|modify/re-inject| WinDivert
    Fake -->|inject| WinDivert
    BW -->|filter| WinDivert
    WinDivert -->|inject| NIC

    %% Module Utilities
    Utils --> DNS
    Utils --> TTL
    Utils --> Fake
    Utils --> BW

    %% External Interactions
    DNS -->|queries| DNSExternal
    Engine -->|connects| Internet

    %% Click Events
    click Service "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/service.c"
    click Service "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/service.h"
    click Engine "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/goodbyedpi.c"
    click Engine "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/goodbyedpi.h"
    click DNS "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/dnsredir.c"
    click DNS "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/dnsredir.h"
    click TTL "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/ttltrack.c"
    click TTL "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/ttltrack.h"
    click Fake "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/fakepackets.c"
    click Fake "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/fakepackets.h"
    click BW "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/blackwhitelist.c"
    click BW "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/blackwhitelist.h"
    click Utils "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/utils/getline.c"
    click Utils "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/utils/getline.h"
    click Utils "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/utils/repl_str.c"
    click Utils "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/utils/repl_str.h"
    click Utils "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/src/utils/uthash.h"
    click Makefile "https://github.com/cagritaskn/goodbyedpi-turkey/tree/master/src/Makefile"
    click DocsCI "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/README.md"
    click DocsCI "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/REVERT.md"
    click DocsCI "https://github.com/cagritaskn/goodbyedpi-turkey/tree/master/LICENSE"
    click DocsCI "https://github.com/cagritaskn/goodbyedpi-turkey/blob/master/.github/workflows/build.yml"

    %% Styles
    classDef orchestration fill:#a8d5a2,stroke:#333,stroke-width:1px
    classDef usermode fill:#79b8ff,stroke:#333,stroke-width:1px
    classDef kernel fill:#fa8072,stroke:#333,stroke-width:1px
    classDef external fill:#d3d3d3,stroke:#333,stroke-width:1px
```
