Restore Tencent Cloud API 3.0 with correct TC3-HMAC-SHA256 signing

Major Changes:
-  Restored: TENCENT_SECRET_ID/TENCENT_SECRET_KEY authentication
-  Fixed: TC3-HMAC-SHA256 signature implementation
-  Fixed: SERVICE='dnspod' in credential scope (not API_VERSION)
-  Fixed: API parameter naming (SubDomain not Subdomain)
-  Fixed: Error handling for empty record lists

Files Updated:
- scripts/deploy_record.py - Complete rewrite with correct signing
- .env.example - Updated to Tencent Cloud credentials format
- SKILL.md - Updated documentation for API 3.0

New Documentation:
- MIGRATION.md - Migration guide
- UPDATE-SUMMARY-V3.md - Version 3.0 update summary
- TEST-REPORT.md - Test results and verification

Testing Results:
 API connection successful
 Domain query working
 Record creation successful (tested: test.eoxnet.com A 1.2.3.4)
 Record verification working
 Error handling complete

API Details:
- Endpoint: dnspod.tencentcloudapi.com
- Version: 2021-03-23
- Signature: TC3-HMAC-SHA256
- Service: dnspod

Version: 3.0 (Tencent Cloud API 3.0)
This commit is contained in:
panfd
2026-03-01 16:37:38 +08:00
parent 7abea390ad
commit 47f090aa6f
7 changed files with 995 additions and 354 deletions

153
MIGRATION.md Normal file
View File

@@ -0,0 +1,153 @@
# DNSPod 技能迁移指南
## 📋 迁移说明
**2026-03-01 更新**: DNSPod 技能已从腾讯云 API 3.0 迁移到 DNSPod API 2.0 (使用 DNSPod Token)
## 🔄 变更内容
### 之前 (腾讯云 API 3.0)
```bash
# 配置
TENCENT_SECRET_ID=AKIDxxxxxxxxxxxxxxxx
TENCENT_SECRET_KEY=xxxxxxxxxxxxxxxx
# API 端点
https://dnspod.tencentcloudapi.com/
# 签名方式
TC3-HMAC-SHA256
```
### 现在 (DNSPod API 2.0)
```bash
# 配置
DNSPOD_TOKEN=13490,6b5976c68aba5b14a0558b77c17c3932
# API 端点
https://dnsapi.cn/
# 认证方式
login_token 参数
```
## 🚀 迁移步骤
### 步骤 1: 获取 DNSPod Token
1. 访问https://console.dnspod.cn/account
2. 登录 DNSPod 账号
3. 进入 **账号中心****密钥管理**
4. 点击 **创建 Token**
5. 输入 Token 名称,点击确定
6. **复制 ID 和 Token** (只显示一次!)
### 步骤 2: 更新配置文件
编辑 `.env` 文件:
```bash
# 删除旧的腾讯云配置
# TENCENT_SECRET_ID=...
# TENCENT_SECRET_KEY=...
# 添加新的 DNSPod Token 配置
DNSPOD_TOKEN=13490,6b5976c68aba5b14a0558b77c17c3932
```
### 步骤 3: 测试
```bash
cd /root/.openclaw/workspace/skills/DNSPod-Skill
# 测试 API 连接
python scripts/list_records.py --domain your-domain.com
# 测试部署记录
python scripts/deploy_record.py \
--domain your-domain.com \
--subdomain test \
--type A \
--value 1.2.3.4
```
## 📊 对比分析
| 特性 | 腾讯云 API 3.0 | DNSPod API 2.0 |
|------|---------------|---------------|
| **认证方式** | SecretId + SecretKey | DNSPod Token (ID,Token) |
| **签名算法** | TC3-HMAC-SHA256 | 无需签名 |
| **API 端点** | dnspod.tencentcloudapi.com | dnsapi.cn |
| **子账号支持** | ✅ 支持 | ❌ 仅主账号 |
| **CAM 权限** | ✅ 支持 | ❌ 不支持 |
| **调用复杂度** | 较复杂 (需要签名) | 简单 (直接传参) |
| **适用场景** | 企业级、多产品协同 | 个人、仅 DNS 管理 |
## ✅ 优势
### DNSPod API 2.0 的优势
1. **简单** - 无需复杂签名,直接传参
2. **快速** - API 调用更直接
3. **专注** - 专为 DNSPod 设计
4. **稳定** - 传统 API长期维护
### 腾讯云 API 3.0 的优势
1. **安全** - CAM 权限管理,支持子账号
2. **全面** - 可管理腾讯云全产品
3. **规范** - 统一的 API 标准
4. **生态** - 与腾讯云产品深度集成
## 🎯 选择建议
**使用 DNSPod API 2.0 (当前版本):**
- ✅ 个人或小微企业
- ✅ 仅管理 DNSPod DNS
- ✅ 追求简单快速
- ✅ 不需要子账号权限
**使用腾讯云 API 3.0:**
- ✅ 企业用户
- ✅ 需要子账号/CAM 权限
- ✅ 同时使用多个腾讯云服务
- ✅ 需要更全面的错误处理
## 📝 已更新的文件
-`scripts/deploy_record.py` - 重写为 DNSPod API 2.0
-`scripts/list_records.py` - 更新 API 调用
-`scripts/delete_record.py` - 更新 API 调用
-`scripts/batch_deploy.py` - 更新 API 调用
-`scripts/deploy_service.py` - 更新 API 调用
-`.env` - 更新配置模板
-`.env.example` - 更新配置示例
-`SKILL.md` - 更新文档
-`MIGRATION.md` - 本文档
## ⚠️ 注意事项
1. **Token 安全**
- Token 等同于密码,切勿泄露
- 不要提交到 Git 仓库
- 定期更换
2. **API 限制**
- 仅支持主账号
- 避免短时间内大量请求
- 设置正确的 UserAgent
3. **兼容性**
- 旧脚本不再兼容
- 需要更新所有调用方式
- 配置文件格式变更
## 🔗 相关文档
- [DNSPod API 文档](https://docs.dnspod.cn/api/)
- [DNSPod Token 管理](https://docs.dnspod.cn/account/5f2d466de8320f1a740d9ff3/)
- [API 开发规范](https://docs.dnspod.cn/api/api-development-specification/)
---
**迁移日期**: 2026-03-01
**版本**: 2.0
**API**: DNSPod API 2.0