Commit Graph
36 Commits
Author SHA1 Message Date
qing aa3741b861 feat(liblogc): 统一集中式日志客户端库 + 全量迁移
新增:
- liblogc/: C++ 统一日志库 (libus_logc.so),支持 set_endpoint/set_service_name/set_level
- pymsg/pymsg/logc.py: Python 统一日志模块,基于 AsyncRpcQueue

C++ 迁移 (删除 6 份本地 LogC.hpp 副本):
- ca, gateway: <us/LogC.hpp> + set_service_name
- captcha2, confs2, smtp3: using qing::LogC + set_service_name
- core: ConfsLogC → qing::LogC (ConfsTask.cpp)
- 所有 Makefile 添加 -lus_logc

Python 迁移 (6 个 log_client.py → 4 行薄包装):
- smtp, redirect80, confs, captcha, dnfs, static
- 全部委托到 pymsg.logc.LogClient

Go (waf): 保持现状,自成体系
2026-08-10 04:51:43 +00:00
qing 01ae877673 fix(smtp): 给 LogClient 补 set_log_level 方法,修复启动崩溃
commit 9fc3542 把 set_log_level 加成模块级函数,但 smtp_v2.py:319
以 logs.set_log_level() 当实例方法调用,导致服务启动即抛
AttributeError: 'LogClient' object has no attribute 'set_log_level'。

新增 LogClient.set_log_level 委托给模块级函数,保持 logs 单例为
统一公开 API,模块级函数保留不破坏其他调用。
2026-08-10 12:26:59 +08:00
qing 9fc3542771 smtp: CLI 标准化补完(--host/--log-level/--instance + log_client 级别过滤)
- argparse 新增 --host(别名 --addr)、--log-level、--instance
- --log-level 经 logs.set_log_level() 真正订阅日志过滤
- log_client.py: 新增 _LOG_LEVELS/set_log_level()/_normalize_level() + push() 级别过滤
- 启动日志打印 instance/log-level 及配置来源说明
- services.yaml: smtp 声明 --instance 和 --log-level
- 注: SMTP 账号走 .env/ENV(密码不进 CLI),与全项目约定一致
2026-08-10 12:05:46 +08:00
qing 08df3929b2 feat(core): services.yaml 启动配置 + _run.sh 统一参数透传
Step 1: init.txt → services.yaml
- 新增 InitParser (yaml-cpp), 支持 YAML/TXT 双模式解析, 向后兼容 init.txt
- 新增 services.yaml 声明式服务配置 (name/cmd/args/depends_on/sleep_before)
- 改造 pmc_mtd.cpp 集成 InitParser, 支持目录/.yaml/.txt 三种路径模式
- Makefile 添加 InitParser 编译目标 + -lyaml-cpp 链接
- setup 脚本添加 libyaml-cpp-dev / yaml-cpp-devel 依赖
- core/_run.sh 改为 -i . (目录模式, 自动查找 services.yaml → init.txt)

Step 2: 11 个 _run.sh 统一参数透传
- 8 个脚本改动: 追加 "$@" / 移除 sleep / 修引号
- waf 保留 -c config.yaml 作为脚本默认值
- services.yaml waf args 改为 [] 避免重复传递
- 开发方案文档: docs/reports/core_services_yaml_dev_doc.md
2026-08-10 03:16:28 +08:00
qing 53ddcb364f feat(aibox): 创建/安装技能工具统一生成 .md 扩展名 + 下线旧版 smtp.py
- CreateSkillTool/InstallSkillTool 改为生成带 .md 扩展名的技能文件,与人格技能文件规范一致
- 同步更新 7_extension_skills.md 模板与工具描述
- 删除旧版 smtp.py(P0-1)并同步审计文档与 README
2026-08-04 08:26:57 +08:00
qing a7a78d1424 docs: aggregate project documentation under docs/ with unified index
- Move all per-module security audit reports to docs/security/
- Move code review logs to docs/reviews/, analysis reports to docs/reports/
- Add docs/INDEX.md as single entry point for all project documentation
- Add documentation management conventions section to README.md
- Clean up empty per-module docs/ directories
2026-08-03 13:21:48 +08:00
qing cebef9fe70 docs: 各模块安全审计报告 + 补充 .gitignore 忽略规则 2026-08-01 05:21:23 +08:00
qing 1b9c727e80 fix(log_client): harden background flush thread against exceptions
- Wrap _flush_loop main body in outer try/except to prevent any
  unexpected exception (network errors, serialization errors, etc.)
  from killing the background thread (which would cause unbounded
  queue growth and eventual OOM)
- Wrap _send() call in inner try/except as final safety net
- Wrap RpcClient() construction in try/except (connection failures
  during client creation were previously unhandled)
- Add _safe_json() helper: unserializable extra fields fall back to
  repr()/str() instead of raising TypeError that could kill thread
- Generate timestamp at push() (enqueue time) instead of _send() time,
  so timestamps reflect actual event time even when queue is backed up
- Replace unreliable time.sleep(0.6) in flush() with _flush_done Event
  for proper synchronization between caller and background thread
- Add _QUEUE_MAXSIZE=10000 with drop-oldest policy to prevent unbounded
  memory growth even in pathological cases
- Use put_nowait with Full handling to ensure push() never blocks
  business threads
- Sync fix to all 4 copies: confs/static/smtp/dnfs
2026-08-01 03:23:19 +08:00
qing 49f0698b9d fix(gateway,smtp): 修复邮件轰炸漏洞(审计 P0-1)
gateway v0.5.3 → v0.5.4:

