Files
Nexus/docs/reports/step-3-webssh/engineering-report.md
T
Your Name c9a99f4fb3 fix: 全项目文档对齐 + 代码清理
代码修复:
- web/agent/agent.py: datetime.utcnow() → datetime.now(timezone.utc)
- requirements.txt: 移除 paramiko==3.5.0 (已无活跃引用)
- 删除 server/infrastructure/ssh/pool.py (DEPRECATED, 无引用)

连接池三层对齐 (config.py/.env.example/session.py):
- DB_POOL_SIZE 100→160, DB_MAX_OVERFLOW 100→120
- 基于 MySQL max_connections=400, install.php 公式

文档修复 (21项):
- P0: 硬编码域名/IP替换为配置变量占位符
- P1: 10个过时设计文档加归档标注 (引用旧文件结构)
- P2: step-3-webssh报告 paramiko引用修正
- 6份审查报告连接池参数勘误 100/100→160/120
- ECC安全报告 EC5 datetime.utcnow 标记已修复
- docs/README.md 文档索引重写
- docs/memory/mem_nexus_overview.md 移除硬编码凭证
- docs/project/tech-stack-inventory.md paramiko标记已移除

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 08:19:56 +08:00

1.5 KiB

第三步:Web SSH终端 — 工程部工作报告

日期: 2026-05-21 部门: 工程部 负责人: CTO 任务编号: W1-W5


工作内容

W1: asyncssh 连接池模块(引用计数模式)

  • server/infrastructure/ssh/asyncssh_pool.py
  • AsyncSSHPool 类:引用计数 + 自动空闲清理 + 最大连接数限制
  • acquire(server) / release(server_id) / close_connection(server_id)
  • 全局实例 ssh_pool,在 main.py lifespan 中 start/stop
  • exec_ssh_command(server, command) 替换旧 paramiko exec_command

W2: 替换 paramiko 调用

  • asyncssh_pool 提供统一的 exec_ssh_command() 接口
  • server/infrastructure/ssh/pool.py 保留(paramiko),Sync引擎逐步迁移 pool.py 已删除,paramiko 已从 requirements.txt 移除,所有代码已迁移到 asyncssh

W3: /ws/terminal/{token} 端点

  • server/api/webssh.py — WebSocket终端端点
  • JWT认证(查询参数)
  • 会话追踪(SshSession 记录)
  • 命令日志(CommandLog 按行记录)

W4: xterm.js 前端页面

  • web/app/terminal.html — Tailwind + xterm.js + WebSocket
  • 自适应窗口、断开连接、全屏切换

W5: Koko 消息协议

  • TERMINAL_INIT / DATA / RESIZE / CLOSE / ERROR 消息类型
  • 终端尺寸变更同步

交付物

  • server/infrastructure/ssh/asyncssh_pool.py — asyncssh连接池
  • server/api/webssh.py — WebSSH端点+Koko协议
  • web/app/terminal.html — xterm.js终端页面

验收意见

待测试部压力测试 + ECC组安全审查