# Proxy-RS **Repository Path**: su_xii/proxy-rs ## Basic Information - **Project Name**: Proxy-RS - **Description**: 一个用 Rust 编写的高性能代理服务器,支持 SOCKS5 和 HTTP 代理协议。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-12-01 - **Last Updated**: 2025-12-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Proxy-RS 一个用 Rust 编写的高性能代理服务器,支持 SOCKS5 和 HTTP 代理协议。 ## 功能特性 - ✅ **SOCKS5 代理** - 完整的 SOCKS5 协议支持 - ✅ **HTTP 代理** - 支持 HTTP/HTTPS 代理,包括 CONNECT 方法 - ✅ **高性能** - 基于 Tokio 异步运行时 - ✅ **配置灵活** - 支持 TOML 配置文件 - ✅ **实时统计** - 连接数和流量统计 - ✅ **易于部署** - 直接编译部署,无需容器 ## 快速开始 ### 构建项目 1. **克隆项目** ```bash git clone https://gitee.com/su_xii/proxy-rs cd proxy-rs ``` 2. **构建项目** ```bash cargo build --release ``` 3. **配置文件** 编辑 `config.toml` 文件: ```toml # SOCKS5 代理监听地址和端口 socks5_addr = "0.0.0.0:6000" # HTTP 代理监听地址和端口 http_addr = "0.0.0.0:6001" # 启用的协议 enable_socks5 = true enable_http = true # 最大连接数 max_connections = 1000 # 连接超时时间(秒) timeout = 30 # 缓冲区大小(字节) buffer_size = 8192 ``` 4. **运行代理服务器** ```bash ./target/release/proxy-server ``` ### 使用自定义配置文件 ```bash ./target/release/proxy-server --config /path/to/your/config.toml ``` ## 配置说明 | 配置项 | 说明 | 默认值 | |--------|------|--------| | `socks5_addr` | SOCKS5 代理监听地址 | `"0.0.0.0:6000"` | | `http_addr` | HTTP 代理监听地址 | `"0.0.0.0:6001"` | | `enable_socks5` | 是否启用 SOCKS5 代理 | `true` | | `enable_http` | 是否启用 HTTP 代理 | `true` | | `max_connections` | 最大连接数 | `1000` | | `timeout` | 连接超时时间(秒) | `30` | | `buffer_size` | 缓冲区大小(字节) | `8192` | ## 客户端配置 ### SOCKS5 代理 - **代理地址**: `your-server-ip:6000` - **代理类型**: SOCKS5 - **认证**: 无(或根据配置) ### HTTP 代理 - **代理地址**: `your-server-ip:6001` - **代理类型**: HTTP - **认证**: 无(或根据配置) ## 性能优化 1. **调整缓冲区大小** ```toml buffer_size = 16384 # 增加到 16KB ``` 2. **增加最大连接数** ```toml max_connections = 5000 ``` 3. **调整系统参数** ```bash # 增加文件描述符限制 ulimit -n 65536 ``` ## 监控和日志 代理服务器会每 30 秒输出一次统计信息: ``` 统计报告 - 连接数: 1234, 传输量: 1.23 GB, 运行时间: 02:30:45 ``` 使用以下命令查看实时日志: ```bash ./target/release/proxy-server ``` ## 安全建议 1. **使用防火墙限制访问** ```bash # 只允许特定 IP 访问代理 iptables -A INPUT -s 允许的IP -p tcp --dport 6000 -j ACCEPT iptables -A INPUT -s 允许的IP -p tcp --dport 6001 -j ACCEPT iptables -A INPUT -p tcp --dport 6000 -j DROP iptables -A INPUT -p tcp --dport 6001 -j DROP ``` 2. **启用认证** ```toml [auth] username = "your_username" password = "your_password" ``` 3. **使用 TLS 加密** 考虑使用 stunnel 或类似工具为代理连接添加 TLS 加密。 ## 故障排除 ### 常见问题 1. **连接被拒绝** - 检查防火墙设置 - 确认端口未被其他进程占用 2. **性能问题** - 调整缓冲区大小 - 检查系统资源使用情况 3. **认证失败** - 检查配置文件中的认证设置 - 确认客户端配置正确 ### 调试模式 启用调试日志: ```bash RUST_LOG=debug ./target/release/proxy-server ``` ## 贡献 欢迎提交 Issue 和 Pull Request! ## 许可证 MIT License