Overview
Therun command starts the TurkeyDPI daemon with the full DPI bypass engine, control server, and optional proxy backend. This is the primary mode for production deployments.
Unlike the simple bypass command, run provides:
- Full configuration file support
- Unix socket control interface for management
- Advanced rule-based packet transformation
- Multiple backend support (proxy, transparent, TUN)
- Runtime configuration reload
- Detailed statistics and monitoring
Usage
Options
Enable the SOCKS5 proxy backend.When enabled:
- Starts a SOCKS5 proxy server on the specified listen address
- Processes all traffic through the DPI bypass engine
- Supports rule-based transformations from config file
Proxy backend listen address (SOCKS5 server).Only used when
--proxy is enabled.Examples:127.0.0.1:1080- localhost only (recommended)0.0.0.0:1080- all interfaces (use with caution)[::1]:1080- IPv6 localhost
Path to configuration file.If not specified, uses default configuration with:
- Fragmentation enabled
- Padding enabled
- HTTPS (port 443) and DNS (port 53) rules
- Standard transform parameters
Logging verbosity level.Levels:
trace- Very detailed, includes all debug infodebug- Detailed operational informationinfo- General informational messages (default)warn- Warning messages onlyerror- Error messages only
Output structured JSON logs.Each log line is a JSON object with fields:
timestamp- ISO 8601 timestamplevel- Log leveltarget- Source modulemessage- Log message- Additional contextual fields
Unix domain socket path for control server.Used by management commands (
start, stop, status, etc.) to communicate with the daemon.Requirements:- Parent directory must exist and be writable
- Path should be absolute
- Will be removed on clean shutdown
Examples
Start with default configuration (control-only mode)
Start SOCKS5 proxy on default port
Start with custom configuration and port
Start with debug logging and JSON output
Start with custom socket path
SOCKS5 Proxy Details
When--proxy is enabled, TurkeyDPI runs a full SOCKS5 proxy server:
Supported Features
- SOCKS5 protocol (version 0x05)
- Authentication: No auth (0x00) only
- Commands: CONNECT only
- Address types: IPv4, IPv6, domain names
- DNS resolution: Automatic for domain names
Connection Flow
- Client connects to proxy
- SOCKS5 handshake (no authentication)
- Client sends CONNECT request
- Proxy resolves destination (if domain)
- Proxy connects to destination
- Traffic flows through DPI bypass engine
- Engine applies configured transformations
- Transformed packets sent to destination
Pipeline Processing
All traffic through the proxy is processed by the pipeline:Configuration File
When--config is specified, the daemon loads a TOML or JSON configuration file with:
- Global settings: Feature toggles, log level
- Rules: Match criteria and transform chains
- Transform parameters: Fragmentation, padding, jitter settings
- Limits: Flow table, memory, queue sizes
Control Server
The control server always runs when usingrun command. It provides a Unix socket interface for:
- Starting/stopping the engine
- Checking health and status
- Retrieving statistics
- Reloading configuration
- Validating config files
Process Management
Graceful Shutdown
PressCtrl+C or send SIGINT/SIGTERM:
- Signal received
- Stop accepting new connections
- Wait for active connections (max 5s)
- Stop proxy backend
- Stop control server
- Clean up socket file
Running as System Service
Create systemd service (/etc/systemd/system/turkeydpi.service):
Client Configuration
SOCKS5 Setup
Configure applications to use SOCKS5 proxy at127.0.0.1:1080:
- Firefox
- cURL
- Environment
- Settings → Network Settings → Settings
- Select “Manual proxy configuration”
- SOCKS Host:
127.0.0.1, Port:1080 - Select “SOCKS v5”
- Check “Proxy DNS when using SOCKS v5”
Performance Tuning
Configuration Options
Adjust in config file:System Limits
Increase file descriptor limits for high connection counts:/etc/security/limits.conf:
Troubleshooting
Socket already in use
Socket already in use
Remove stale socket file:
Proxy not accepting connections
Proxy not accepting connections
Check if —proxy flag is set and firewall allows connections:
Configuration file not found
Configuration file not found
Verify file path and permissions:
High CPU usage
High CPU usage
Reduce fragmentation intensity in config or disable unnecessary transforms.
See Also
- bypass command - Quick HTTP proxy mode
- Daemon Control Commands - Managing the running daemon
- Configuration Management - Validate and generate configs
- Configuration Guide - Detailed configuration reference