MasterDnsVPN

masterking32MIT活跃维护

基于 DNS 隧道的 VPN,用来绕过网络审查,靠低开销 ARQ、解析器负载均衡和高丢包稳定性,速度和抗丢包比 DNSTT、SlipStream 更强。

Advanced DNS tunneling VPN for censorship bypass, optimized beyond DNSTT and SlipStream with low-overhead ARQ, resolver load balancing, high packet-loss stability and speed.

v2026.10.26.100415-5f83ee9发布于 2026-10-26 10:06 UTC7,322star +5 / 7 天755fork同步于 2026-11-10 11:33 UTC

怎么上手

由 README 提炼,执行前请确认
bash <(curl -Ls https://raw.githubusercontent.com/masterking32/MasterDnsVPN/main/server_linux_install.sh)
sudo ufw allow 53/udp
硬件要求按 README 说明

README 未说明具体硬件或显存要求;服务端需能接收 UDP 53 端口流量,客户端提供 Windows、macOS、Linux 预编译包,主版本用 Go 实现。

支持 Apple Silicon有 Docker 镜像
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 DNS 查询封装 TCP 流量的抗审查隧道,在丢包和强干扰网络下追求稳定与速度

基于 DNS 隧道的 VPN,用来绕过网络审查,靠低开销 ARQ、解析器负载均衡和高丢包稳定性,速度和抗丢包比 DNSTT、SlipStream 更强。

核心能力

  • 自定义协议加 ARQ,传输头开销仅约 5–7 字节
  • 内置 8 种解析器负载均衡模式并支持多解析器路由
  • 解析器健康检查、自动禁用与后台恢复机制
  • 支持数据包复制与故障转移以提升弱网可靠性
  • 客户端内置本地 DNS 服务与 DNS 缓存,降低 DNS 劫持影响

容易踩的坑

需先在域名商处配置 A 记录和 NS 记录委派子域,并等待 DNS 生效(可能数分钟到 48 小时)。服务端需放行 UDP 53,若被 systemd-resolved 占用需先处理端口冲突。安装后生成的 encrypt_key.txt 加密密钥必须保存,客户端连接时要用。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v2026.10.26.100415-5f83ee9
  1. v2026.10.26.100415-5f83ee9Release v2026.10.26.100415-5f83ee9最新正式版2026-10-26 · 2026-10-26 10:06 UTC

    Changes since v2026.06.13.234407-7de2476:

    Automated release created by workflow run 40304480846 for commit 5f83ee9a1690a968f9edf495d3a7e00a2043b0bd

    Commits

    • Update README.MD (aa47921)
    • docs: add more translations, italian, spanish, russian and chinese (#194) (95305eb)
    • Update README.MD (8cad28e)
    • Update README_FA.MD (450cacc)
    • Update README_RU.MD (7f096e5)
    • fix: return NXDOMAIN for non-tunnel DNS queries (#189) (8a81e3d)
    • Remove oosmetrics badges from README (4b583e0)
    • Update README.MD (89fcf58)
    • Update README_ES.MD (3c52dee)
    • Update README_FA.MD (914c7a2)
    • Update README_IT.MD (2e2353d)
    • Update README_RU.MD (a9a9db3)
    • Update README_ZH.MD (61362cb)
    • Update build-go.yml (bc69a58)
    • Update README with new badges and project comparison (1e8d7cf)
    • Update README_ES.MD (01664a0)
    • Update README_FA.MD (7cbce1e)
    • Update README_IT.MD (9390c14)
    • Update README_RU.MD (34436d7)
    • Update README_ZH.MD (897894b)
    • Support dual-stack UDP wildcard listeners (#200) (81f8924)
    • Add fallback handling for non-DNS UDP traffic (#199) (acbf1c6)
    • Add opt-in fd protection for upstream UDP sockets (Android VpnService) (#196) (f8eb323)
    • Upload builds. (aeb5769)
    • Docker build (5f83ee9)

    Merged PRs

    • #194 docs: add more translations, italian, spanish, russian and chinese @Helias
    • #189 fix: return NXDOMAIN for non-tunnel DNS queries @nyxst4ck
    • #200 Support dual-stack UDP wildcard listeners @Mygod
    • [#199](h
  2. v2026.06.13.234407-7de2476Release v2026.06.13.234407-7de24762026-06-13 · 2026-06-13 23:47 UTC
    查看更新说明

    Changes since v2026.05.10.180256-27c7e11:

    Automated release created by workflow run 27482590364 for commit 7de2476f1c33e69eec35360c52810dab43c5c986

    Commits

    • Update README.MD (17e3df8)
    • Add russian localization for README.MD (#185) (e40f0b7)
    • Update README.MD (4da2ae4)
    • Update README.MD (aae8b2f)
    • Add GitHub Sponsors username to FUNDING.yml (db4aa3f)
    • Fixed a possible apt-get update error (#188) (81f3d29)
    • Add support for Russian README in build workflow (7de2476)

    Merged PRs

    • #185 Add russian localization for README.MD @Fy0urM
    • #188 Fixed a possible apt-get update error @BabakAmini

    Contributors

    • @masterking32 — 5 commit(s)
    • @Fy0urM — 1 commit(s)
    • @BabakAmini — 1 commit(s)
  3. v2026.05.10.180256-27c7e11Release v2026.05.10.180256-27c7e112026-05-10 · 2026-05-10 18:05 UTC
    查看更新说明

    Changes since v2026.05.04.123456-38b73de:

    Automated release created by workflow run 25635856673 for commit 27c7e11ce9eb51d7db36b34188502e524a3184db

    Commits

    • Add badges to README for project visibility (ae4a40d)
    • Update README.MD (dd1c223)
    • Added new balancers to logs. (4c45fe6)
    • Update some of default configs. (a6bad63)
    • Change limits. (665f8bf)
    • Add GitHub Trend Badge from Trendshift (45f24f9)
    • Update logos. (4068fa4)
    • Update logos. (c746810)
    • implement smart MTU outlier detection. (d9f0482)
    • Update outlier log. (27c7e11)

    Contributors

    • @masterking32 — 10 commit(s)
  4. v2026.05.04.123456-38b73deRelease v2026.05.04.123456-38b73de2026-05-04 · 2026-05-04 12:37 UTC
    查看更新说明

    Changes since v2026.04.12.234117-978faee:

    Automated release created by workflow run 25319270649 for commit 38b73de5993fc2d208e5df2c1765ddc8397d5222

    Commits

    • Update README.MD (a7aef64)
    • Update README.MD (f9dee92)
    • Ignore injected executable path in client positional args (49cd565)
    • Merge branch 'main' of https://github.com/masterking32/MasterDnsVPN (768ec46)
    • Compact recently-closed heap to prevent stale entry accumulation (#134) (e6bd8e3)
    • MasterDNSWeb Added (#138) (aff170e)
    • Add KevinNet DNS project details to README (#147) (f466bf8)
    • feat(docker): add containerization setup and build scripts (README updated) (#154) (b6ecd85)
    • ci(docker): automate GHCR multi-arch publish in release workflow and harden Docker scripts (e29b497)
    • fix(docker): correct GitHub release asset URL for server zip download (51248db)
    • Removed docker-ghcr.yml (8c1562e)
    • Update installer, Allow install old versions and uninstall. (1bc7454)
    • Fixed syntax error (CRLF->LF) (145e510)
    • Fixed BOM/LF (538af44)
    • Remove Old binaries (aa76a35)
    • Fixed issue of installing old versions. (38b73de)

    Merged PRs

    • #134 Compact recently-closed heap to prevent stale entry accumulation @Isusami
    • #138 MasterDNSWeb Added @abolix
    • #147 Add KevinNet DNS project details to README @kamalalhagh
    • #154 feat(docker): add containerization setup and build scripts (README updated) @pouya6672

    Contributors

    • @masterking32 — 12 commit(s)
    • @Isusami — 1 commit(s)
    • @abolix — 1 commit(s)
    • @kamalalhagh — 1 commit(s)
    • @pouya6672 — 1 commit(s)
  5. v2026.04.12.234117-978faeeRelease v2026.04.12.234117-978faee2026-04-12 · 2026-04-12 23:43 UTC
    查看更新说明

    Changes since v2026.04.11.044523-0639f8b:

    Automated release created by workflow run 24319218457 for commit 978faeec4c4e2d79f07842c28d97ef46614e775f

    Commits

    • Log resolver timeouts to MTU output and tidy MTU handling (137b919)
    • Adjust auto-disable thresholds for large timeout windows (bc3c57e)
    • Reactive log. (243a634)
    • Confirm resolver down before auto-disable on small pools (28b0cb8)
    • Align minimum MTU floors with session payload sizes (86972d5)
    • Update Readme files. (6591c8b)
    • Update Readme (How to use with 3x-ui) (eba217c)
    • Update Readme Styles. (978faee)

    Contributors

    • @masterking32 — 8 commit(s)

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    MasterDnsVPN Project 🔐

    | 🇮🇷 فارسی | 🇬🇧 English | 🇷🇺 Русский | 🇨🇳 中文 | 🇪🇸 Español | 🇮🇹 Italiano |

    MasterDnsVPN is a scientific and research-oriented project for carrying TCP traffic through DNS queries and responses. In broad goal, it is similar to projects such as DNSTT or SlipStream, but it follows a fundamentally different structure and implementation approach. This system is designed around compatibility with many resolver behaviors and harsh network conditions, with the goal of preserving the highest possible stability and data delivery even in the worst cases.

    Ask DeepWiki

    📊 MasterDnsVPN Compared with Similar Projects

    FeatureSlipStreamDNSTTMasterDnsVPN
    Protocol typeAdvanced DNS tunnelClassic DNS tunnelAdvanced DNS tunnel
    Transport protocolQUICKCP + NoiseCustom protocol + ARQ
    Transport header overhead🟠 ~24B🔴 ~59B🟢 ~5–7B≈88% lower than DNSTT≈71% lower than SlipStream
    Encryption styleTLS 1.3 (inside QUIC)Noise (Curve25519)AES / ChaCha20 / XOR (if XOR is used: lightweight with lower security and no extra overhead)
    ArchitectureUnified (QUIC handles everything)Multi-layered (KCP + SMUX + Noise)🟢 Lightweight custom design optimized for DNS
    Speed🟡 High (up to ~5× faster than DNSTT)🔴 Medium🟢 Faster than othersUp to ~9× faster than DNSTTUp to ~3.6× faster than SlipStream
    Stability under packet loss🟡 Good🟠 Medium🟢 Very high (Multi-resolver routing + ARQ)
    Multi-resolver supportYes (multipath)❌Yes — advanced (multi-resolver routing + duplication)
    Resilience under heavy censorshipGoodMediumVery strong (a core project goal)
    Setup complexityMediumSimpleEasier installationMore complex only if you heavily customize advanced settings
    SOCKS5 supportYesYesOptimized for SOCKS5 / SOCKS4 with reduced SOCKS overhead
    Shadowsocks support✅❌Indirectly: TCP Forwarding mode can carry TCP-based protocolse.g. Shadowsocks, VLESS/VMess, etc.
    Multi-resolver routingYes (QUIC multipath)❌Yes (multi-resolver routing + duplication)
    Adaptive routingLimited❌Advanced (latency/loss based)
    Design goalHigh speed and efficiencySimplicity and stabilitySurviving the harshest networks — stability, speed, and efficiency
    Implementation languageRustGoMain version is GoLegacy Python version also exists
    Built-in resolver balancer🔴❌🟢 (8 built-in balancing modes)
    Duplication system❌❌Yes — increases traffic to improve reliability (configurable or can be disabled)
    MTU toleranceBetter than DNSTT-Works even with very small MTU because protocol overhead is very low
    Failover system❌❌✅
    Download speed 10MB (Local)🟡 0.978s🔴 2.492s🟢 0.270s
    Upload speed 10MB (Local)🟡 3.249s🔴 16.207s🟢 1.746s
    Resolver health checks and auto-disable❌❌✅
    Background reactivation of healthy resolvers❌❌✅
    Local DNS service on client (to reduce DNS hijacking)❌❌✅ (with strong DNS caching)
    DNS resolving through SOCKS5❌❌✅ (with DNS caching)
    Fine-grained professional configuration🟠🟠🟢 Almost every subsystem is configurable
    No external helper software required❌❌🟢 No extra software is required; if needed, you can still combine it with SOCKS or tools such as Shadowsocks or OpenVPN

    ❌ Disclaimer

    MasterDnsVPN is provided as an educational and research project only.

    • Provided without warranty: This software is provided “AS-IS”, without any express or implied warranty, including merchantability, fitness for a particular purpose, or non-infringement.
    • Limitation of liability: The developers and contributors of this project accept no responsibility for any direct, indirect, incidental, consequential, or other damages arising from the use of this software or the inability to use it.
    • User responsibility: Using this project outside test environments may disrupt or damage network behavior. The user alone is responsible for all consequences of installation, configuration, and use.
    • Legal compliance: Using this project to bypass local laws may result in civil or criminal consequences. Please review the laws and regulations of your country before use. The developers accept no responsibility for violations of local, national, or international laws by users.
    • License terms: Use, copying, distribution, or modification of this software is governed by the license in the LICENSE file of this repository. Any use outside those terms is prohibited.

    Announcement and Support Channel 📢

    For the latest news, releases, and project updates, follow our Telegram channel: Telegram Channel


    If you like this project, please support it by starring it on GitHub (⭐). It helps the project get discovered.


    Optional Financial Support 💸

    • TON network:

    masterking32.ton

    • EVM-compatible networks (ETH and compatible chains):

    0x517f07305D6ED781A089322B6cD93d1461bF8652

    • TRC20 network (TRON):

    TLApdY8APWkFHHoxebxGY8JhMeChiETqFH

    Every contribution and every piece of feedback is appreciated. Support directly helps ongoing development and improvement.


    Key Features and Advantages ✨

    A brief overview of the main capabilities of MasterDnsVPN:

    • Censorship resistance and harsh-network survivability: 🛡️ Designed to work on filtered networks, unstable links, and strict MTU environments.
    • Lightweight custom protocol: 🔄 Uses a custom protocol with retransmission logic to reduce overhead and increase usable DNS payload.
    • Multi-resolver routing and packet duplication: 📡 Routes queries across multiple resolvers and supports selective duplication to increase delivery probability on unstable networks.
    • Smart resolver selection and health checks: ⚡ Selects resolvers based on quality and health, and manages problematic resolvers automatically.
    • MTU discovery and synchronization: 🧰 Detects the practical MTU of working resolver pairings and aligns around it to reduce fragmentation and improve stability.
    • SOCKS5 / SOCKS4 support and optimization: 🧦 Optimized local proxy handling for common applications.
    • Packed control blocks and lower control overhead: 📦 Groups ACK/control traffic together to reduce control chatter.
    • Optional compression and request packing: 🗜️ Reduces request counts and improves efficiency under small-MTU conditions.
    • Flexible encryption: 🔐 Supports multiple encryption methods to balance speed and security.
    • Optional client-side local DNS and caching: 📛 Can expose a local DNS service, reduce latency, and limit hijacking opportunities.
    • Scalable resource control: ⚙️ Can run on small servers or be tuned for heavier loads.

    This list is only a high-level summary. The related sections below explain each area in more detail.


    🌐 Battle-Tested During a Total Internet Blackout

    MasterDnsVPN isn't just a theoretical project. It is battle-tested and proven to work in environments where the global internet is completely severed.

    Recently, during the 88-day internet blackout in Iran, authorities didn't just block VPNs or filter websites—they completely pulled the plug on international bandwidth. With 99% of the connection to the outside world physically cut off, users were trapped inside a closed, local intranet.

    Standard circumvention tools are useless when there is no international internet to connect to. Yet, during this massive shutdown, MasterDnsVPN stood out as one of the very few lifelines that actually kept users connected to the global web.

    How did it survive a total shutdown? Instead of acting like a standard VPN, MasterDnsVPN relies on smart DNS tunneling techniques to pierce through the blackout:

    • Multiple Resolvers: It routes traffic through various DNS resolvers, ensuring the connection never relies on a single, easily blockable path.
    • Encryption & Data Splitting: It encrypts your data and breaks it down into tiny, scattered pieces.
    • Disguised as Legitimate Traffic: It wraps these data pieces inside standard, perfectly normal DNS queries.
    • Bypassing Local Traps: Because the traffic looks exactly like basic, everyday DNS requests, firewalls allow it through. The data gets resolved and reaches the outside world—even if the network forces you to use their own restricted, government-controlled local resolvers.

    This exact combination is what allowed MasterDnsVPN to maintain a stable connection when the outside world was completely blocked.


    Setup and Getting Started 🧑‍💻

    Section 1: 🖥️ Server Setup

    Section 1.1: 🌐 Domain Setup and Preparation (Prerequisite)

    To receive DNS requests directly on your server, you must delegate a subdomain to it. In short, create two records: one A record that points to your server IP, and one NS record that delegates the tunnel subdomain to that A record.

    Step 1.1.1: 🅰️ Create an A Record (Server Address)
    • Type: A
    • Name: a short name such as ns
    • Value: your server IPv4 address

    Example: ns.example.com -> 1.2.3.4

    Cloudflare note: if the domain uses Cloudflare, open the DNS page and click the cloud icon next to the A record so it becomes gray (DNS only). It must not remain proxied.

    Step 1.1.2: 🏷️ Create an NS Record (Delegate the Subdomain)
    • Type: NS
    • Name: the tunnel subdomain, for example v
    • Value / Target: ns.example.com

    Example: v.example.com -> ns.example.com

    Cloudflare note: add the NS record normally. Cloudflare does not proxy NS records, but make sure the ns A record is already set to DNS only.

    Section 1.1.3: 💡 A Short Note About MTU

    Shorter domain names leave more space for actual data inside each DNS request. For better throughput, keep names short. If you use Cloudflare, still keep the relevant records in DNS only mode.


    Section 1.2: 🐧 Quick Linux Server Installation

    Step 1.2.1: Automatic Installation (Script)

    If you want to deploy the server on Linux, the easiest method is the automatic installer script. Run this command on the server:

    bash <(curl -Ls https://raw.githubusercontent.com/masterking32/MasterDnsVPN/main/server_linux_install.sh)
    

    The script handles installation and configuration automatically. When it finishes, the server starts and the encryption key is shown in the terminal log and also written to encrypt_key.txt next to the executable. Keep this key safe.

    Step 1.2.2: Important Notes After Installation
    • During installation, you will be asked for a domain. It must be the same delegated subdomain you configured in the NS record, for example v.example.com.
    • After creating DNS records, wait for propagation. This may take from a few minutes to several hours, and in some cases up to 48 hours depending on TTL and the DNS provider.
    • To verify the DNS setup, you can use tools such as dig or nslookup, for example dig v.example.com NS or nslookup -type=ns v.example.com. For a direct query to the new nameserver: dig @ns.example.com v.example.com A.
    • If the server firewall is enabled, allow UDP port 53. Example for ufw:
    sudo ufw allow 53/udp
    sudo ufw reload
    

    For firewalld:

    sudo firewall-cmd --add-port=53/udp --permanent
    sudo firewall-cmd --reload
    
    • If port 53 is already occupied by another service, such as systemd-resolved, see the troubleshooting section “Fixing Port 53 Already in Use”.
    • The encryption key (encrypt_key.txt) is shown after installation. Copy it and store it safely because the client needs it to connect.

    Section 2: 🚀 Installation and Launch (Client and Server)

    You can install and run this project in two ways:

    1. Use the prebuilt binaries (recommended for most users)
    2. Run directly from source with Go (recommended for developers)

    Section 2.1: Use Prebuilt Releases (✅ Recommended)

    For convenience, prebuilt client and server binaries are published in the release page. Download the correct archive for your operating system and extract it.

    💡 Note: Release archives usually include the binary plus sample configuration files.

    Client Download Links 📥
    Operating SystemArchitectureSuitable ForDirect Download
    Windows 🪟AMD64 (64-bit)Windows 10 and 11Download Windows Client ⬇️
    Windows 🪟x86 (32-bit)Older 32-bit Windows systemsDownload Windows x86 Client ⬇️
    Windows 🪟ARM64Windows on ARM devicesDownload Windows ARM64 Client ⬇️
    macOS 🍎ARM64Apple Silicon Macs (M1 / M2 / M3)Download macOS Client ⬇️
    macOS 🍎AMD64Intel MacsDownload macOS Intel Client ⬇️
    Linux 🐧AMD64 (64-bit)Modern distributions (Ubuntu 22.04+, Debian 12+)Download Linux Client ⬇️
    Linux 🐧x86 (32-bit)Older 32-bit Linux systemsDownload Linux x86 Client ⬇️
    Linux (Legacy) 🐧AMD64 (64-bit)Older distributions (Ubuntu 20.04, Debian 11)Download Linux Legacy Client ⬇️
    Linux (Legacy) 🐧ARM64Older ARM64 Linux systems that need broader compatibilityDownload Linux Legacy ARM64 Client ⬇️
    Linux (ARM) 🐧ARM64ARM servers, Raspberry Pi, and similar boardsDownload Linux ARM Client ⬇️
    Linux (ARM) 🐧ARMv732-bit ARM boards and older embedded Linux devicesDownload Linux ARMv7 Client ⬇️
    Linux (ARM) 🐧ARMv6Older ARM boards and lightweight Linux devicesDownload Linux ARMv6 Client ⬇️
    Linux (ARM) 🐧ARMv5Very old ARM devices and embedded Linux systemsDownload Linux ARMv5 Client ⬇️
    Linux 🐧RISCV64RISC-V Linux boards and serversDownload Linux RISCV64 Client ⬇️
    Linux (MIPS) 🐧MIPSBig-endian MIPS Linux and router platformsDownload Linux MIPS Client ⬇️
    Linux (MIPS) 🐧MIPSLELittle-endian MIPS Linux and router platformsDownload Linux MIPSLE Client ⬇️
    Linux (MIPS) 🐧MIPS6464-bit big-endian MIPS Linux systemsDownload Linux MIPS64 Client ⬇️
    Linux (MIPS) 🐧MIPS64LE64-bit little-endian MIPS Linux systemsDownload Linux MIPS64LE Client ⬇️
    Termux / Android 📱ARM64Modern Android phones running TermuxDownload Termux ARM64 Client ⬇️
    Termux / Android 📱ARMv7Older Android phones running 32-bit Termux environmentsDownload Termux ARMv7 Client ⬇️
    Server Download Links 📤

    (Use these if you do not want the automated Linux installer.)

    Operating SystemArchitectureSuitable ForDirect Download
    Windows 🪟AMD64 (64-bit)Windows Server, Windows 10 and 11Download Windows Server ⬇️
    Windows 🪟x86 (32-bit)Older 32-bit Windows systemsDownload Windows x86 Server ⬇️
    Windows 🪟ARM64Windows on ARM devicesDownload Windows ARM64 Server ⬇️
    Linux 🐧AMD64 (64-bit)Ubuntu 22.04+, Debian 12+ serversDownload Linux Server ⬇️
    Linux 🐧x86 (32-bit)Older 32-bit Linux systemsDownload Linux x86 Server ⬇️
    Linux (Legacy) 🐧AMD64 (64-bit)Older servers (Ubuntu 20.04, Debian 11)Download Linux Legacy Server ⬇️
    Linux (Legacy) 🐧ARM64Older ARM64 Linux systems that need broader compatibilityDownload Linux Legacy ARM64 Server ⬇️
    Linux (ARM) 🐧ARM64ARM serversDownload Linux ARM Server ⬇️
    Linux (ARM) 🐧ARMv732-bit ARM servers and embedded Linux devicesDownload Linux ARMv7 Server ⬇️
    Linux (ARM) 🐧ARMv6Older ARM boards and lightweight Linux devicesDownload Linux ARMv6 Server ⬇️
    Linux (ARM) 🐧ARMv5Very old ARM devices and embedded Linux systemsDownload Linux ARMv5 Server ⬇️
    Linux 🐧RISCV64RISC-V Linux boards and serversDownload Linux RISCV64 Server ⬇️
    Linux (MIPS) 🐧MIPSBig-endian MIPS Linux and router platformsDownload Linux MIPS Server ⬇️
    Linux (MIPS) 🐧MIPSLELittle-endian MIPS Linux and router platformsDownload Linux MIPSLE Server ⬇️
    Linux (MIPS) 🐧MIPS6464-bit big-endian MIPS Linux systemsDownload Linux MIPS64 Server ⬇️
    Linux (MIPS) 🐧MIPS64LE64-bit little-endian MIPS Linux systemsDownload Linux MIPS64LE Server ⬇️
    macOS 🍎ARM64Apple Silicon MacsDownload macOS Server ⬇️
    macOS 🍎AMD64Intel MacsDownload macOS Intel Server ⬇️
    Termux / Android 📱ARM64Modern Android / Termux environmentsDownload Termux ARM64 Server ⬇️
    Termux / Android 📱ARMv7Older Android / 32-bit Termux environmentsDownload Termux ARMv7 Server ⬇️

    Section 2.2: 📦 MasterDnsVPN Docker Image


    Section 2.2.1: ⚠️ Overview

    This Docker image runs the MasterDnsVPN server in a containerized environment and supports multi-architecture builds.

    It automatically:

    • Boots a default configuration if none exists
    • Injects your domain on first startup
    • Stores persistent data in /data

    Section 2.2.2: 🖥 Supported Architectures
    • linux/amd64
    • linux/arm/v5
    • linux/arm/v7
    • linux/arm64/v8
    • linux/mips64le

    The image bundles the server and its configuration template for all five architectures. First startup works without downloading files; existing configuration and keys in /data are reused. The minimal runtime has no shell or package manager.


    Section 2.2.3: 🚀 Quick Start

    Run the container with Docker:

    docker run -d \
      --name masterdnsvpn \
      --restart unless-stopped \
      -e DOMAIN=v.example.com \
      -v $(pwd)/data:/data \
      -p 53:53/tcp \
      -p 53:53/udp \
      ghcr.io/masterking32/masterdnsvpn:latest
    

    Section 2.2.4: 🧪 Example with docker-compose
    services:
      masterdnsvpn:
        image: ghcr.io/masterking32/masterdnsvpn:latest
        restart: unless-stopped
        environment:
          - DOMAIN=v.example.com
        volumes:
          - ./data:/data
        ports:
          - "53:53/tcp"
          - "53:53/udp"
    

    Section 2.2.5: ⚙️ Required Environment Variables
    VariableDescription
    DOMAINYour DNS domain (required on first run)

    ⚠️ If DOMAIN is not set on first boot, the container will stop with an error.


    Section 2.2.6: 📁 Persistent Data

    Stored in /data:

    • server_config.toml
    • encrypt_key.txt

    You can mount it as volume:

    -v ./data:/data
    

    Section 2.2.7: 🔧 MikroTik / RouterOS Usage

    For MikroTik containers:

    Example:

    /container mounts
    add dst=/data list=MasterDnsVPN src=/containers/mounts/MasterDnsVPN
    
    /container envs
    add key=DOMAIN list=MasterDnsVPN value=v.example.com
    
    /container add check-certificate=no dns=1.1.1.1 envlists=MasterDnsVPN hostname=MasterDnsVPN interface=MasterDnsVPN layer-dir="" mountlists=MasterDnsVPN name=MasterDnsVPN remote-image=ghcr.io/masterking32/masterdnsvpn:latest root-dir=/containers/data/MasterDnsVPN start-on-boot=yes
    

    Section 2.2.8: 📌 Notes
    • DNS port 53 is required (UDP/TCP)
    • Do NOT run another DNS service on the same host
    • Designed for production use but still lightweight
    • No systemd or host modifications required

    Section 2.3: 🪟 Preparing and Running the Client on Windows

    • After downloading the Windows package, extract it.
    • Open client_config.toml with a text editor such as Notepad.
    • Replace the default values with your real domain, encryption key, and resolver list.
    • Run the client executable.
    • Configure your browser or app to use the local SOCKS5 proxy at 127.0.0.1:18000 unless you changed the defaults.

    Section 2.4: 🐧 Preparing and Running on Linux / macOS

    After downloading the package on Linux:

    sudo apt update
    sudo apt install unzip nano
    

    Extract the archive:

    unzip MasterDnsVPN_Client_Linux_AMD64.zip
    ls
    

    Give execute permission if needed:

    chmod +x MasterDnsVPN_Client_Linux_AMD64
    chmod +x MasterDnsVPN_Server_Linux_AMD64
    

    Edit the configuration:

    nano client_config.toml
    nano server_config.toml
    

    Then run:

    ./MasterDnsVPN_Client_Linux_AMD64
    ./MasterDnsVPN_Server_Linux_AMD64
    

    Section 2.5: 🧑‍💻 Run Directly from Source (Go)

    ⚠️ This section is intended for developers or users who want to run the current Go source directly.

    Prerequisite
    • Go 1.24 or newer
    Build from source
    git clone https://github.com/masterking32/MasterDnsVPN.git
    cd MasterDnsVPN
    
    go build -o masterdnsvpn-client ./cmd/client
    go build -o masterdnsvpn-server ./cmd/server
    

    On Windows:

    git clone https://github.com/masterking32/MasterDnsVPN.git
    cd MasterDnsVPN
    
    go build -o masterdnsvpn-client.exe .\cmd\client
    go build -o masterdnsvpn-server.exe .\cmd\server
    
    Create config files

    On Linux and macOS:

    cp client_config.toml.simple client_config.toml
    cp server_config.toml.simple server_config.toml
    cp client_resolvers.simple client_resolvers.txt
    

    On Windows:

    Copy-Item client_config.toml.simple client_config.toml
    Copy-Item server_config.toml.simple server_config.toml
    Copy-Item client_resolvers.simple client_resolvers.txt
    
    Run the server and client
    ./masterdnsvpn-server -config server_config.toml
    ./masterdnsvpn-client -config client_config.toml
    

    On Windows:

    .\masterdnsvpn-server.exe -config server_config.toml
    .\masterdnsvpn-client.exe -config client_config.toml
    
    Command-line parameters

    Both binaries support these arguments:

    ParameterDescription
    -configPath to the configuration file
    -logOptional path to a log file
    -versionPrint version and exit

    Example:

    ./masterdnsvpn-server -config server_config.toml -log server.log
    ./masterdnsvpn-client -config client_config.toml -log client.log
    

    Section 3: Configuration Files and Structure 🛠️

    Section 3.1: Important Project Files 📂

    FilePurpose
    client_config.tomlMain client configuration
    server_config.tomlMain server configuration
    client_resolvers.txtResolver list
    encrypt_key.txtShared server-side encryption key
    client_config.toml.simpleFull sample client config for the current Go version
    server_config.toml.simpleFull sample server config for the current Go version

    Accepted formats in client_resolvers.txt:

    • IP
    • IP:PORT
    • CIDR
    • CIDR:PORT

    Example:

    8.8.8.8
    1.1.1.1:53
    9.9.9.0/24
    208.67.222.0/24:5353
    

    Section 3.2: Quick Client Checklist 🚀

    These items are required on the client:

    1. ENCRYPTION_KEY must match the content of the server’s encrypt_key.txt
    2. DOMAINS must match the server domain
    3. client_resolvers.txt must contain working resolvers
    4. For normal use, keep PROTOCOL_TYPE = "SOCKS5"

    Section 3.3: Quick Server Checklist ⚙️

    These settings are critical on the server:

    1. Set DOMAIN to your delegated tunnel domain
    2. DATA_ENCRYPTION_METHOD must match the client
    3. ENCRYPTION_KEY_FILE defines the path to the server key file
    4. If you want direct outbound connections, keep USE_EXTERNAL_SOCKS5 = false
    5. If you want to chain through an external SOCKS5 proxy, set USE_EXTERNAL_SOCKS5 = true and fill FORWARD_IP / FORWARD_PORT

    Section 3.4: 📘 Client Configuration Variables (client_config.toml)

    3.4.1) 🧭 Tunnel Identity and Security

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    PROTOCOL_TYPE"SOCKS5""SOCKS5" or "TCP"Chooses the local service mode exposed by the client.SOCKS5 is the default and recommended mode for normal use.TCP is useful when you want to forward traffic to one fixed remote destination instead of giving applications a SOCKS proxy.
    DOMAINS["v.example.com"]Non-empty list of stringsThese are the tunnel domains used to build DNS requests.Every domain here must belong to the same tunnel you configured on the server.If this list is wrong, the client may build valid DNS queries that the server will simply ignore.
    DATA_ENCRYPTION_METHOD10..5Must match the server.0=None, 1=XOR, 2=ChaCha20, 3=AES-128-GCM, 4=AES-192-GCM, 5=AES-256-GCM.XOR is lightweight but weaker. AEAD modes are stronger but have more overhead.
    ENCRYPTION_KEY""StringShared secret used by the client codec.This must be exactly the same as the server-side encryption key.If the key is wrong, packets may be parsed as garbage and the tunnel will not work.Not required when DATA_ENCRYPTION_METHOD is 0.

    3.4.2) 🧦 Local Proxy

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    LISTEN_IP"127.0.0.1"Valid IP stringAddress where the client listens for local proxy users.Use 127.0.0.1 for normal local-only usage.If some applications prefer IPv6 localhost on your system, using localhost can be a better local-only choice.Use 0.0.0.0 only if you want to share the proxy on the network and understand the security implications.
    LISTEN_PORT180000..65535Port for the local proxy.Your applications must use this port to send traffic into the tunnel.
    SOCKS5_AUTHfalsetrue/falseEnables username/password authentication on the local SOCKS5 proxy.If you bind to 0.0.0.0, enabling this is strongly recommended.
    SOCKS5_USER"master_dns_vpn"Up to 255 bytesUsername for the local SOCKS5 proxy.Used only if SOCKS5_AUTH=true.
    SOCKS5_PASS"master_dns_vpn"Up to 255 bytesPassword for the local SOCKS5 proxy.Used only if SOCKS5_AUTH=true.

    3.4.3) 📛 Local DNS

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    LOCAL_DNS_ENABLEDfalsetrue/falseIf enabled, the client exposes a local DNS service and can resolve DNS through the tunnel.This is useful for reducing DNS hijacking or when you want applications to use the tunnel for DNS as well.
    LOCAL_DNS_IP"127.0.0.1"Valid IP stringBind address for the local DNS listener.
    LOCAL_DNS_PORT530..65535Port of the local DNS service.Port 53 is standard, but on some systems it may already be used by another service.
    LOCAL_DNS_CACHE_MAX_RECORDS5000If <1, fallback appliesMaximum number of local DNS cache records.A larger value reduces repeated DNS lookups but uses more memory.
    LOCAL_DNS_CACHE_TTL_SECONDS28800.0If <=0, fallback appliesHow long successful DNS records stay in the local cache.
    LOCAL_DNS_PENDING_TIMEOUT_SECONDS300.0If <=0, fallback appliesIf a local DNS query is in progress, follower queries can wait for it instead of launching another upstream request.This value defines how long they may wait.
    LOCAL_DNS_CACHE_PERSIST_TO_FILEtruetrue/falseIf enabled, the local DNS cache can be written to disk for reuse between runs.
    LOCAL_DNS_CACHE_FLUSH_INTERVAL_SECONDS60.0If <=0, fallback appliesHow often the persisted local DNS cache is flushed to disk.
    DNS_RESPONSE_FRAGMENT_TIMEOUT_SECONDS10.0If <=0, fallback appliesHow long the client waits for missing DNS tunnel response fragments before giving up.

    3.4.4) ⚡ Resolver Selection, Duplication, Health, and Failover

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    RESOLVER_BALANCING_STRATEGY20..8Chooses how resolvers are selected.0/2 = Round Robin, 1 = Random, 3 = Least Loss, 4 = Lowest Latency, 5 = Hybrid Score, 6 = Loss Then Latency, 7 = Least Loss Top Random, 8 = Least Loss Top Round Robin.The hybrid mode uses a weighted combined score. The loss-then-latency mode first shortlists by loss, then prefers lower latency inside that tier, and rotates among near-equal top candidates. The top-random mode picks randomly from the best loss tier so load does not stick to one resolver. The top-round-robin mode cycles through the same top loss tier with deterministic rotation.
    PACKET_DUPLICATION_COUNT2clamp to valid range in codeNormal outgoing packet duplication count.Higher values increase traffic cost but improve survivability on weak links.
    SETUP_PACKET_DUPLICATION_COUNT2clamp to valid range in codeSimilar to PACKET_DUPLICATION_COUNT, but used for setup-sensitive packets such as stream creation and other critical control events.
    STREAM_RESOLVER_FAILOVER_RESEND_THRESHOLD2If <1, fallback appliesIf a stream accumulates repeated resend pressure on the same preferred resolver, the client may fail over that stream to another resolver.This threshold controls how quickly that happens.
    STREAM_RESOLVER_FAILOVER_COOLDOWN2.5If <=0, fallback appliesMinimum delay between two failovers for the same stream.This prevents unstable oscillation between resolvers.
    RECHECK_INACTIVE_SERVERS_ENABLEDtruetrue/falseEnables background rechecks for currently disabled or unhealthy resolvers.If disabled, once a resolver becomes unusable, it will stay disabled until restart or manual rebuild.
    AUTO_DISABLE_TIMEOUT_SERVERStruetrue/falseEnables automatic disabling of resolvers that keep timing out and show no successful activity.
    AUTO_DISABLE_TIMEOUT_WINDOW_SECONDS30.0If <=0, fallback appliesTime window used to decide whether a resolver is timeout-only.If all observations in this window are timeouts, it may be disabled.
    FD_CONTROL_UNIX_SOCKET""Empty, or a Unix socket pathAndroid VpnService hosts only.When set, the client sends the fd of every upstream UDP socket (resolver pool, MTU probes, health checks, tunnel workers) to this Unix socket before connect/bind, so the host can call VpnService.protect(fd) and keep resolver traffic out of the tunnel.The client never sends local listeners (SOCKS5/TCP, SOCKS5 UDP relay, local DNS). If the protect server is unreachable or rejects the fd, socket creation fails.Leave empty on desktop and server setups.
    BASE_ENCODE_DATAfalsetrue/falseIf enabled, payloads are encoded in a base-safe format before tunneling.This usually reduces payload efficiency, but can help in strict resolver environments.

    3.4.5) 🗜️ Compression

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    UPLOAD_COMPRESSION_TYPE00..30=OFF, 1=ZSTD, 2=LZ4, 3=ZLIB.Controls client-side compression for outgoing payloads.
    DOWNLOAD_COMPRESSION_TYPE00..3Compression type expected or preferred for server-to-client payloads.
    COMPRESSION_MIN_SIZE120If invalid, fallback appliesMinimum payload size before compression is attempted.Very small packets often grow instead of shrinking, so this avoids pointless compression work.

    3.4.6) 🧪 MTU Discovery and Initial Testing

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    MIN_UPLOAD_MTU38positive integerSmallest upload MTU the client accepts during resolver testing. Minimum enforced is the session-init payload size (10).
    MIN_DOWNLOAD_MTU100positive integerSmallest download MTU the client accepts during resolver testing. Minimum enforced is the session-accept payload size (20).
    MAX_UPLOAD_MTU150positive integerUpper bound for upload MTU testing.
    MAX_DOWNLOAD_MTU500positive integerUpper bound for download MTU testing.
    MTU_TEST_RETRIES2if invalid, fallback appliesNumber of retries for each MTU probe.
    MTU_TEST_TIMEOUT2.0if invalid, fallback appliesTimeout for a single MTU probe.
    MTU_TEST_PARALLELISM16if invalid, fallback appliesNumber of resolvers tested in parallel during MTU scanning.Higher values scan faster but use more CPU/network and may produce more noisy failures.
    SAVE_MTU_SERVERS_TO_FILEfalsetrue/falseIf enabled, successful resolver results are written to an output file.
    MTU_SERVERS_FILE_NAME"masterdnsvpn_success_test_{time}.log"stringOutput file name template for successful MTU-tested resolvers.
    MTU_SERVERS_FILE_FORMAT"{IP} ({DOMAIN}) - UP: {UP_MTU} DOWN: {DOWN-MTU}"stringOutput format used in the MTU results file.
    MTU_USING_SECTION_SEPARATOR_TEXT""stringOptional separator text inserted into the MTU output file.
    MTU_REMOVED_SERVER_LOG_FORMAT"Resolver {IP} ({DOMAIN}) removed at {TIME} due to {CAUSE}"stringLog/output format when a resolver is removed from the valid set.
    MTU_ADDED_SERVER_LOG_FORMAT"Resolver {IP} ({DOMAIN}) added back at {TIME} (UP {UP_MTU}, DOWN {DOWN_MTU})"stringLog/output format when a resolver is restored.
    MTU_REACTIVE_ADDED_SERVER_LOG_FORMAT"Resolver {IP} ({DOMAIN}) added back at {TIME} after reactive recheck (UP {UP_MTU}, DOWN {DOWN_MTU})"stringLog/output format when a resolver is restored by background health checks.

    3.4.7) 🧵 Runtime Workers, Queues, and Timers

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    RX_TX_WORKERS4if invalid, fallback appliesNumber of shared runtime workers used for both UDP tunnel reads and writes.
    TUNNEL_PROCESS_WORKERS6if invalid, fallback appliesNumber of workers processing tunnel packets after read.
    TUNNEL_PACKET_TIMEOUT_SECONDS10.0if invalid, fallback appliesOverall timeout for tunnel packet handling.
    DISPATCHER_IDLE_POLL_INTERVAL_SECONDS0.020if invalid, fallback appliesWhen there is nothing to send, the dispatcher sleeps for this interval before polling again.
    RX_CHANNEL_SIZE4096if invalid, fallback appliesCapacity of the incoming tunnel packet channel.
    SOCKS_UDP_ASSOCIATE_READ_TIMEOUT_SECONDS30.0if invalid, fallback appliesRead timeout for SOCKS UDP associate mode.
    CLIENT_TERMINAL_STREAM_RETENTION_SECONDS45.0if invalid, fallback appliesHow long terminal streams remain in client bookkeeping before full cleanup.
    CLIENT_CANCELLED_SETUP_RETENTION_SECONDS120.0if invalid, fallback appliesRetention time for setup streams cancelled before completion.
    SESSION_INIT_RETRY_BASE_SECONDS1.0if invalid, fallback appliesBase delay for session-init retries.
    SESSION_INIT_RETRY_STEP_SECONDS1.0if invalid, fallback appliesStep increment used in the retry schedule.
    SESSION_INIT_RETRY_LINEAR_AFTER5if invalid, fallback appliesAfter this many retries, the retry backoff becomes more linear.
    SESSION_INIT_RETRY_MAX_SECONDS60.0if invalid, fallback appliesMaximum retry delay for session initialization.
    SESSION_INIT_BUSY_RETRY_INTERVAL_SECONDS60.0if invalid, fallback appliesRetry delay when the server explicitly responds with SESSION_BUSY.

    3.4.8) 📡 Ping / Keepalive

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    PING_AGGRESSIVE_INTERVAL_SECONDS0.100positive numberFastest ping interval used in the hottest activity state.
    PING_LAZY_INTERVAL_SECONDS0.750positive numberNormal operating ping interval.
    PING_COOLDOWN_INTERVAL_SECONDS2.0positive numberPing interval during cooldown.
    PING_COLD_INTERVAL_SECONDS15.0positive numberPing interval when the session is cold/mostly idle.
    PING_WARM_THRESHOLD_SECONDS8.0positive numberThreshold after which the session is treated as warm.
    PING_COOL_THRESHOLD_SECONDS20.0positive numberThreshold after which the session is treated as cooling down.
    PING_COLD_THRESHOLD_SECONDS30.0positive numberThreshold after which the session is treated as cold.

    3.4.9) 🔄 ARQ and Packet Packing

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    MAX_PACKETS_PER_BATCH8if invalid, fallback appliesMaximum number of control items the client tries to batch in one packet turn.
    ARQ_WINDOW_SIZE600valid positive rangeARQ send/receive window size per stream.
    ARQ_INITIAL_RTO_SECONDS1.0clamped in codeInitial retransmission timeout for data packets.
    ARQ_MAX_RTO_SECONDS5.0clamped in codeMaximum retransmission timeout for data packets.
    ARQ_CONTROL_INITIAL_RTO_SECONDS0.5clamped in codeInitial retransmission timeout for control packets.
    ARQ_CONTROL_MAX_RTO_SECONDS3.0clamped in codeMaximum retransmission timeout for control packets.
    ARQ_MAX_CONTROL_RETRIES400clamped in codeMaximum number of retries for control packets.
    ARQ_INACTIVITY_TIMEOUT_SECONDS1800.0clamped in codeStream inactivity timeout.
    ARQ_DATA_PACKET_TTL_SECONDS2400.0clamped in codeTTL for data packets before they are abandoned.
    ARQ_CONTROL_PACKET_TTL_SECONDS1200.0clamped in codeTTL for control packets.
    ARQ_MAX_DATA_RETRIES1200clamped in codeMaximum retries for data packets.
    ARQ_DATA_NACK_MAX_GAP16clamped in codeMaximum gap size for NACK generation when packets arrive out of order.
    ARQ_DATA_NACK_INITIAL_DELAY_SECONDS0.1clamped in codeInitial delay before sending a NACK for missing data packets. Controls how eagerly the system requests retransmissions.
    ARQ_DATA_NACK_REPEAT_SECONDS1.0clamped in codeMinimum interval before repeating a NACK for the same missing sequence.
    ARQ_TERMINAL_DRAIN_TIMEOUT_SECONDS120.0clamped in codeAfter a stream becomes terminal, how long the client waits for queue drain.
    ARQ_TERMINAL_ACK_WAIT_TIMEOUT_SECONDS90.0clamped in codeHow long the client waits for the final terminal ACK.

    3.4.10) 🪵 Logging

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    LOG_LEVEL"INFO"usually DEBUG, INFO, WARN, ERRORControls client log verbosity.INFO is usually enough for normal operation.Use DEBUG when investigating resolver health, failover, ARQ, or packet paths.

    Section 3.5: 📖 Server Configuration (server_config.toml)

    ℹ️ Note: the sample server config contains a key named CONFIG_VERSION, but the current Go code does not read it into ServerConfig. For that reason it is not included in the table below and has no effect on real server behavior.

    3.5.1) 🌐 Tunnel Policy and Protocol Acceptance

    ParameterSample Value in server_config.toml.simpleAllowed Values / Real BehaviorFull Explanation
    DOMAIN["v.domain.com"]list of stringsDomain or domains that this server treats as belonging to its tunnel.They must match the client DOMAINS, otherwise tunnel packets will not be recognized correctly.
    PROTOCOL_TYPE"SOCKS5"only "SOCKS5" or "TCP"Determines what kind of setup the server accepts for new streams.In SOCKS5 mode, the server expects PACKET_SOCKS5_SYN and takes the target from the client payload.In TCP mode, setup happens through PACKET_STREAM_SYN and the server connects to FORWARD_IP:FORWARD_PORT.
    MIN_VPN_LABEL_LENGTHnot shown in sampleif <=0, fallback to 3Minimum tunnel data label length.This helps avoid confusing ordinary DNS queries with tunnel queries.If this parameter is missing from your old README or config, it is worth adding because the code supports it.
    SUPPORTED_UPLOAD_COMPRESSION_TYPES[0, 1, 2, 3]valid compression IDs onlyCompression modes the server allows clients to request for upload traffic.
    SUPPORTED_DOWNLOAD_COMPRESSION_TYPES[0, 1, 2, 3]valid compression IDs onlySame idea for download traffic from server to client.

    3.5.2) 📥 UDP Listener and Front-Door Capacity

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    UDP_HOST""empty for the family-neutral wildcard, or an unbracketed IP literalAddress where the DNS server binds.The empty default lets Go choose a generic UDP wildcard. It accepts IPv4 and IPv6 through one socket where IPv4-mapped IPv6 is supported; otherwise Go selects an available family. Explicit 0.0.0.0 and :: wildcards retain their IPv4 or IPv6 family where mapped dual-stack sockets are unavailable. A concrete address restricts the listener to that family.
    UDP_PORT531..65535UDP port used by the server.In most deployments this should remain 53 so resolvers can query it directly.
    FALLBACKomittedempty/off, or HOST:PORT; bracket IPv6 addressesOptional raw UDP proxy for non-DNS datagrams received on the DNS listener. Routing is tracked per source, and only a structurally complete DNS datagram establishes or resets DNS classification. An unknown non-DNS source is forwarded immediately and remains sticky to fallback, while a DNS-classified source switches after 16 consecutive non-DNS packets. While the source remains DNS-classified, every packet retained on the DNS path refreshes its 180-second idle timer; DNS resets the non-DNS streak and non-DNS increments it. After a gap longer than 180 seconds, the next non-DNS packet is treated as a new source and forwarded immediately. Active fallback sessions also expire after 180 seconds without traffic in either direction. Fallback mode uses one ingress reader to preserve packet order and a full 65,535-byte receive buffer; startup rejects a target that resolves back to the listener. Sessions have no hard cap, so untrusted or spoofed traffic can consume file descriptors and CPU; use network filtering or rate limiting on public listeners.
    UDP_READERS4auto-default if <=0Number of goroutines reading directly from the UDP socket.A larger number may help on very busy servers, but beyond a point it only increases context switching.
    DNS_REQUEST_WORKERS8auto-default if <=0Number of workers that take requests from the front-door queue and pass them into the session/decode layer.
    MAX_CONCURRENT_REQUESTS16384fallback if <=0Capacity of the incoming request queue.If this queue fills up, packets are dropped and the server emits rate-limited overload logs.
    SOCKET_BUFFER_SIZE4194304fallback if <=0Operating-system socket buffer size request for the UDP listener.This matters for heavy bursts of incoming traffic.
    MAX_PACKET_SIZE65535fallback if <=0; at least 65535 with FALLBACKSize of the largest packet buffer that the packet pool allocates. Fallback forces a full-size UDP receive buffer so raw datagrams are not truncated.
    DROP_LOG_INTERVAL_SECONDS2.0fallback if <=0Minimum interval between repeated overload/drop logs, to avoid log spam during pressure.

    3.5.3) 🧠 Deferred Session Runtime

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    DEFERRED_SESSION_WORKERS4clamped up to 128Number of deferred-session workers.These workers handle ordering-sensitive and setup-heavy tasks such as stream setup, SOCKS connect, and some DNS assembly tasks.Too few can slow down stream setup; too many can create unnecessary contention.
    DEFERRED_SESSION_QUEUE_LIMIT4096clamped to 256..14336Queue capacity for deferred-session work.If it fills up, new setup or deferred tasks may be rejected.
    SESSION_ORPHAN_QUEUE_INITIAL_CAPACITYautoderived internallyInitial orphan/control queue sizing is derived automatically from server worker counts and batching pressure.
    STREAM_QUEUE_INITIAL_CAPACITYautoderived internallyPer-stream queue initial capacity is derived automatically from ARQ window size and packing pressure.
    DNS_FRAGMENT_STORE_CAPACITYautoderived internallyDNS tunnel fragment store capacity is derived automatically from request concurrency and worker count.
    SOCKS5_FRAGMENT_STORE_CAPACITYautoderived internallySOCKS5 setup fragment store capacity is derived automatically from deferred-session pressure and concurrency.

    3.5.4) 🍪 Session / Stream Lifecycle and Invalid Cookie Tracking

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    INVALID_COOKIE_WINDOW_SECONDS2.0fallback if <=0Time window used to count invalid-cookie errors.This helps the server detect broken sessions or clients repeatedly using a wrong cookie.
    INVALID_COOKIE_ERROR_THRESHOLD10fallback if <=0If invalid-cookie errors reach this threshold inside the window above, the server responds more aggressively.
    SESSION_TIMEOUT_SECONDS300.0fallback if <=0If a session has no activity for this long, the server times it out and cleans it up.
    SESSION_CLEANUP_INTERVAL_SECONDS30.0fallback if <=0How often the periodic session cleanup loop runs.
    CLOSED_SESSION_RETENTION_SECONDS600.0fallback if <=0How long closed-session metadata is kept so late packets can still be recognized.
    SESSION_INIT_REUSE_TTL_SECONDS600.0clamp to 1..86400 secondsHow long session-init signatures are kept for reuse and simple replay protection.
    RECENTLY_CLOSED_STREAM_TTL_SECONDS600.0clamp to 1..86400 secondsHow long recently closed streams remain in the “recently closed” table so late SYN packets do not revive them.
    RECENTLY_CLOSED_STREAM_CAP2000clamp to 1..1000000Maximum number of recently closed stream entries the server keeps.
    TERMINAL_STREAM_RETENTION_SECONDS45.0clamp to 1..86400 secondsHow long terminal streams remain before final sweeping.

    3.5.5) 📛 Egress DNS (DNS-over-Tunnel)

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    DNS_UPSTREAM_SERVERS["1.1.1.1:53", "1.0.0.1:53"]fallback if emptyWhen the client sends a real DNS request through the tunnel, the server forwards it to these recursive DNS resolvers.This section is only for DNS-over-tunnel, not for the tunnel transport itself.
    DNS_UPSTREAM_TIMEOUT4.0fallback if <=0Timeout for each exchange with the real DNS upstream.
    DNS_INFLIGHT_WAIT_TIMEOUT_SECONDS60.0clamp to 0.1..120 secondsIf several identical DNS queries arrive at the same time, only one upstream lookup is performed and the rest wait as followers.This value controls how long followers wait for the main lookup result.
    DNS_FRAGMENT_ASSEMBLY_TIMEOUT300.0fallback if <=0How long the server waits for all fragments of a tunneled DNS query to arrive.
    DNS_CACHE_MAX_RECORDS50000fallback if <1Maximum size of the server’s internal DNS cache for tunneled DNS queries.
    DNS_CACHE_TTL_SECONDS300.0fallback if <=0TTL of the server-side internal DNS cache.

    3.5.6) 🌐 Destination Forwarding and External SOCKS

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    SOCKS_CONNECT_TIMEOUT120.0fallback if <=0Timeout for the server’s outbound connection to the final destination or to an external SOCKS5 server.The sample shows a higher value, but the real code fallback is 8 seconds.
    USE_EXTERNAL_SOCKS5falsetrue/falseIf true, the server sends outbound traffic through an external SOCKS5 server instead of connecting directly.This is mainly useful for chaining or hiding server egress.
    SOCKS5_AUTHfalsetrue/falseWhether the external SOCKS5 server requires username/password authentication.
    SOCKS5_USER"admin"up to 255 bytesUsername for the external SOCKS5 server.
    SOCKS5_PASS"123456"up to 255 bytesPassword for the external SOCKS5 server.If auth is enabled and username/password are invalid, the config becomes invalid.
    FORWARD_IP""stringIn TCP mode, this is the fixed outbound destination.In SOCKS5 mode with USE_EXTERNAL_SOCKS5=true, this is the address of the external SOCKS5 proxy itself.
    FORWARD_PORT00..65535Port of the endpoint above.If USE_EXTERNAL_SOCKS5=true, this must be a valid non-zero value.

    3.5.7) 🔐 Security

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    DATA_ENCRYPTION_METHOD10..5Must match the client.If an invalid value is supplied, the current code normalizes it back to 1.
    ENCRYPTION_KEY_FILE"encrypt_key.txt"relative or absolute pathPath to the server encryption key file.If it is relative, it is resolved relative to the config directory.If it is empty, the fallback is encrypt_key.txt.

    3.5.8) 🔄 ARQ, Packing, and Control TTLs

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    MAX_PACKETS_PER_BATCH5fallback if <1Maximum number of control blocks the server tries to pack into one response.Important note: if the value is invalid, the real code fallback is 20.
    PACKET_BLOCK_CONTROL_DUPLICATION1clamp to 1..16How many extra turns the last packed control block should be repeated.1 effectively means duplication is off.This is useful on lossy links so critical ACK/close data arrives more reliably.
    STREAM_SETUP_ACK_TTL_SECONDS400.0clamp to 1..86400 secondsTTL of ACK packets related to stream setup.
    STREAM_RESULT_PACKET_TTL_SECONDS300.0clamp to 1..86400 secondsTTL of result packets such as connect success/failure that must reach the client.
    STREAM_FAILURE_PACKET_TTL_SECONDS120.0clamp to 1..86400 secondsTTL of failure packets for setup or outbound errors.
    ARQ_WINDOW_SIZE800clamp to 1..16384ARQ window size per stream on the server.
    ARQ_INITIAL_RTO_SECONDS1clamp to 0.05..60 secondsInitial retransmission timeout for data packets.
    ARQ_MAX_RTO_SECONDS5.0clamp to [ARQ_INITIAL_RTO_SECONDS, 120]Maximum retransmission timeout for data packets.
    ARQ_CONTROL_INITIAL_RTO_SECONDS0.5clamp to 0.05..60 secondsInitial retransmission timeout for control packets.
    ARQ_CONTROL_MAX_RTO_SECONDS3.0clamp to [ARQ_CONTROL_INITIAL_RTO_SECONDS, 120]Maximum retransmission timeout for control packets.
    ARQ_MAX_CONTROL_RETRIES300clamp to 5..5000Maximum retries for control packets.
    ARQ_INACTIVITY_TIMEOUT_SECONDS1800.0clamp to 30..86400 secondsInactivity timeout for streams.
    ARQ_DATA_PACKET_TTL_SECONDS2400.0clamp to 30..86400 secondsTTL for data packets.
    ARQ_CONTROL_PACKET_TTL_SECONDS1200.0clamp to 30..86400 secondsTTL for control packets.
    ARQ_MAX_DATA_RETRIES1200clamp to 60..100000Maximum retries for data packets.
    ARQ_DATA_NACK_MAX_GAP16clamp to 0..255If out-of-order packets arrive, this controls how large a missing gap may be reported with NACK.
    ARQ_DATA_NACK_INITIAL_DELAY_SECONDS0.3clamped in codeInitial delay before sending a NACK for missing data packets. Controls how eagerly the system requests retransmissions.
    ARQ_DATA_NACK_REPEAT_SECONDS1.0clamp to 0.1..30 secondsFor a missing sequence, this defines how soon a repeated NACK may be issued again.
    ARQ_TERMINAL_DRAIN_TIMEOUT_SECONDS120.0clamp to 10..3600 secondsAfter a stream becomes terminal, how long the server waits for queues to drain.
    ARQ_TERMINAL_ACK_WAIT_TIMEOUT_SECONDS90.0clamp to 5..3600 secondsAfter terminal close, how long the server waits for the final ACK.

    3.5.9) 🪵 Logging

    ParameterSample ValueAllowed Values / Real BehaviorFull Explanation
    LOG_LEVEL"INFO"usually DEBUG, INFO, WARN, ERRORServer log level.For normal production usage, INFO is usually enough.For deep investigation of sessions, deferred workers, or ARQ behavior, temporarily use DEBUG.

    3.5.10) Session Policy Sync

    During SESSION_INIT, the server may append a compact policy block to SESSION_ACCEPT. The client applies these limits immediately before normal run