Features: - Single record deployment (A/CNAME/MX/TXT records) - Batch deployment from JSON configuration - Quick service deployment (Web/API/CDN) - .env file support for secure credential management - Complete documentation with installation guide - Error handling and troubleshooting guide Scripts: - deploy_record.py - Single record management - batch_deploy.py - Batch deployment from config - deploy_service.py - Quick service templates - list_records.py - Query existing records - delete_record.py - Remove DNS records Documentation: - SKILL.md - Main skill documentation - INSTALL.md - Installation and quick start - ENV_SETUP.md - Environment configuration guide - README.md - Project overview - references/api-auth.md - API authentication details - references/common-errors.md - Error handling - examples/dns-config.json - Batch deployment example
78 lines
2.0 KiB
Python
Executable File
78 lines
2.0 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
DNS记录列表查询脚本
|
|
"""
|
|
import os
|
|
import sys
|
|
import json
|
|
|
|
from deploy_record import call_api, load_env
|
|
|
|
# 加载 .env
|
|
load_env()
|
|
|
|
def list_records(domain, record_type=None, subdomain=None):
|
|
"""查询DNS记录列表"""
|
|
params = {"Domain": domain}
|
|
|
|
if record_type:
|
|
params["RecordType"] = record_type
|
|
if subdomain:
|
|
params["Subdomain"] = subdomain
|
|
|
|
try:
|
|
result = call_api("DescribeRecordList", params)
|
|
records = result.get("Response", {}).get("RecordList", [])
|
|
|
|
if not records:
|
|
print(f"\n没有找到记录")
|
|
return []
|
|
|
|
print(f"\n{'='*80}")
|
|
print(f"DNS记录列表: {domain}")
|
|
print(f"{'='*80}\n")
|
|
|
|
# 表头
|
|
print(f"{'主机记录':<20} {'类型':<10} {'记录值':<30} {'线路':<10} {'TTL':<8} {'状态':<6}")
|
|
print(f"{'-'*80}")
|
|
|
|
# 记录列表
|
|
for record in records:
|
|
name = record.get("Name", "")
|
|
record_type = record.get("Type", "")
|
|
value = record.get("Value", "")
|
|
line = record.get("Line", "")
|
|
ttl = record.get("TTL", 0)
|
|
status = "启用" if record.get("Enabled", 1) == 1 else "禁用"
|
|
|
|
# 截断过长的值
|
|
if len(value) > 28:
|
|
value = value[:28] + ".."
|
|
|
|
print(f"{name:<20} {record_type:<10} {value:<30} {line:<10} {ttl:<8} {status:<6}")
|
|
|
|
print(f"{'-'*80}")
|
|
print(f"总计: {len(records)} 条记录\n")
|
|
|
|
return records
|
|
|
|
except Exception as e:
|
|
print(f"查询失败: {e}")
|
|
return []
|
|
|
|
def main():
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser(description='查询DNS记录列表')
|
|
|
|
parser.add_argument('--domain', required=True, help='域名(如: example.com)')
|
|
parser.add_argument('--type', help='筛选记录类型')
|
|
parser.add_argument('--subdomain', help='筛选子域名')
|
|
|
|
args = parser.parse_args()
|
|
|
|
list_records(args.domain, args.type, args.subdomain)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|