ProxyTuner development is organized into 6 phases. Each phase builds on the previous one and delivers a working (though incomplete) version.
Goal: Working CLI with config management, no traffic interception yet.
- Initialize Python project (
pyproject.toml,src/proxy_tuner/layout) - Add dependencies:
click,rich(for CLI output),pydantic(config validation) - Implement
proxy_tuner/config.py— config file load/save/validate - Implement
proxy_tuner/cli.py— CLI entry point with all subcommands - Implement outbound management (add/remove/list/test — config-only, no proxy logic)
- Implement rule management (add/remove/list/move/test — config-only, no matching logic)
- Write tests for config and CLI
- Create example config file
proxy-tuner outbound add my-proxy --type socks5 --host 127.0.0.1 --port 1080
proxy-tuner outbound list
proxy-tuner rule add firefox-vpn --process firefox --outbound my-proxy
proxy-tuner rule list
proxy-tuner config showclick>=8.0
rich>=13.0
pydantic>=2.0
Goal: Complete rule matching logic with all match types.
- Implement
proxy_tuner/rules.py— rule evaluation engine - Implement process matching (cross-platform process name/PATH resolution)
- Implement domain matching (wildcard patterns, regex)
- Implement IP matching (exact, CIDR, regex)
- Implement port matching (exact, ranges)
- Implement URL regex matching
- Implement AND/OR combination logic
- Write unit tests for all match types
- Rule engine that can evaluate a
ConnectionInfoagainst a list of rules - Full test coverage for matching logic
Goal: Actual SOCKS5/HTTP proxy connections, usable as a local proxy.
- Implement
proxy_tuner/outbounds.py— outbound connection manager - Implement SOCKS5 client (
asyncio-based, RFC 1928) - Implement HTTP CONNECT client
- Implement
proxy_tuner/forwarder.py— local proxy server (listens onlisten_port) - Integrate rule engine with forwarder (match → select outbound → forward)
- Implement DNS resolution for domain matching
- Add connection statistics tracking
- Write tests for SOCKS5/HTTP clients
- Users can point browser/system at
127.0.0.1:10808as HTTP/SOCKS proxy - Traffic is forwarded based on rules
- Still manual proxy configuration (no auto-redirect)
Goal: Transparent proxying on Linux (no manual proxy config needed).
- Implement
proxy_tuner/tun.py— TUN interface manager - Implement
proxy_tuner/platform/base.py— abstract platform interface - Implement
proxy_tuner/platform/linux.py:- TUN interface creation/destruction
- nftables rules for traffic interception
- Per-process matching via
--uid-owner/ cgroups SO_ORIGINAL_DST//proc/net/tcpfor real destination
- Implement
proxy_tuner/startandproxy_tuner stopcommands - Implement DNS interception (optional)
- Handle iptables/nftables cleanup on stop
- Write integration tests (requires root)
sudo proxy-tuner start # transparently intercepts traffic
# All apps automatically route based on rules
sudo proxy-tuner stop # cleans up all firewall rulespyroute2>=0.7 # TUN management
netfilter>=0.6 # nftables bindings (or subprocess calls)
Goal: Transparent proxying on Windows.
- Implement
proxy_tuner/platform/windows.py:- WinDivert packet capture (via
pydivertor ctypes) - Process ID extraction from packets
- TUN interface via
wintunadapter
- WinDivert packet capture (via
- Handle WinDivert driver installation/management
- Implement connection-to-process mapping (
iphlpapi) - Implement cleanup on stop
- Write tests (mocked, as Windows-specific)
- Transparent proxying on Windows with per-process routing
- Admin elevation handling
pydivert>=2.1 # WinDivert Python bindings
or
wintun>=0.1 # TUN adapter (ctypes bindings)
Goal: Stable, well-documented, production-ready tool.
- Add
proxy-tuner statuswith live stats - Add signal handling (SIGTERM, SIGINT) for clean shutdown
- Add
--daemonmode (background with PID file) - Add config hot-reload (
proxy-tuner reload) - Add output/logging framework (
loguruorlogging) - Add
proxy-tuner config validatecommand - Add
proxy-tuner versioncommand - Write comprehensive README
- Add CI/CD (GitHub Actions)
- Publish to PyPI
- Write man pages
- Add shell completions (bash, zsh, fish)
- Fully functional CLI tool
- Published on PyPI
- Comprehensive documentation
Phase 1 (Scaffold)
│
├──→ Phase 2 (Rules) ──┐
│ │
└──→ Phase 3 (Forward) ─┤
│
┌────────┤
▼ ▼
Phase 4 (Linux) Phase 5 (Windows)
│ │
└────────┘
│
▼
Phase 6 (Polish)
Phases 4 and 5 can be developed in parallel by different contributors.
| Component | Choice | Rationale |
|---|---|---|
| CLI framework | Click | Mature, decorator-based, widely used |
| Config validation | Pydantic v2 | Type-safe, fast, great error messages |
| TUI output | Rich | Beautiful terminal output, tables, progress |
| Async runtime | asyncio | Native Python async, no extra deps |
| SOCKS5 client | Custom (asyncio) | Full control, no heavy dependencies |
| HTTP client | aiohttp or custom | For HTTP CONNECT proxy |
| TUN (Linux) | pyroute2 | Well-maintained, feature-complete |
| Firewall (Linux) | nftables via subprocess | Avoids Python binding complexity |
| Packet capture (Windows) | pydivert / ctypes | WinDivert is the standard for this |
| Testing | pytest + pytest-asyncio | Standard Python testing |
| Phase | Effort | Prerequisite |
|---|---|---|
| Phase 1 | 1-2 days | None |
| Phase 2 | 2-3 days | Phase 1 |
| Phase 3 | 3-5 days | Phase 1, 2 |
| Phase 4 | 5-7 days | Phase 2, 3 |
| Phase 5 | 5-7 days | Phase 2, 3 |
| Phase 6 | 3-5 days | Phase 4, 5 |
Total: ~20-30 days of focused development.