gardenoftheazazil/daemonproc

GitHub: gardenoftheazazil/daemonproc

DaemonProc 是一个提供 NAT 穿透和端到端加密的无服务器 P2P 网络守护进程,让应用程序无需中央服务器即可直接安全通信。

Stars: 1 | Forks: 1

# Azazil 之园 — DaemonProc [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/ad/ad5834178f7599af9fdda11629d49cae07f2997beec49821b2920eff5bfd50e7.svg)](https://github.com/gardenoftheazazil/daemonproc/actions/workflows/ci.yml) [![Go Version](https://img.shields.io/github/go-mod/go-version/gardenoftheazazil/daemonproc)](https://go.dev/) [![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](https://www.gnu.org/licenses/agpl-3.0) [![Go Report Card](https://goreportcard.com/badge/github.com/gardenoftheazazil/daemonproc)](https://goreportcard.com/report/github.com/gardenoftheazazil/daemonproc) **Serverless、去中心化、端到端加密的 P2P 通信 daemon。** DaemonProc 是 **Garden of the Azazil (GOTA)** 生态系统的核心网络 daemon。它允许应用程序直接在互联网上进行通信——无需任何中央服务器——通过使用 NAT 穿透、加密握手和端到端加密。 ## 愿景 我们正在为**应用间 P2P 通信**构建一套标准,它具备以下特性: - 🔒 **端到端加密** — 没有人能读取您的数据,甚至包括我们 - 🌐 **Serverless** — 没有中央服务器,没有单点故障 - ⚡ **极速** — 通过 UDP 和 NAT 穿透建立直接的 peer 连接 - 🧩 **应用无关性** — 任何应用都可以通过标准库使用 GOTA ### 未来路线图 我们的长期使命超越了简单的 P2P: ``` Phase 1 (Current) Phase 2 Phase 3 ───────────────── ───────────── ───────────── P2P E2EE Mesh Network Distributed App-to-App ───► TURN/Relay ───► Infrastructure Communication Fallback & Protocol Std ``` ## 架构 DaemonProc 是 GOTA 生态系统中的一个组件。应用程序永远不会直接接触网络——它们通过 Unix sockets 与本地 daemon 进行通信。 ``` Machine A Machine B ┌──────────────────┐ ┌──────────────────┐ │ │ │ │ │ ┌────────────┐ │ │ ┌────────────┐ │ │ │ Your App │ │ │ │ Peer App │ │ │ │ │ │ │ │ │ │ │ └─────┬──────┘ │ │ └─────┬──────┘ │ │ │ │ │ │ │ │ Unix Socket │ │ Unix Socket │ │ (libgota) │ │ (libgota) │ │ │ │ │ │ │ │ ┌─────▼──────┐ │ UDP / P2P / E2EE │ ┌─────▼──────┐ │ │ │ DaemonProc │◄─┼────────────────────────►─┤ │ DaemonProc │ │ │ │ │ │ NAT Punch + Handshake │ │ │ │ │ └────────────┘ │ Noise Protocol IKpsk2 │ └────────────┘ │ │ │ │ │ └──────────────────┘ └──────────────────┘ ``` ### 组件 | 组件 | 仓库 | 描述 | |-----------|-----------|-------------| | **DaemonProc** | 本仓库 | 处理 P2P 网络、NAT 穿透和 E2EE 的后台 daemon | | **libgota** | *(即将推出)* | 应用程序用于 IPC 的客户端库 (`.dll` / `.so`) | ### 工作原理 1. **您的应用**链接到 `libgota` 并将数据写入 Unix socket 2. **DaemonProc** 从 socket 读取数据,对其进行加密,然后通过 UDP 发送 3. **NAT 打洞** 在 peer 之间建立直接连接 4. **Noise Protocol (IKpsk2)** 执行加密握手 5. **ChaCha20-Poly1305** 对所有流量进行端到端加密 6. **远程 DaemonProc** 解密数据,并通过其 Unix socket 传递给目标应用 ## 快速入门 ### 前置条件 | 工具 | 版本 | 安装 | |------|---------|---------| | Go | 1.26.5+ | [go.dev/dl](https://go.dev/dl/) | | golangci-lint | v2.x | [golangci-lint.run](https://golangci-lint.run/welcome/install/) | | GNU Make | 任意版本 | Linux/macOS 已预装;[Windows](https://gnuwin32.sourceforge.net/packages/make.htm) | ### 快速开始 ``` # 克隆 git clone https://github.com/gardenoftheazazil/daemonproc.git cd daemonproc # 安装 dependencies make deps # 运行所有 checks make check # 查看所有可用 commands make help ``` ### 可用的 Make 目标 ``` fmt Format all Go source files. lint Run golangci-lint on all packages. vet Run go vet on all packages. test Run all tests with race detector. test-short Run tests in short mode. cover Run tests with coverage report. build Build the daemon binary. deps Download and tidy Go module dependencies. deps-upgrade Upgrade all dependencies. check Run all quality checks (CI equivalent). clean Remove build artifacts and coverage files. ``` ## 代码质量规则 所有贡献**必须**遵守以下规则。违反这些规则的 Pull request 将被 CI pipeline **自动拒绝**。 ### Lint — golangci-lint 每个文件必须通过 `golangci-lint run ./...` 且零问题。完整的配置定义在 [`.golangci.yml`](.golangci.yml) 中。
📋 点击展开:完整规则说明 #### 许可证头部 每个 `.go` 文件必须以以下内容开头: ``` // Copyright (c) Garden of the Azazil. All rights reserved. // Licensed under the AGPL-3.0 License. // See LICENSE file in the project root for full license information. ``` #### 文档注释 | 规则 | 执行者 | |------|-------------| | 所有导出的 symbol 必须包含文档注释 | `revive`, `stylecheck` | | 每个 package 必须包含 package 注释 | `revive`, `stylecheck` | | 所有注释必须以句号结尾 | `godot` | #### 命名规范 | 规则 | 执行者 | |------|-------------| | Go 命名规范(`camelCase` / `PascalCase`) | `revive`, `stylecheck` | | 错误类型必须以 `Error` 后缀结尾 | `errname` | | 错误变量必须命名为 `errXxx` | `stylecheck` | | 错误字符串必须以小写字母开头 | `revive`, `stylecheck` | | 一致的接收者命名 | `revive`, `stylecheck` | | 禁止 shadowing 预定义标识符 | `predeclared` | #### 导入顺序 ``` import ( "context" // stdlib "golang.org/x/crypto/nacl/box" // third-party "github.com/gardenoftheazazil/daemonproc/interfaces" // project ) ``` #### 格式化与风格 | 规则 | 详情 | |------|---------| | 最大行长 | 120 字符 | | 格式化 | `gofmt` (制表符) | | 换行符 | 仅限 LF | | 生产环境中禁止使用 `fmt.Print*` | 使用结构化 logger | | 禁止使用 `panic()` | 应改为返回错误 | #### 错误处理 | 规则 | 执行者 | |------|-------------| | 必须检查所有错误 | `errcheck` | | 使用 `%w` 包装错误 | `errorlint` | | 使用 `errors.Is()` 进行比较 | `errorlint` | | 关闭 HTTP 响应体 | `bodyclose` | #### 复杂度限制 | 指标 | 阈值 | |--------|-----------| | 认知复杂度 (Cognitive complexity) | ≤ 30 | | 圈复杂度 (Cyclomatic complexity) | ≤ 15 | | 嵌套 if 深度 | ≤ 5 |
### 测试 ``` go test ./... -race -count=1 ``` ### 抑制规则 ``` //nolint:lll // This line contains a long regex pattern that cannot be split. var pattern = regexp.MustCompile(`...very long pattern...`) ``` ## CI / 合并要求 | 检查项 | 命令 | 是否必须 | |-------|---------|----------| | **Lint** | `golangci-lint run ./...` | ✅ | | **测试** | `go test ./... -race -count=1` | ✅ | | **审查** | 1 个批准的审查 | ✅ | ## 安全 对于安全漏洞,请参阅我们的[安全政策](SECURITY.md)。 **请勿通过公开的 GitHub issue 报告安全问题。** ## 行为准则 本项目遵循 [Contributor Covenant v2.1](CODE_OF_CONDUCT.md)。 ## 许可证 本项目基于 **GNU Affero General Public License v3.0 (AGPL-3.0)** 授权。 完整文本请参见 [LICENSE](license.md)。
标签:EVTX分析, Golang, NAT穿透, P2P网络, UDP协议, 安全编程, 日志审计, 端到端加密, 网络通信