基于 Python + Docker 的腾讯云 EdgeOne 动态域名解析系统,提供现代化的 Web 管理界面,支持 IPv4/IPv6 双栈解析和自定义 Webhook 通知。
声明: 本项目由AI生成,很多内容没有经过人工校对,但是已测试,可以正常使用。
EdgeOne DDNS System ├── app.py # Flask 主应用程序和 Web API ├── config.py # 配置管理模块,支持动态配置 ├── edgeone_client.py # EdgeOne API 客户端,支持 A/AAAA 记录 ├── ip_detector.py # 公网IP检测模块,IPv4/IPv6 双栈支持 ├── notification.py # 自定义 Webhook 通知模块 ├── ddns_service.py # DDNS 服务核心模块,支持分离域名 ├── templates/ # Web 界面模板(Bootstrap 5) │ ├── index.html # 仪表板页面 │ ├── config.html # 配置管理页面 │ └── logs.html # 日志查看页面 ├── static/ # 静态资源文件 │ ├── css/ # 样式文件 │ └── js/ # JavaScript 文件 ├── logs/ # 日志文件目录 ├── config.json # 配置文件(可选,Web界面可自动创建) ├── docker-entrypoint.sh # Docker 容器入口脚本 ├── requirements.txt # Python 依赖 ├── Dockerfile # Docker 容器配置 ├── docker-compose.yml # Docker Compose 配置 └── README.md # 项目文档
services:
edgeone-ddns:
image: nixingshiguang/edgeone-ddns:latest
container_name: edgeone-ddns
volumes:
- ddns-config:/app/config
- ddns-logs:/app/logs
environment:
- PYTHONUNBUFFERED=1
- TZ=Asia/Shanghai
network_mode: host #需要解析ipv6的必须使用host模式
healthcheck:
test:
- CMD
- curl
- -f
- http://localhost:4646/api/status
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
volumes:
ddns-config:
driver: local
ddns-logs:
driver: local
git clone https://github.com/your-username/ddns-for-edgeone.git
cd ddns-for-edgeone
deploy.bat
git clone https://github.com/your-username/ddns-for-edgeone.git
cd ddns-for-edgeone
chmod +x deploy.sh
./deploy.sh
# 1. 构建镜像
docker build -t edgeone-ddns .
# 2. 运行容器(使用 Docker 托管卷)
docker run -d \
--name edgeone-ddns \
--network host \
-v ddns-config:/app/config \
-v ddns-logs:/app/logs \
--restart unless-stopped \
edgeone-ddns
# 3. 访问 Web 界面进行配置
# 浏览器打开:http://localhost:4646
# 注意:
# - 使用 Docker 托管卷自动管理配置和日志存储
# - 配置文件通过 Web 界面创建和保存
# - 无需手动挂载配置文件或担心权限问题
# 1. 克隆项目
git clone https://github.com/your-username/ddns-for-edgeone.git
cd ddns-for-edgeone
# 2. 创建虚拟环境
python -m venv venv
source venv/bin/activate # Linux/Mac
# 或
venv\Scripts\activate # Windows
# 3. 安装依赖
pip install -r requirements.txt
# 4. 创建日志目录
mkdir -p logs
# 5. 运行应用
python app.py
http://localhost:4646重要提示:
访问 http://localhost:4646/config 进行配置:
确保你的腾讯云 API 密钥具有以下 EdgeOne 权限:
GET /api/status # 返回: 当前IP、域名数量、最后更新时间等
GET /api/config # 获取当前配置 POST /api/config # 更新配置 POST /api/test_connectivity # 测试连接和权限
POST /api/manual_update # 手动触发DDNS更新 GET /api/last_ips # 获取上次记录的IP地址
POST /api/test_notification # 测试Webhook通知
GET /api/logs # 获取日志列表 DELETE /api/logs/clear # 清空日志文件
GET /api/detect_ip # 手动检测当前公网IP
{
"success": true,
"data": {
"current_ipv4": "203.0.113.1",
"current_ipv6": "2001:db8::1",
"last_update": "2024-11-29T10:30:00Z",
"total_domains": 5
},
"message": "操作成功"
}
cloud.tencent.com)本项目使用 Docker 托管卷(Docker Managed Volumes)来管理配置和日志数据:
volumes:
ddns-config: # 配置数据存储
driver: local
ddns-logs: # 日志数据存储
driver: local
# 使用环境变量存储敏感信息(推荐)
export TENCENT_SECRET_ID="your-secret-id"
export TENCENT_SECRET_KEY="your-secret-key"
# 查看容器日志
docker logs edgeone-ddns
# 查看容器状态
docker ps -a | grep edgeone-ddns
# 重新构建镜像(无缓存)
docker-compose build --no-cache
# 检查 Docker 托管卷
docker volume ls | grep ddns
# 查看托管卷详细信息
docker volume inspect ddns-config
docker volume inspect ddns-logs
# 如果遇到权限问题,重新创建托管卷
docker-compose down
docker volume rm ddns-config ddns-logs
docker-compose up -d
# 检查容器内权限
docker exec -it edgeone-ddns ls -la /app/
docker exec -it edgeone-ddns ls -la /app/config/
docker exec -it edgeone-ddn ls -la /app/logs/
# 检查Python版本
python --version # 需要 3.8+
# 检查端口占用
netstat -tlnp | grep 4646 # Linux
netstat -ano | findstr 4646 # Windows
# 检查依赖安装
pip list | grep flask
zone-xxxxxxxx# 测试 API 连通性
curl -I https://teo.tencentcloudapi.com/
# 测试 DNS 解析
nslookup teo.tencentcloudapi.com
系统内置11个IP检测服务,自动故障转移:
# 测试自定义端点
curl -4 "your-ipv4-endpoint"
curl -6 "your-ipv6-endpoint"
使用 Web 界面的 测试通知 功能:
钉钉机器人
{
"url": "https://oapi.dingtalk.com/robot/send?access_token=xxx",
"method": "POST",
"headers": {"Content-Type": "application/json"},
"body": {
"msgtype": "text",
"text": {"content": "DDNS更新: {ip_type}地址变更为{new_ip}"}
}
}
企业微信机器人
{
"url": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx",
"method": "POST",
"headers": {"Content-Type": "application/json"},
"body": {
"msgtype": "text",
"text": {"content": "DDNS更新通知\n类型: {ip_type}\n新IP: {new_ip}"}
}
}
# 检查系统状态
curl http://localhost:4646/api/status
# 测试手动更新
curl -X POST http://localhost:4646/api/manual_update
# 获取最新IP
curl http://localhost:4646/api/detect_ip
# 查看实时日志
tail -f logs/ddns.log
# 搜索错误日志
grep "ERROR" logs/ddns.log
# 统计更新记录
grep "DNS记录更新成功" logs/ddns.log | wc -l
我们欢迎所有形式的贡献!无论是 Bug 报告、功能建议还是代码提交。
enhancement 标签git clone https://github.com/your-username/ddns-for-edgeone.git
cd ddns-for-edgeone
git checkout -b feature/your-feature-name
git commit -m "feat: add your feature description"
git push origin feature/your-feature-name
本项目采用 MIT 许可证 - 允许自由使用、修改和分发。
感谢以下开源项目和服务:
如果这个项目对你有帮助,请给我们一个 ⭐ Star!
Made with ❤️ by Open Source Community