SpoofDPI Documentation

repository·main·Indexed 26 days ago

https://github.com/xvzc/spoofdpi

A proxy tool designed to bypass internet censorship by neutralizing Deep Packet Inspection (DPI) techniques. It supports HTTP, SOCKS5, and TUN modes, featuring TLS desync capabilities and a TUI for log management. Documentation covers installation via scripts and package managers, manual builds using Go 1.26+, and developer guides for testing and code quality.

Tokens
9.5K
Snippets
43
Records
82
Agent score
88%

What's inside spoofdpi

  1. Overview of SpoofDPI

    main

    SpoofDPI is a simple proxy tool designed to neutralize Deep Packet Inspection (DPI) techniques used by internet censorship systems.

    Security Warning: SpoofDPI is NOT available on iOS or Android. Official binaries are ONLY provided through GitHub and official package managers. Avoid downloading from unofficial sources to prevent malware.

  2. Key features of spoofdpi

    main

    spoofdpi provides the following capabilities:

    • High Performance: Low latency via the Go runtime and caching mechanisms.
    • Built-in DNS Resolver: Includes built-in DNS resolvers, allowing use without modifying system-wide DNS settings.
    • Flexible Policies: Supports robust policy rules based on domains (e.g., allow or ignore specific domains).
    • Easy Configuration: Configurable via a TOML file.
    • Cross-Platform Support: Compatible with macOS, Linux, and FreeBSD.
  3. Implement table-driven tests

    main

    For testing multiple scenarios of the same logic, use table-driven tests. This pattern involves defining a slice of structs containing inputs and expected outputs, then iterating over them using t.Run to execute subtests.

    func TestCalculation(t *testing.T) {
        tcs := []struct {
            name     string
            input    int
            expected int
        }{
            {
                name:     "positive number",
                input:    5,
                expected: 10,
            },
            {
                name:     "zero",
                input:    0,
                expected: 0,
            },
        }
    
        for _, tc := range tcs {
            t.Run(tc.name, func(t *testing.T) {
                result := calculate(tc.input)
                assert.Equal(t, tc.expected, result)
            })
        }
    }
  4. Configure Aggressive HTTPS Bypass

    main

    If default settings fail to bypass DPI, use aggressive settings to disorder the Client Hello and inject multiple fake packets. You can specify fake-count, a fake-packet byte array, enable disorder, and set split-mode to "chunk" with a specific chunk-size.

    [https]
    fake-count = 5
    fake-packet = [0x16, 0x03, 0x01] # Simple fake Client Hello prefix
    disorder = true
    split-mode = "chunk"
    chunk-size = 1
  5. Build spoofdpi from GitHub Release source

    main

    For platforms where native GitHub Actions runners are unavailable (like FreeBSD), you can build directly from the release source archives. These archives include a COMMIT file which should be used to embed the commit hash during the build process.

    #!/usr/bin/env bash
    
    VERSION="#REPLACE_THIS_WITH_VERSION#"
    BUILD_INFO="freebsd"
    ASSET="spoofdpi-$VERSION.tar.gz"
    SRC="spoofdpi-$VERSION"
    DIST="dist"
    
    curl -fsSL \
      https://github.com/xvzc/spoofdpi/releases/download/v$VERSION/$ASSET \
      -o ./$ASSET
    
    tar -xvzf ./spoofdpi-$VERSION.tar.gz
    
    BUILD_LDFLAGS="-s -w"
    BUILD_LDFLAGS="$BUILD_LDFLAGS -X 'main.version=$VERSION'"
    BUILD_LDFLAGS="$BUILD_LDFLAGS -X 'main.commit=$(cat ./$SRC/COMMIT)'"
    BUILD_LDFLAGS="$BUILD_LDFLAGS -X 'main.build=$BUILD_INFO'"
    
    # You can disable CGO on Linux by setting CGO_ENABLED=0
    CGO_ENABLED=1 go build -C ./$SRC \
      -ldflags "$BUILD_LDFLAGS" \
      -o ../$DIST/spoofdpi ./cmd/spoofdpi
  6. Use testify for assertions in spoofdpi tests

    main

    The project uses the standard testing package along with github.com/stretchr/testify for assertions.

    • Use testify/assert for general assertions where a failure should record an error but allow the test to continue.
    • Use testify/require for critical checks (like error handling or setup) where the test must stop immediately if the condition is not met.
    import (
        "testing"
        "github.com/stretchr/testify/assert"
        "github.com/stretchr/testify/require"
    )
    
    func TestExample(t *testing.T) {
        result, err := SomeFunction()
        
        // Stop immediately if there's an error
        require.NoError(t, err)
        
        // Assert the result, but continue even if it fails
        assert.Equal(t, "expected", result)
    }
  7. Apply specific HTTPS bypass settings to a domain

    main

    To unblock a specific site, use a rule that matches its domain and applies custom https configuration settings, such as fake-count and disorder.

    [[rules]]
    name = "unblock site"
    match = { domains = ["blocked-site.com"] }
    https = { fake-count = 2, disorder = true }
  8. Locate the spoofdpi configuration file

    main

    If you do not specify a path using the --config flag, spoofdpi searches for spoofdpi.toml in the following locations in order. It will apply only the first file it finds:

    1. The path specified in the $SPOOFDPI_CONFIG environment variable.
    2. /etc/spoofdpi.toml
    3. $XDG_CONFIG_HOME/spoofdpi/spoofdpi.toml
    4. $HOME/.config/spoofdpi/spoofdpi.toml