1. gateway/src/main.cpp
   - /register/send_code 强制 CAPTCHA 校验(经 captcha:8009,Token 一次性消费,fail-closed)
   - 新增邮箱级双窗口限流(3 次/小时 + 10 次/天,CAPTCHA 通过后才计入配额)
   - 新增 _EMAIL_ADDR_RATE_HOUR / _EMAIL_ADDR_RATE_DAY 限流器实例

2. smtp/smtp_v2.py
   - 新增邮箱级长期限流兜底(EMAIL_HOURLY_LIMIT / EMAIL_DAILY_LIMIT,默认 3/10)
   - 新增全局熔断(SMTP_HOURLY_LIMIT,默认 100 封/小时,防 smtp 账号被封)
   - 预占/回滚与 60s 冷却同模式,发送失败不计入配额

3. gateway/docs/SECURITY_AUDIT_20260801.md
   - 新增带日期的安全审计报告
   - P0-1 标记为已修复 v0.5.4

4. gateway/README.md
   - 更新 /register/send_code 接口文档(CAPTCHA 必填 + 5 层防护)
   - 更新版本变更日志

防护层次:IP 限流 → CAPTCHA → 邮箱级限流(gateway)→ 60s 冷却 → 邮箱级限流(smtp)→ 全局熔断
2026-08-01 02:37:15 +08:00
qing 3f97dd92ef update 2026-07-30 21:57:04 +08:00
qing 32d3a5a19f 重构db 2026-07-30 20:15:02 +08:00
qing 74610c32c8 微调 2026-07-30 19:03:34 +08:00
qing 931e134796 docs(smtp): 新建完整 README,覆盖协议、路由、配置与安全机制
- 3 个路由的完整请求/响应文档(send_email / verify_email / health)
- .env 配置项说明(4 种格式支持、必填/可选字段)
- 验证码生命周期:生成→冷却→消费→过期→作废→失败回滚
- 安全机制:发送冷却、失败次数上限防枚举、SMTP 失败回滚
- 集成关系:gateway 调用流程、core 守护、log_client 日志推送
- 旧版 smtp.py 的安全风险标注

fix(smtp): _set.sh 中 nuitka 编译目标 smtp.py → smtp_v2.py
2026-07-30 12:02:25 +08:00
qing 5275b8bf75 feat(smtp): 邮箱验证码连续校验失败 5 次自动作废,防枚举 6 位数字码 2026-07-29 21:57:16 +08:00
qing c5dd8d198d feat(smtp): 同一邮箱 60 秒发送冷却,gateway 429 透传 + 前端重发倒计时(gateway v0.5.3) 2026-07-29 20:54:56 +08:00
qing f4a7aca2fa update: smtp 验证码有效期 60s 调整为 10 分钟,邮件正文从 CODE_TTL 派生
60 秒对邮件送达延迟过于紧张;正文有效期文案改为按 TTL 自动生成避免漂移,前端提示与 README 同步。同时移除 .env 排查用的凭证明文调试打印。
2026-07-29 19:32:44 +08:00
qing f5b69d0b4c fix: smtp .env 解析兼容 KEY: VALUE 冒号格式,MAIL_FROM 默认跟随 SMTP_USER
服务器 .env 误用 YAML 冒号格式导致凭证全部加载为空;163 等服务商强制 From 头与登录账号一致,写死的 MAIL_FROM 会触发 553,现默认取 SMTP_USER、可用 .env 显式覆盖。
2026-07-29 19:08:13 +08:00
qing 53c742c26e refactor: smtp.py.remote 更名为 smtp_v2.py,恢复 .py 后缀以便工具链识别
_run.sh 同步指向新文件名;start() 新增启动时凭证明文打印(仅 stdout 不落日志库),用于排查 .env 加载问题,调试完成后需移除。
2026-07-29 18:36:21 +08:00
qing 11993e178b smtp dev 2026-07-29 18:22:38 +08:00
qing d5a67ce77e fix: smtp .env 兼容 export 前缀并在启动时报告缺失的配置项名称 2026-07-28 17:42:37 +08:00
qing 6330e04474 fix: smtp .env 手动解析替代 dotenv,同时支持 KEY=VALUE 和 KEY VALUE 格式 2026-07-28 17:34:55 +08:00
qing 9078c4d051 refactor: smtp 改造为 pymsg TCP 服务并修复 NameError/finally/KeyError 等已知 bug 2026-07-28 17:12:45 +08:00
shufeng2012 974c912d9e 🦺 更新验证码位数 2026-07-27 19:16:27 +08:00
qing 167ef235e6 fixbug 100% cpu 2026-07-27 14:47:12 +08:00
qing 58e9391503 refix 2026-07-27 09:28:27 +08:00
qing b790e18024 Merge branch 'dev_qing' of https://git.cancerai.top/qing/micro_servers into dev_qing 2026-07-27 09:21:20 +08:00
qing 08021015b1 更新msg客户端 2026-07-27 09:21:06 +08:00
shufeng2012 813fe91663 🐛 修复无法运行的bug 2026-07-26 21:15:23 +08:00
shufeng2012 c1642dbc0c ➕ 添加.env依赖 2026-07-26 20:57:54 +08:00
shufeng2012 747c2ebd0a 🙈 更新smtp/.gitignore 2026-07-26 20:57:16 +08:00
shufeng2012 957981c2c3 🍱 更新脚本 2026-07-26 20:57:04 +08:00
shufeng2012 52f4429f6f 更新端口 2026-07-26 20:22:31 +08:00
shufeng2012 fb57c87d17 🔥 好像这个API文档没啥用 2026-07-26 20:14:40 +08:00
shufeng2012 6067030ae2 ✨ 添加smtp邮箱验证功能 2026-07-26 19:37:20 +08:00
shufeng2012 a3c361e591 💩 写了依托smtp 2026-07-25 21:42:05 +08:00
qing efbe2b36f3 节点所有权 2026-07-25 14:20:08 +08:00