How xvzc/spoofdpi works
SpoofDPI is a Go proxy for countering DPI-based censorship. Its main workflow is to load CLI/configuration, start a selected proxy mode, accept client traffic, and forward it while applying TLS or UDP desynchronization where configured. HTTP, SOCKS5, and TUN modes have distinct handlers; DNS resolution, rules, packet-based hop learning, and connection utilities support those paths. The source index documents imports and module references, but several server constructors and runtime modules were not excerpted, so those links are limited to relationships visible in the index or README.
Main entry points: main.go Application startup · conn.go Connection utilities · tls.go TLS desynchronizer · socks5.go SOCKS5 proxy
Components 23
Startup and configuration
- Application startup
cmd/spoofdpi/main.go - Terminal UI
cmd/spoofdpi/tui.go - Config and CLI
internal/config/cli.go
Proxy modes
- HTTP proxy
internal/server/http/http.go - HTTP request handler
internal/server/http/handler_http.go - HTTPS handler
internal/server/http/handler_https.go - SOCKS5 proxy
internal/server/socks5/socks5.go - SOCKS5 connect
internal/server/socks5/handler_connect.go - SOCKS5 bind
internal/server/socks5/handler_bind.go - SOCKS5 UDP associate
internal/server/socks5/handler_udp_assoc.go - TUN server
internal/server/tun/tun.go - TUN TCP handler
internal/server/tun/handler_tcp.go - TUN UDP handler
internal/server/tun/handler_udp.go
DPI circumvention
- TLS desynchronizer
internal/desync/tls.go - UDP desynchronizer
internal/desync/udp.go - Packet capture and writers
internal/packet
Network support
- Rule matching
internal/rule/set.go - DNS resolution
internal/dns/client.go - Caches
internal/cache/cache.go - Connection utilities
internal/netutil/conn.go - Protocol parsing
internal/proto/tls.go - Session context
internal/session/session.go
Other components
- CLI user
Connections 35
- CLI user → Application startup: starts
cmd/spoofdpi/main.go - Application startup → Config and CLI: creates command
cmd/spoofdpi/main.go - Application startup → Session context: creates trace context
cmd/spoofdpi/main.go - Application startup → HTTP proxy: starts selected mode
cmd/spoofdpi/main.go - Application startup → SOCKS5 proxy: starts selected mode
cmd/spoofdpi/main.go - Application startup → TUN server: starts selected mode
cmd/spoofdpi/main.go - Application startup → DNS resolution: initializes resolver
cmd/spoofdpi/main.go - Application startup → Rule matching: builds rule set
cmd/spoofdpi/main.go - Application startup → Packet capture and writers: starts capture
cmd/spoofdpi/main.go - Application startup → TLS desynchronizer: constructs desyncer
cmd/spoofdpi/main.go - Application startup → UDP desynchronizer: constructs desyncer
cmd/spoofdpi/main.go - HTTP proxy → HTTP request handler: dispatches requests
- HTTP proxy → HTTPS handler: dispatches tunnels
- HTTPS handler → TLS desynchronizer: desynchronizes hello
internal/server/http/handler_https.go - HTTPS handler → Connection utilities: dials and tunnels
internal/server/http/handler_https.go - HTTP request handler → Connection utilities: dials and tunnels
internal/server/http/handler_http.go - SOCKS5 proxy → SOCKS5 connect: dispatches requests
- SOCKS5 proxy → SOCKS5 bind: dispatches requests
- SOCKS5 proxy → SOCKS5 UDP associate: dispatches requests
- SOCKS5 UDP associate → UDP desynchronizer: tracks UDP hops
internal/server/socks5/handler_udp_assoc.go - SOCKS5 UDP associate → Connection utilities: dials and pools
internal/server/socks5/handler_udp_assoc.go - SOCKS5 connect → TLS desynchronizer: desynchronizes TLS
internal/server/socks5/handler_connect.go - SOCKS5 bind → Connection utilities: tunnels connections
internal/server/socks5/handler_bind.go - TUN server → TUN TCP handler: dispatches TCP
- TUN server → TUN UDP handler: dispatches UDP
- TUN TCP handler → Rule matching: matches destinations
internal/server/tun/handler_tcp.go - TUN TCP handler → TLS desynchronizer: desynchronizes hello
internal/server/tun/handler_tcp.go - TUN TCP handler → Connection utilities: dials and tunnels
internal/server/tun/handler_tcp.go - TUN UDP handler → Rule matching: matches destinations
internal/server/tun/handler_udp.go - TUN UDP handler → UDP desynchronizer: desynchronizes traffic
internal/server/tun/handler_udp.go - TUN UDP handler → Connection utilities: dials and tunnels
internal/server/tun/handler_udp.go - TLS desynchronizer → Packet capture and writers: sends crafted packets
internal/desync/tls.go - TLS desynchronizer → Protocol parsing: splits TLS messages
internal/desync/tls.go - DNS resolution → Caches: caches answers
internal/dns/client.go - Terminal UI → Connection utilities: uses network helpers
cmd/spoofdpi/tui.go