Commit Graph

11 Commits

Author SHA1 Message Date
hailin e76adcbe8d . 2025-12-07 14:56:13 +00:00
hailin 747e4ae8ef refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing
- Remove Address field from PartyEndpoint (parties connect to router themselves)
- Update K8s Discovery to only manage PartyID and Role labels
- Add Party registration and SessionEvent protobuf definitions
- Implement PartyRegistry and SessionEventBroadcaster domain logic
- Add RegisterParty and SubscribeSessionEvents gRPC handlers
- Prepare infrastructure for party-driven MPC coordination

This is the first phase of migrating from coordinator-driven to party-driven
architecture following international MPC system design patterns.
2025-12-05 08:11:28 -08:00
Developer 7d257cd35f fix(tproxy): detect clash process with any name (clash-linux-amd64, etc.)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 01:28:17 -08:00
Developer b00cec6b3b feat(scripts): add transparent proxy script for gateway
Script to enable/disable transparent proxy on 192.168.1.100, allowing
192.168.1.111 to access internet through Clash proxy without any
client-side configuration.

Usage:
  sudo bash scripts/tproxy.sh on      # Enable
  sudo bash scripts/tproxy.sh off     # Disable
  sudo bash scripts/tproxy.sh status  # Check status
  sudo bash scripts/tproxy.sh config  # Show required Clash config

Features:
- Redirects TCP traffic from specified clients to Clash redir port
- Optional DNS redirect to Clash DNS
- Bypasses local/private networks
- Easy on/off switching

Prerequisites:
- Clash running with redir-port and allow-lan enabled
- 192.168.1.100 configured as gateway for 192.168.1.111

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 01:16:01 -08:00
Developer ad2790e95e fix(deploy): remove global port settings from mpc.env to fix port conflicts
Problem: message-router and other services were using wrong ports (50051/8080)
instead of their configured ports (50052/8082) because mpc.env contained:
  MPC_SERVER_HTTP_PORT=8080
  MPC_SERVER_GRPC_PORT=50051

These global settings in mpc.env were overriding the per-service Environment=
settings in systemd unit files, causing port conflicts.

Solution:
- Remove MPC_SERVER_HTTP_PORT and MPC_SERVER_GRPC_PORT from mpc.env template
- Add fix-ports command to remove these settings from existing installations
- Add comments explaining per-service port configuration

Port assignments:
  - session-coordinator: gRPC 50051, HTTP 8081
  - message-router: gRPC 50052, HTTP 8082
  - server-party-1/2/3: HTTP 8083/8084/8085
  - account-service: HTTP 8080

To fix existing installation:
  sudo bash scripts/deploy.sh fix-ports
  sudo bash scripts/deploy.sh restart

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 01:02:40 -08:00
Developer dfefd343b0 fix: improve regenerate_keys() to replace any existing key values
Changed sed patterns from matching specific placeholder strings to
matching entire lines (^KEY=.*), ensuring keys are properly replaced
regardless of current value.

Tested in WSL2 - generates valid 64-char hex master key.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 00:47:59 -08:00
Developer ee398534bb fix: auto-generate secure keys and add regenerate-keys command
- create_env_config() now auto-generates random secure keys:
  - PostgreSQL password (32 char alphanumeric)
  - RabbitMQ password (32 char alphanumeric)
  - JWT secret (32 char alphanumeric)
  - API key (32 char alphanumeric)
  - Master key (64 hex chars = 256-bit)
- Add regenerate-keys command to fix placeholder key issues
- Fixes "Invalid master key format" error for server-party services

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 00:39:12 -08:00
Developer ec9366186c fix(mpc-system): 修复服务 gRPC/HTTP 端口冲突
问题:
- session-coordinator 和 message-router 都默认使用 gRPC 50051
- 端口冲突导致 message-router 无法启动
- server-party 因无法连接 message-router 而失败

修复:
为每个服务分配独立的端口:
- account-service: HTTP 8080
- session-coordinator: gRPC 50051, HTTP 8081
- message-router: gRPC 50052, HTTP 8082
- server-party-1: HTTP 8083
- server-party-2: HTTP 8084
- server-party-3: HTTP 8085

服务器修复步骤:
  git pull
  sudo bash scripts/deploy.sh build   # 重新生成 systemd 服务文件
  sudo bash scripts/deploy.sh restart
  sudo bash scripts/deploy.sh status

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 00:23:14 -08:00
Developer 959fc3910c feat(mpc-system): 添加 debug 命令用于故障排查
新增 debug 命令,显示以下信息:
- 环境变量配置状态
- PostgreSQL 连接测试(使用 mpc.env 中的密码)
- Redis 连接测试
- RabbitMQ 状态检查
- 端口监听状态(5432, 6379, 5672, 50051, 50052, 8080)
- 各服务最近 10 条日志
- 手动测试命令提示

使用方法:
  sudo ./scripts/deploy.sh debug

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 00:19:13 -08:00
Developer 0604255ba8 fix(mpc-system): 修复 PostgreSQL 认证配置问题
问题原因:
- 部署脚本使用 POSTGRES_PASSWORD 环境变量
- Go 代码使用 MPC_DATABASE_PASSWORD 环境变量 (Viper 前缀)
- 变量名不匹配导致数据库认证失败

修复内容:
- configure_postgres() 改用 MPC_DATABASE_* 环境变量
- 添加 pg_hba.conf 配置,将 peer/scram-sha-256 改为 md5 认证
- 添加 GRANT ALL ON SCHEMA public 权限
- 使用 127.0.0.1 而非 localhost 进行连接
- 新增 reconfigure 命令用于修复现有安装

服务器修复步骤:
  sudo ./scripts/deploy.sh reconfigure
  sudo ./scripts/deploy.sh restart

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 00:13:24 -08:00
Developer 70e6391691 feat(mpc-system): 添加原生部署脚本,替代 Docker 部署
由于中国网络环境无法正常使用 Docker,添加原生部署方案:

新增文件:
- backend/mpc-system/scripts/deploy.sh - 一键部署脚本

脚本功能:
- install: 安装 Go 1.21、PostgreSQL、Redis、RabbitMQ
- build: 编译 Go 服务并配置基础设施
- start/stop/restart: 服务控制
- status: 查看服务状态
- logs: 查看服务日志
- uninstall: 卸载服务

更新文档:
- 更新 DEPLOYMENT_GUIDE.md 第 4 节为原生部署方式
- 添加 systemd 服务管理说明
- 添加 Nginx/iptables 端口映射配置
- 更新故障排查指南

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 23:24:16 -08:00