Files
ipv6-domain-router/README.md
T

86 lines
2.8 KiB
Markdown
Raw 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.
# IPv6 / 组网 / NPS 域名路由自动检测
Docker 化单页面应用:自动判断本机 IPv6 是否可用,可用则把域名解析到 IPv6;
否则判断组网(EasyTier)地址能否连通,能连通则解析到组网地址;再不行则走 NPS 内网穿透。
页面横排三栏(配置 | 状态+已连通 | 日志),自适应全屏、无滚动条。
## 功能
- 检测优先级:IPv6 → 组网(ping,无端口)→ NPS(reachable)
- 多域名支持:多个域名共用同一套服务商凭据
- DNS 服务商:Cloudflare / 腾讯云 DNSPod / 阿里云 / 华为云 / 自定义 Webhook
- TOKEN 访问鉴权:固定值,存于 `data/config.json` 的 `access_token`,永不轮换
- 日志落盘:`data/logs.jsonl`,只保留最近 24 小时,超期自动删除
- 检测间隔可配置(秒),检测全部线路
## 部署
```bash
cp config.example.json data/config.json
# 编辑 data/config.json 填入域名与服务商密钥
docker compose up -d --build
```
访问 http://服务器IP:8025/,输入 TOKEN(见 `data/config.json` 的 `access_token`,
或容器启动日志)登录;也支持 `?token=` 快捷登录。
### 方式一:docker run(单容器,不使用 compose)
```bash
docker pull gitea.88531.cn/jinghui/ipv6-domain-router:latest
docker run -d --name ipv6-domain-router --restart always --pid host \
-p 8025:8025 \
-v "$PWD/data:/data" \
-v /proc:/host/proc:ro \
-e TZ=Asia/Shanghai \
-e CONFIG_PATH=/data/config.json \
gitea.88531.cn/jinghui/ipv6-domain-router:latest
```
- 本地构建镜像:`docker build -t ipv6-domain-router:1.0 .`,再把镜像名换掉
- `--pid host` 与 `/proc` 挂载是探测本机网络所必需的,不能省
### 方式二:Docker Compose部署
完整 `docker-compose.yml`(与仓库根目录文件完全一致,含全部 ports / volumes / environment / command):
```yaml
services:
ipv6-router:
build: .
container_name: ipv6-domain-router
restart: always
pid: host
command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8025"]
ports:
- "8025:8025"
volumes:
- ./data:/data
- /proc:/host/proc:ro
environment:
- TZ=Asia/Shanghai
- CONFIG_PATH=/data/config.json
```
```bash
docker compose up -d --build # 首次构建并启动
docker compose up -d # 日常更新 / 重启
```
## 文件说明
| 文件 | 说明 |
| ---- | ---- |
| app.py | 后端(检测 / DNS 更新 / 鉴权 / 日志) |
| index.html | 前端单页面 |
| Dockerfile / docker-compose.yml | 容器化 |
| config.example.json | 配置模板(无密钥,可照抄) |
| data/ | 运行数据(config.json、logs.jsonl,**含密钥,不提交**) |
## 安全说明
- `data/` 目录(含 `config.json` 明文密钥与日志)已加入 `.gitignore`,绝不提交到仓库
- `/api/config` 接口不回传 `access_token`