|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Rabbit Digger Pro is an all-in-one proxy server written in Rust with hot-reloading capabilities. It supports multiple proxy protocols (Shadowsocks, Trojan, HTTP, Socks5, obfs) and provides both CLI and web API interfaces. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +The codebase follows a modular workspace structure: |
| 12 | + |
| 13 | +- **Core**: `rabbit-digger/` - Main proxy engine with hot-reload and configuration management |
| 14 | +- **Interface**: `rd-interface/` - Plugin interface definitions and core types |
| 15 | +- **Standard Library**: `rd-std/` - Built-in networking utilities, servers, and rules |
| 16 | +- **Protocols**: Individual protocol implementations in `protocol/`: |
| 17 | + - `ss/` - Shadowsocks client/server |
| 18 | + - `trojan/` - Trojan protocol implementation |
| 19 | + - `rpc/` - Internal RPC protocol |
| 20 | + - `raw/` - Raw packet forwarding |
| 21 | + - `obfs/` - Obfuscation protocols |
| 22 | +- **Frontend**: `ui/` - React-based web interface |
| 23 | +- **Documentation**: `docs/` - Docusaurus-based documentation |
| 24 | + |
| 25 | +## Key Components |
| 26 | + |
| 27 | +- **RabbitDigger**: Core proxy engine in `rabbit-digger/src/rabbit_digger/` |
| 28 | +- **Registry**: Plugin system for dynamic protocol loading |
| 29 | +- **Configuration**: YAML-based config with JSON Schema validation |
| 30 | +- **API Server**: RESTful API with WebSocket support for real-time updates |
| 31 | +- **Hot Reloading**: Config changes applied without restart |
| 32 | + |
| 33 | +## Common Commands |
| 34 | + |
| 35 | +### Rust Development |
| 36 | +```bash |
| 37 | +# Build the project |
| 38 | +cargo build --release |
| 39 | + |
| 40 | +# Run tests |
| 41 | +cargo test |
| 42 | + |
| 43 | +# Run with default config |
| 44 | +cargo run --bin rabbit-digger-pro |
| 45 | + |
| 46 | +# Run with custom config |
| 47 | +cargo run --bin rabbit-digger-pro -- -c config.yaml |
| 48 | + |
| 49 | +# Generate JSON schema |
| 50 | +cargo run --bin rabbit-digger-pro -- generate-schema schema.json |
| 51 | + |
| 52 | +# Run API server only |
| 53 | +cargo run --bin rabbit-digger-pro -- server |
| 54 | + |
| 55 | +# Development with console |
| 56 | +cargo run --bin rabbit-digger-pro --features console |
| 57 | +``` |
| 58 | + |
| 59 | +### Frontend Development |
| 60 | +```bash |
| 61 | +# UI development |
| 62 | +cd ui/ |
| 63 | +pnpm install |
| 64 | +pnpm dev |
| 65 | + |
| 66 | +# Build UI |
| 67 | +cd ui/ |
| 68 | +pnpm build |
| 69 | + |
| 70 | +# Documentation development |
| 71 | +cd docs/ |
| 72 | +pnpm install |
| 73 | +pnpm start |
| 74 | +``` |
| 75 | + |
| 76 | +### Testing & Quality |
| 77 | +```bash |
| 78 | +# Run all tests |
| 79 | +cargo test --workspace |
| 80 | + |
| 81 | +# Check formatting |
| 82 | +cargo fmt --check |
| 83 | + |
| 84 | +# Run clippy |
| 85 | +cargo clippy --workspace |
| 86 | + |
| 87 | +# Generate coverage |
| 88 | +./gen_coverage.sh |
| 89 | +``` |
| 90 | + |
| 91 | +## Configuration |
| 92 | + |
| 93 | +- Main config: `config.yaml` (default) or specified with `-c` |
| 94 | +- Environment variables: |
| 95 | + - `RD_CONFIG`: Config file path |
| 96 | + - `RD_BIND`: API server bind address |
| 97 | + - `RD_ACCESS_TOKEN`: API access token |
| 98 | + - `RD_WEB_UI`: Web UI folder path |
| 99 | + - `RUST_LOG`: Logging level |
| 100 | + |
| 101 | +## Development Features |
| 102 | + |
| 103 | +- **Hot reload**: Config changes automatically applied |
| 104 | +- **JSON Schema**: Auto-generated schema for config validation |
| 105 | +- **Plugin system**: Extensible via registry system |
| 106 | +- **Web UI**: React frontend with real-time updates via WebSocket |
| 107 | +- **Telemetry**: Optional OpenTelemetry/Jaeger integration |
| 108 | +- **Console**: Optional console-subscriber for debugging |
0 commit comments