# nettools **Repository Path**: guyi/nettools ## Basic Information - **Project Name**: nettools - **Description**: No description available - **Primary Language**: Go - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-06 - **Last Updated**: 2025-07-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # NetTools - 多端口网络代理工具 NetTools 是一个高性能的端口转发和网络代理系统,支持多端口多服务的架构,使用纯TCP socket通信。 ## 🚀 特性 ### 核心功能 - **多端口多服务**:服务器可配置多个监听端口,每个端口对应一个独立的服务 - **双程序架构**:服务端 + 客户端(模式可配置) - **独立连接管理**:每个服务都有独立的socket连接 - **透明代理**:支持任意TCP协议的透明转发 ### 客户端模式 - **内网模式**:连接服务端,将socket流量转发到内部端口 - **外部模式**:监听本地端口,将流量转发到服务端socket连接 ### 安全特性 - **灵活认证**:支持令牌、密钥、证书三种认证方式 - **服务级配置**:每个服务可独立配置认证和安全策略 - **可选加密**:支持TLS和PSK AES-256-GCM加密 ### 标准协议支持 - SSH、RDP、MySQL等标准协议的透明代理 - 外部客户端程序提供透明代理,用户可使用标准客户端连接 ## 📋 系统要求 - Go 1.19+ (编译时需要) - 支持的操作系统: - Windows (amd64) - Linux (amd64) - macOS (amd64/arm64) ## 🔧 编译安装 ### 快速编译 #### Linux/macOS: ```bash # 编译所有程序 make build # 或分别编译 make server # 编译服务端 make client # 编译客户端 # 查看所有可用命令 make help ``` #### Windows: ```cmd # 编译所有程序 build.bat build # 或分别编译 build.bat server # 编译服务端 build.bat client # 编译客户端 # 查看所有可用命令 build.bat help ``` ### 跨平台编译 #### Linux/macOS: ```bash make build-all # 构建所有平台版本 make release # 创建发布包 ``` #### Windows: ```cmd build.bat build-all # 构建所有平台版本 ``` ### 手动编译 ```bash # 编译服务端 cd server && go build -o ../build/nettools-server . # 编译客户端 cd client && go build -o ../build/nettools-client . ``` ## 📖 使用说明 ### 1. 配置文件 项目使用JSON格式的配置文件,示例配置位于 `configs/` 目录: - `server-config.json` - 服务端配置 - `client-internal.json` - 内网客户端配置 - `client-external.json` - 外部客户端配置 ### 2. 启动服务端 ```bash # 使用默认配置 ./build/nettools-server # 指定配置文件 ./build/nettools-server -config configs/server-config.json # 查看版本信息 ./build/nettools-server -version ``` ### 3. 启动客户端 #### 内网模式(将内网服务暴露给外部) ```bash # 使用默认内网配置 ./build/nettools-client -config configs/client-internal.json # 命令行指定模式 ./build/nettools-client -mode internal -config configs/client-internal.json ``` #### 外部模式(访问内网服务) ```bash # 使用外部配置 ./build/nettools-client -config configs/client-external.json # 命令行指定模式 ./build/nettools-client -mode external -config configs/client-external.json ``` ### 4. 快速测试 #### Linux/macOS: ```bash # 启动服务端 make run-server # 启动内网客户端 make run-client-internal # 启动外部客户端 make run-client-external ``` ## 🔨 配置说明 ### 服务端配置示例 ```json { "host": "0.0.0.0", "services": [ { "name": "ssh-proxy", "port": 2222, "service_type": "proxy", "description": "SSH代理服务", "enabled": true, "auth_required": false, "auth_type": "token" }, { "name": "rdp-proxy", "port": 3389, "service_type": "proxy", "description": "RDP代理服务", "enabled": true, "auth_required": false, "auth_type": "token" } ], "security": { "default_auth_enabled": false, "default_auth_type": "token", "tls_enabled": false, "psk_enabled": false }, "performance": { "max_connections": 1000, "max_services_per_client": 10, "buffer_size": 32768 } } ``` ### 内网客户端配置示例 ```json { "mode": "internal", "server_addr": "your-server-ip", "internal": { "services": [ { "name": "ssh-service", "server_port": 2222, "target_host": "127.0.0.1", "target_port": 22, "protocol": "tcp", "description": "SSH服务映射", "enabled": true, "auth_token": "" } ] } } ``` ### 外部客户端配置示例 ```json { "mode": "external", "server_addr": "your-server-ip", "external": { "services": [ { "name": "ssh-client", "local_port": 2222, "server_addr": "your-server-ip", "server_port": 2222, "protocol": "tcp", "description": "SSH客户端代理", "enabled": true, "auth_token": "" } ] } } ``` ## 📚 使用场景 ### 场景1:SSH访问内网服务器 1. 内网服务器运行SSH服务(端口22) 2. 内网客户端配置:`server_port: 2222, target_port: 22` 3. 外部客户端配置:`local_port: 2222, server_port: 2222` 4. 外部用户通过 `ssh user@localhost -p 2222` 访问内网服务器 ### 场景2:RDP远程桌面访问 1. 内网Windows机器启用RDP(端口3389) 2. 内网客户端配置:`server_port: 3389, target_port: 3389` 3. 外部客户端配置:`local_port: 3389, server_port: 3389` 4. 外部用户通过RDP客户端连接 `localhost:3389` ### 场景3:MySQL数据库访问 1. 内网数据库服务器MySQL(端口3306) 2. 内网客户端配置:`server_port: 3306, target_port: 3306` 3. 外部客户端配置:`local_port: 3306, server_port: 3306` 4. 外部应用通过 `localhost:3306` 访问内网数据库 ## 🛡️ 安全配置 ### 启用认证 ```json { "auth_required": true, "auth_type": "token", "auth_config": { "token": "your-secure-token" } } ``` ### 启用TLS加密 ```json { "security": { "tls_enabled": true, "tls_cert_file": "path/to/cert.pem", "tls_key_file": "path/to/key.pem" } } ``` ## 📝 开发计划 - [ ] 完整的网络处理实现 - [ ] WebUI管理界面 - [ ] 连接状态监控 - [ ] 配置热重载 - [ ] UDP协议支持 - [ ] 负载均衡 - [ ] 连接池优化 ## 📄 许可证 本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。 ## 🤝 贡献 欢迎提交 Issue 和 Pull Request! ## 📞 支持 如有问题,请通过以下方式联系: - 提交 GitHub Issue - 查看项目文档:`doc/` 目录