{"id":38973510,"url":"https://github.com/silver2dream/andromeda-linux-cpp","last_synced_at":"2026-01-17T16:42:57.381Z","repository":{"id":162155956,"uuid":"636268961","full_name":"silver2dream/andromeda-linux-cpp","owner":"silver2dream","description":"High‑performance C++ TCP server framework (master‑worker + epoll) — showcase mode / limited maintenance","archived":false,"fork":false,"pushed_at":"2025-07-25T21:18:02.000Z","size":219,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-07-26T03:33:38.437Z","etag":null,"topics":["concurrency","cpp","epoll","framework","high-performance","linux","networking","protobuf","showcase","tcp-server"],"latest_commit_sha":null,"homepage":"https://github.com/silver2dream/andromeda-linux-cpp#readme","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silver2dream.png","metadata":{"files":{"readme":"README-zh-TW.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY_FIXES.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-05-04T13:24:27.000Z","updated_at":"2025-07-25T21:29:17.000Z","dependencies_parsed_at":"2024-10-29T23:45:10.578Z","dependency_job_id":null,"html_url":"https://github.com/silver2dream/andromeda-linux-cpp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/silver2dream/andromeda-linux-cpp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silver2dream%2Fandromeda-linux-cpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silver2dream%2Fandromeda-linux-cpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silver2dream%2Fandromeda-linux-cpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silver2dream%2Fandromeda-linux-cpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silver2dream","download_url":"https://codeload.github.com/silver2dream/andromeda-linux-cpp/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silver2dream%2Fandromeda-linux-cpp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28511868,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","cpp","epoll","framework","high-performance","linux","networking","protobuf","showcase","tcp-server"],"created_at":"2026-01-17T16:42:56.639Z","updated_at":"2026-01-17T16:42:57.361Z","avatar_url":"https://github.com/silver2dream.png","language":"C++","readme":"[English](README.md) | [繁體中文](README-zh-TW.md)\n---\n# Andromeda Linux C++\n\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/silver2dream/andromeda-linux-cpp/ubuntu.yml?logo=github)\n[![GitHub License](https://img.shields.io/github/license/silver2dream/andromeda-linux-cpp?logo=github)][license]\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/b0e6a6bf3b59467e9f18379dc87d9ee6)](https://app.codacy.com/gh/silver2dream/andromeda-linux-cpp/dashboard?utm_source=gh\u0026utm_medium=referral\u0026utm_content=\u0026utm_campaign=Badge_grade)\n![Project Status](https://img.shields.io/badge/status-showcase-yellow)\n![Maintenance](https://img.shields.io/badge/maintenance-limited-orange)\n\n[license]: LICENSE\n\n一個使用 C++ 編寫的高性能網路伺服器框架，採用多進程和多線程架構設計，專為處理高並發 TCP 連接而開發。\n\n## 📢 專案狀態\n\n本專案目前處於**展示模式**。雖然程式碼功能完整並展示了高性能網路程式設計概念，但由於時間限制，主動維護和功能開發受到限制。\n\n### 這意味著什麼：\n- ✅ **歡迎程式碼審查**：歡迎探索和學習程式碼\n- ✅ **問題討論**：歡迎提出錯誤報告和問題進行社群討論\n- ⚠️ **PR 審查有限**：Pull Request 可能無法及時審查\n- ⚠️ **不接受功能請求**：目前不積極規劃新功能\n\n### 社群貢獻\n如果您覺得這個專案有用並想要貢獻：\n- Fork 儲存庫進行您自己的修改\n- 與社群分享您的改進\n- 如果您有興趣長期參與，請考慮成為維護者\n\n## 🌟 特色功能\n\n- **多進程架構**：採用類似 Nginx 的 Master-Worker 進程模型\n- **高並發處理**：基於 Epoll 的 I/O 多路復用配合線程池\n- **Protocol Buffer 支援**：使用 protobuf 進行高效的二進制序列化\n- **安全特性**：DDoS 防護、洪水攻擊檢測和連接超時管理\n- **記憶體管理**：自定義記憶體池，配合 Valgrind 進行洩漏檢測\n- **Docker 就緒**：支援容器化部署\n- **CI/CD 整合**：透過 GitHub Actions 自動化測試和構建\n\n## 🏗️ 系統架構\n\n```\n┌─────────────────┐\n│   Master 進程    │\n└─────────┬───────┘\n          │\n    ┌─────▼─────┐\n    │  Worker   │\n    │   進程群   │\n    └─────┬─────┘\n          │\n    ┌─────▼─────┐\n    │   線程池   │\n    └───────────┘\n```\n\n### 核心組件\n\n- **app/**: 主應用程式入口點\n- **business/**: 業務邏輯處理器和訊息處理\n- **net/**: 網路層，包含 socket 管理和 epoll 處理\n- **signal/**: 信號處理，用於進程間通信\n- **proc/**: 進程管理工具\n- **misc/**: 工具函數和輔助類別\n- **_include/**: 頭文件和公共介面\n\n## 📁 專案結構\n\n```\nandromeda-linux-cpp/\n├── 📁 app/                    # 主應用程式\n│   ├── andromeda.cxx          # 入口點和主函數\n│   └── CMakeLists.txt         # 構建配置\n├── 📁 business/               # 業務邏輯層\n│   ├── andro_logic.cxx        # 核心業務邏輯和訊息處理器\n│   └── CMakeLists.txt         # 構建配置\n├── 📁 net/                    # 網路層\n│   ├── andro_socket.cxx       # 主要 socket 管理\n│   ├── andro_socket_accept.cxx # 連接接受\n│   ├── andro_socket_conn.cxx  # 連接管理\n│   ├── andro_socket_inet.cxx  # 網路工具\n│   ├── andro_socket_request.cxx # 請求處理\n│   ├── andro_socket_time.cxx  # 超時和計時器處理\n│   ├── ikcp.c                 # KCP 協定實現\n│   └── CMakeLists.txt         # 構建配置\n├── 📁 signal/                 # 信號處理\n│   └── CMakeLists.txt         # 構建配置\n├── 📁 proc/                   # 進程管理\n│   └── CMakeLists.txt         # 構建配置\n├── 📁 misc/                   # 工具和輔助\n│   └── CMakeLists.txt         # 構建配置\n├── 📁 _include/               # 頭文件\n│   ├── andro_cmd.h            # 指令定義\n│   ├── andro_conf.h           # 配置管理\n│   ├── andro_crc32.h          # CRC32 校驗工具\n│   ├── andro_func.h           # 通用函數\n│   ├── andro_global.h         # 全域定義\n│   ├── andro_lockmutex.h      # 互斥鎖和鎖定\n│   ├── andro_logic.h          # 業務邏輯介面\n│   ├── andro_macro.h          # 巨集定義\n│   ├── andro_memory.h         # 記憶體管理\n│   ├── andro_packet.h         # 封包結構定義\n│   ├── andro_socket.h         # Socket 介面\n│   ├── andro_threadpool.h     # 線程池管理\n│   └── ikcp.h                 # KCP 協定頭文件\n├── 📁 proto/                  # Protocol Buffer 定義\n│   └── auth.proto             # 認證訊息\n├── 📁 generated/              # 生成的 protobuf 文件\n│   └── (自動生成的 .pb.cc 和 .pb.h 文件)\n├── 📁 .github/workflows/      # CI/CD 管道\n│   └── ubuntu.yml             # GitHub Actions 工作流程\n├── 📁 logs/                   # 日誌文件目錄\n├── 📄 andromeda.conf          # 伺服器配置文件\n├── 📄 CMakeLists.txt          # 根構建配置\n├── 📄 Dockerfile             # 容器配置\n├── 📄 .clang-format           # 程式碼格式化規則\n├── 📄 .gitignore              # Git 忽略模式\n├── 📄 LICENSE                 # AGPL-3.0 授權條款\n└── 📄 README.md               # 此文檔\n```\n\n## 🚀 快速開始\n\n### 系統需求\n\n確保您的系統已安裝以下依賴項：\n\n```bash\n# Ubuntu/Debian\nsudo apt-get update\nsudo apt-get install -y build-essential cmake g++ protobuf-compiler libprotobuf-dev valgrind\n\n# CentOS/RHEL\nsudo yum install -y gcc gcc-c++ cmake protobuf-compiler protobuf-devel valgrind\n```\n\n### 從原始碼構建\n\n1. **複製儲存庫**\n   ```bash\n   git clone https://github.com/silver2dream/andromeda-linux-cpp.git\n   cd andromeda-linux-cpp\n   ```\n\n2. **生成 Protocol Buffer 文件**\n   ```bash\n   protoc -I=./proto --cpp_out=./generated ./proto/*.proto\n   ```\n\n3. **構建專案**\n   ```bash\n   mkdir build \u0026\u0026 cd build\n   cmake ..\n   make\n   ```\n\n4. **執行伺服器**\n   ```bash\n   ./andromeda\n   ```\n\n### 使用 Docker\n\n1. **構建 Docker 映像**\n   ```bash\n   docker build -t andromeda-server .\n   ```\n\n2. **執行容器**\n   ```bash\n   docker run -p 9000:9000 andromeda-server\n   ```\n\n## ⚙️ 配置設定\n\n伺服器可透過 `andromeda.conf` 文件進行配置：\n\n### 進程配置\n```ini\n[Process]\nMaster = andromeda:master process\nWorker = andromeda:worker process\nWorkerProcesses = 4          # Worker 進程數量\nWorkerThreadCount = 2        # 每個 Worker 的線程數\nDaemon = 1                   # 以守護進程運行 (1) 或前台運行 (0)\n```\n\n### 網路配置\n```ini\n[Net]\nPortCount = 1\nPort0 = 9000                 # 監聽埠號\nWorkerConnections = 1024     # 每個 Worker 的最大連接數\nSocketRecyWaitTime = 80      # Socket 回收等待時間（秒）\nSocketKickTimerEnable = 1    # 啟用心跳超時檢測\nSocketMaxWaitTime = 20       # 心跳超時閾值（秒）\nSocketTimeoutKick = 1        # 超時時踢出客戶端\n```\n\n### 安全配置\n```ini\n[NetSecurity]\nSecurityFloodAttackDetectionEnable = 1  # 啟用洪水攻擊檢測\nSecurityFloodTimeInterval = 100          # 封包間隔閾值（毫秒）\nSecurityFloodKickCounter = 10            # 間隔內最大封包數，超過即踢出\n```\n\n### 日誌配置\n```ini\n[Log]\nLog = logs/error.log         # 日誌文件路徑\nLogLevel = 8                 # 日誌級別 (0-8，0=最高優先級)\n```\n\n## 📡 通信協定\n\n### 訊息格式\n\n所有訊息都遵循標準化的封包格式：\n\n```cpp\nstruct andro_packet_header_s {\n    unsigned short pkg_len;   // 總訊息長度（頭部 + 主體）\n    unsigned short msg_code;  // 訊息類型識別碼\n    int crc32;                // CRC32 校驗和，用於完整性檢查\n};\n```\n\n### 支援的指令\n\n- **PING (0)**: 心跳/保活訊息\n- **REGISTER (5)**: 使用者註冊\n- **LOGIN (6)**: 使用者認證\n\n### Protocol Buffer 定義範例\n\n```protobuf\nsyntax = \"proto3\";\npackage auth;\n\nmessage C2SRegister {\n   string username = 1;\n   string password = 2;\n}\n\nmessage S2CRegister {\n    string username = 1;\n    string password = 2;   \n}\n```\n\n## 🧪 測試\n\n### 記憶體洩漏檢測\n\n執行 Valgrind 檢查記憶體洩漏：\n\n```bash\nmake memcheck\n```\n\n### 自定義測試指令\n\n```bash\n# 清理構建產物\nmake clear\n\n# 終止所有運行實例\nmake kill\n\n# 重新生成 Protocol Buffer 文件\nmake protoc\n```\n\n## 🔧 開發指南\n\n### 程式碼風格\n\n本專案使用 clang-format 保持一致的程式碼格式。配置定義在 `.clang-format` 文件中。\n\n### 提交規範\n\n我們遵循 [Conventional Commits](https://www.conventionalcommits.org/) 規範：\n\n```\nfeat: 新功能\nfix: 修復錯誤\ndocs: 文檔變更\nstyle: 程式碼風格變更（格式化、缺少分號等）\nrefactor: 程式碼重構（既不添加功能也不修復錯誤）\nperf: 性能改進\ntest: 添加或修改測試\nchore: 構建流程或輔助工具變更\n```\n\n### 添加新的訊息處理器\n\n1. 在 `proto/` 目錄中定義您的訊息\n2. 在 `business/andro_logic.cxx` 中添加處理函數\n3. 在 `status_handler` 陣列中註冊處理器\n4. 重新構建和測試\n\n## 📊 性能表現\n\n- **並發連接**：支援數千個並發連接\n- **記憶體效率**：自定義記憶體池減少分配開銷\n- **低延遲**：基於 Epoll 的事件處理最小化上下文切換\n- **可擴展性**：多進程架構可跨 CPU 核心擴展\n\n## 🐳 Docker 部署\n\n包含的 Dockerfile 創建了一個安全的非 root 容器：\n\n- 基於 Ubuntu 22.04\n- 以使用者 `han`（UID 1000）身份運行\n- 暴露 9000 埠\n- 包含所有必要的依賴項\n\n## 🤝 貢獻指南\n\n1. Fork 此儲存庫\n2. 創建功能分支（`git checkout -b feature/amazing-feature`）\n3. 提交您的變更（`git commit -m 'feat: add amazing feature'`）\n4. 推送到分支（`git push origin feature/amazing-feature`）\n5. 開啟 Pull Request\n\n## 📝 授權條款\n\n本專案依據 **GNU Affero General Public License v3.0 (AGPL-3.0)** 進行授權 - 詳情請參閱 [LICENSE](LICENSE) 文件。\n\n### AGPL-3.0 的重要特點：\n- ✅ **使用自由**：您可以將此軟體用於任何目的\n- ✅ **研究和修改自由**：擁有原始碼存取和修改權限\n- ✅ **散布自由**：您可以散布副本和修改版本\n- ⚠️ **Copyleft 要求**：修改版本也必須採用 AGPL-3.0 授權\n- ⚠️ **網路使用揭露**：如果您在伺服器上運行修改版本，必須向使用者提供原始碼\n\n## 🔗 相關專案\n\n- [Protocol Buffers](https://developers.google.com/protocol-buffers) - 序列化函式庫\n- [Valgrind](https://valgrind.org/) - 記憶體調試工具\n- [Docker](https://www.docker.com/) - 容器化平台\n\n## 📧 技術支援\n\n如果您遇到任何問題或有疑問，請在 GitHub 上開啟 issue。\n\n---\n\n**注意**：這是一個面向生產環境的高性能伺服器框架。在生產環境中部署時，請確保進行適當的測試和安全措施。","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilver2dream%2Fandromeda-linux-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilver2dream%2Fandromeda-linux-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilver2dream%2Fandromeda-linux-cpp/lists"}