mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:40:25 +00:00
## 功能概述
- 新增账号禁用/异常状态的 Webhook 实时通知机制
- 支持 Claude OAuth、Claude Console、Gemini 三种平台的账号监控
- 提供完整的 Webhook 管理 API 和配置选项
## 主要变更
### 新增文件
- `src/utils/webhookNotifier.js`: Webhook 通知核心服务
- `src/routes/webhook.js`: Webhook 管理 API 路由
### 功能集成
- Claude OAuth 账号:unauthorized 状态 + token 刷新错误通知
- Claude Console 账号:blocked 状态通知
- Gemini 账号:token 刷新错误通知
### 配置支持
- 新增环境变量:WEBHOOK_ENABLED, WEBHOOK_URLS, WEBHOOK_TIMEOUT, WEBHOOK_RETRIES
- 支持多个 Webhook URL 并发通知
- 自动重试机制(指数退避)+ 超时保护
### 管理端点
- POST /admin/webhook/test: 测试连通性
- POST /admin/webhook/test-notification: 发送测试通知
- GET /admin/webhook/config: 查看配置信息
## 通知格式
```json
{
"type": "account_anomaly",
"data": {
"accountId": "uuid",
"accountName": "账号名称",
"platform": "claude-oauth|claude-console|gemini",
"status": "unauthorized|blocked|error",
"errorCode": "CLAUDE_OAUTH_UNAUTHORIZED",
"reason": "具体异常原因",
"timestamp": "2025-01-13T10:30:00.000Z"
}
}
```
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
67 lines
1.6 KiB
Plaintext
67 lines
1.6 KiB
Plaintext
# 🚀 Claude Relay Service Configuration
|
||
|
||
# 🌐 服务器配置
|
||
PORT=3000
|
||
HOST=0.0.0.0
|
||
NODE_ENV=production
|
||
|
||
# 🔐 安全配置
|
||
JWT_SECRET=your-jwt-secret-here
|
||
ADMIN_SESSION_TIMEOUT=86400000
|
||
API_KEY_PREFIX=cr_
|
||
ENCRYPTION_KEY=your-encryption-key-here
|
||
|
||
# 👤 管理员凭据(可选,不设置则自动生成)
|
||
# ADMIN_USERNAME=cr_admin_custom
|
||
# ADMIN_PASSWORD=your-secure-password
|
||
|
||
# 📊 Redis 配置
|
||
REDIS_HOST=localhost
|
||
REDIS_PORT=6379
|
||
REDIS_PASSWORD=
|
||
REDIS_DB=0
|
||
REDIS_ENABLE_TLS=
|
||
|
||
# 🎯 Claude API 配置
|
||
CLAUDE_API_URL=https://api.anthropic.com/v1/messages
|
||
CLAUDE_API_VERSION=2023-06-01
|
||
CLAUDE_BETA_HEADER=claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,fine-grained-tool-streaming-2025-05-14
|
||
|
||
# 🌐 代理配置
|
||
DEFAULT_PROXY_TIMEOUT=60000
|
||
MAX_PROXY_RETRIES=3
|
||
|
||
# 📈 使用限制
|
||
DEFAULT_TOKEN_LIMIT=1000000
|
||
|
||
# 📝 日志配置
|
||
LOG_LEVEL=info
|
||
LOG_MAX_SIZE=10m
|
||
LOG_MAX_FILES=5
|
||
|
||
# 🔧 系统配置
|
||
CLEANUP_INTERVAL=3600000
|
||
TOKEN_USAGE_RETENTION=2592000000
|
||
HEALTH_CHECK_INTERVAL=60000
|
||
SYSTEM_TIMEZONE=Asia/Shanghai
|
||
TIMEZONE_OFFSET=8
|
||
METRICS_WINDOW=5 # 实时指标统计窗口(分钟),可选1-60,默认5分钟
|
||
|
||
# 🎨 Web 界面配置
|
||
WEB_TITLE=Claude Relay Service
|
||
WEB_DESCRIPTION=Multi-account Claude API relay service with beautiful management interface
|
||
WEB_LOGO_URL=/assets/logo.png
|
||
|
||
# 🛠️ 开发配置
|
||
DEBUG=false
|
||
ENABLE_CORS=true
|
||
TRUST_PROXY=true
|
||
|
||
# 🔒 客户端限制(可选)
|
||
# ALLOW_CUSTOM_CLIENTS=false
|
||
|
||
# 📢 Webhook 通知配置
|
||
WEBHOOK_ENABLED=true
|
||
WEBHOOK_URLS=https://your-webhook-url.com/notify,https://backup-webhook.com/notify
|
||
WEBHOOK_TIMEOUT=10000
|
||
WEBHOOK_RETRIES=3 |