Commit Graph

19 Commits

Author SHA1 Message Date
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
Developer c63be04322 feat(mpc-system): 优化 Docker 部署配置适配生产环境
部署位置: 192.168.1.100 (Nginx + MPC 服务器)

主要修改:
- 对外仅暴露端口 4000 (account-service)
- 移除基础设施服务的外部端口暴露
- 默认使用 production 环境
- 添加 MPC_API_KEY 和 ALLOWED_IPS 安全配置
- 新增 .env.example 生产环境配置模板
- 移除 Consul 服务发现 (简化部署)
- 优化 Redis 内存配置

架构说明:
- account-service:4000 为对外 API 入口
- 后端服务器 (192.168.1.111) 的 mpc-service 通过此端口调用

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 21:59:01 -08:00
Developer f4a3a6dd1c . 2025-11-29 07:14:44 -08:00
Developer 503999eaf2 docs: Add detailed DDD + Hexagonal architecture documentation
- Add comprehensive DDD tactical patterns (Entity, Value Object, Aggregate, Repository, Domain Service)
- Add Hexagonal Architecture details (Input/Output Ports, Adapters)
- Include code examples for each pattern
- Add dependency injection explanation
- Update section numbering

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 07:13:38 -08:00
Developer 79ccdd7116 feat: Complete MPC TSS implementation with t-of-n threshold signing
Major changes:
- Add TSS core library (pkg/tss) with keygen and signing protocols
- Implement gRPC clients for Server Party service
- Add MPC session endpoints to Account service
- Deploy 3 Server Party instances in docker-compose
- Add MarkPartyReady and StartSession to proto definitions
- Complete integration tests for 2-of-3, 3-of-5, 4-of-7 thresholds
- Add comprehensive documentation (architecture, API, testing, deployment)

Test results:
- 2-of-3: PASSED (keygen 93s, signing 80s)
- 3-of-5: PASSED (keygen 198s, signing 120s)
- 4-of-7: PASSED (keygen 221s, signing 150s)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 06:57:53 -08:00
Developer 75226ce097 feat: Complete production deployment configuration
- Add config.example.yaml with all configuration options documented
- Add server-party service main.go with HTTP endpoints
- Fix message-router gRPC handler registration
- All services now buildable and deployable via docker-compose

Test results:
- Unit tests: 3/3 PASS
- Integration tests: 26/26 PASS
- E2E tests: 8/8 PASS
- Docker build: All 4 services built successfully

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 04:10:06 -08:00
Developer 0f70bb02fd fix: Complete E2E test fixes for account service authentication
- Fix CreateAccount to decode hex-encoded public key before storage
- Fix Login signature verification to hash challenge before verifying
- Return 401 instead of 400 for invalid hex format in login credentials
- Fix CompleteRecovery to handle direct transition from requested state

All 8 E2E tests now pass (100% pass rate):
- TestAccountRecoveryFlow, TestCompleteAccountFlow, TestDuplicateUsername, TestInvalidLogin
- TestCompleteKeygenFlow, TestExceedParticipantLimit, TestGetNonExistentSession, TestJoinSessionWithInvalidToken

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 03:07:50 -08:00
Developer 393c0ef04d > 2025-11-29 01:35:10 -08:00
Developer 5faf4fc9a0 fix: Add hex encoding/decoding for account service authentication
- Add encoding/hex import to account handler
- Encode challenge as hex string in GenerateChallenge handler
- Decode hex-encoded challenge and signature in Login handler
- Decode hex-encoded public key in CompleteRecovery handler

This fixes compatibility between the test client (which uses hex encoding)
and the server handlers.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 01:34:32 -08:00
hailin cc6a76514b fix: Report completion for all 3 participants in TestCompleteKeygenFlow
The test was only reporting completion for one participant, but the session
requires ALL participants to report completion before transitioning to
"completed" status. This follows the domain logic in ShouldCompleteSession()
which checks session.AllCompleted().

Changes:
- Added reportCompletion calls for all 3 parties (party_user_device,
  party_server, party_recovery)
- Updated test comment to clarify all participants must report completion
2025-11-29 00:52:53 -08:00
hailin 7531cbd07a fix: Implement MarkPartyReady and StartSession handlers, update domain logic
- Add sessionRepo to HTTP handler for database operations
- Implement MarkPartyReady handler to update participant status
- Implement StartSession handler to start MPC sessions
- Update CanStart() to accept participants in 'ready' status
- Make Start() method idempotent to handle automatic + explicit starts
- Fix repository injection through dependency chain in main.go
- Add party_id parameter to test completion request
2025-11-29 00:31:24 -08:00