Files
DNSPod-Skill/SKILL.md
panfd 47f090aa6f 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)
2026-03-01 16:37:38 +08:00

253 lines
5.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: tencent-dnspod
description: |
腾讯云 DNSPod 域名快速部署工具 (API 3.0)。用于自动化部署 DNS 记录、批量配置域名解析、快速上线服务。
当用户需要:(1) 快速添加 DNS 记录部署新服务,(2) 批量配置 A/CNAME/MX 等记录,
(3) 域名解析自动化管理,(4) DevOps 域名部署流程时触发。
---
# 腾讯云 DNSPod 域名快速部署
## 快速开始
### 1. 配置认证
获取 API 密钥https://console.cloud.tencent.com/cam/capi
**方式 1: 使用 .env 文件 (推荐,更安全):**
```bash
cp .env.example .env
# 编辑 .env 文件,填入你的密钥
```
**方式 2: 设置环境变量:**
```bash
export TENCENT_SECRET_ID="AKIDxxxxxxxxxxxxxxxx"
export TENCENT_SECRET_KEY="xxxxxxxxxxxxxxxx"
```
**获取密钥步骤:**
1. 访问https://console.cloud.tencent.com/cam/capi
2. 登录腾讯云控制台
3. 进入 **访问管理****访问密钥****API 密钥管理**
4. 点击 **新建密钥** 或查看现有密钥
5. 复制 SecretId 和 SecretKey
### 2. 核心命令
**添加单条记录 (最常用):**
```bash
python scripts/deploy_record.py \
--domain example.com \
--subdomain www \
--type A \
--value 1.2.3.4 \
--line "默认"
```
**批量部署 (从配置文件):**
```bash
python scripts/batch_deploy.py \
--domain example.com \
--config dns-config.json
```
**快速配置服务 (常用组合):**
```bash
python scripts/deploy_service.py \
--domain example.com \
--service web \
--ip 1.2.3.4
```
**删除记录:**
```bash
python scripts/delete_record.py \
--domain example.com \
--subdomain www
```
## 域名快速部署流程
### 场景 1: 部署新 Web 服务
```bash
# 一键部署 www 和主域名
python scripts/deploy_service.py \
--domain example.com \
--service web \
--ip 1.2.3.4
# 自动创建:
# - example.com (A 记录)
# - www.example.com (A 记录)
# - *.example.com (泛域名 A 记录,可选)
```
### 场景 2: 部署 API 服务
```bash
# 部署 API 子域名
python scripts/deploy_record.py \
--domain example.com \
--subdomain api \
--type A \
--value 1.2.3.4
# 或者使用服务模板
python scripts/deploy_service.py \
--domain example.com \
--service api \
--ip 1.2.3.4
```
### 场景 3: 域名验证 (TXT 记录)
```bash
# SSL 证书验证
python scripts/deploy_record.py \
--domain example.com \
--subdomain _dnsauth \
--type TXT \
--value "验证字符串"
```
### 场景 4: 邮件服务 (MX 记录)
```bash
# 添加 MX 记录
python scripts/deploy_record.py \
--domain example.com \
--subdomain @ \
--type MX \
--value "mxbiz1.qq.com" \
--line "默认"
```
## 支持的记录类型
- **A**: IPv4 地址记录
- **AAAA**: IPv6 地址记录
- **CNAME**: 别名记录
- **MX**: 邮件交换记录
- **TXT**: 文本记录 (常用于验证)
- **NS**: 域名服务器记录
- **SRV**: 服务定位记录
- **CAA**: 证书颁发机构授权
## 高级用法
### 强制更新现有记录
```bash
python scripts/deploy_record.py \
--domain example.com \
--subdomain www \
--type A \
--value 1.2.3.5 \
--force # 不询问直接更新
```
### 域名不存在时自动创建
```bash
python scripts/deploy_record.py \
--domain example.com \
--subdomain www \
--type A \
--value 1.2.3.4 \
--create-domain # 自动创建域名
```
### 自定义 TTL
```bash
python scripts/deploy_record.py \
--domain example.com \
--subdomain www \
--type A \
--value 1.2.3.4 \
--ttl 300 # 5 分钟
```
### 添加记录备注
```bash
python scripts/deploy_record.py \
--domain example.com \
--subdomain www \
--type A \
--value 1.2.3.4 \
--remark "生产环境 Web 服务器"
```
## 配置说明
### .env 文件配置
```bash
# 腾讯云 DNSPod API 密钥配置
# SecretId (以 AKID 开头)
TENCENT_SECRET_ID=AKIDxxxxxxxxxxxxxxxx
# SecretKey (32 位字符串)
TENCENT_SECRET_KEY=xxxxxxxxxxxxxxxx
```
### 环境变量
```bash
export TENCENT_SECRET_ID="AKIDxxxxxxxxxxxxxxxx"
export TENCENT_SECRET_KEY="xxxxxxxxxxxxxxxx"
```
## API 说明
本技能使用 **腾讯云 API 3.0**:
- API 端点:`dnspod.tencentcloudapi.com`
- API 版本:`2021-03-23`
- 认证方式TC3-HMAC-SHA256 签名
- 文档https://cloud.tencent.com/document/product/1427
**优势:**
- ✅ CAM 权限管理,支持子账号
- ✅ 与腾讯云产品深度集成
- ✅ 全面的错误码和 SDK 支持
- ✅ 性能优化,全球部署
**签名方法:**
- 算法TC3-HMAC-SHA256
- 文档https://cloud.tencent.com/document/product/1427/56189
## 安全提示
⚠️ **API 密钥等同于密码,请妥善保管!**
- 不要将密钥提交到 Git 仓库
- 不要将密钥分享给他人
- 定期更换密钥
- 如已泄露,立即禁用并重新创建
## 常见问题
### Q: 密钥格式错误?
A: SecretId 应该以 `AKID` 开头,约 20 位SecretKey 是 32 位字符串
### Q: 提示"域名不存在"
A: 使用 `--create-domain` 参数自动创建域名,或先在控制台添加域名
### Q: 如何查看现有记录?
A: 使用 `list_records.py` 脚本:
```bash
python scripts/list_records.py --domain example.com
```
### Q: 支持哪些记录类型?
A: 支持 A、AAAA、CNAME、MX、TXT、NS、SRV、CAA 等常见类型
## 相关文档
- [腾讯云 API 3.0 文档](https://cloud.tencent.com/document/product/1427)
- [签名方法 v3](https://cloud.tencent.com/document/product/1427/56189)
- [API 密钥管理](https://console.cloud.tencent.com/cam/capi)
- [API Explorer](https://console.cloud.tencent.com/api/explorer)
---
**版本**: 3.0 (使用腾讯云 API 3.0)
**更新**: 2026-03-01
**API**: 腾讯云 API 3.0 (TC3-HMAC-SHA256)