Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a4e417b28 | ||
|
|
65001d1eff | ||
|
|
4d2273c885 | ||
|
|
a837f38c8f | ||
|
|
5f202a3a2b | ||
|
|
df9f7857ed | ||
|
|
61788fa7ae | ||
|
|
c9d1f21fa7 | ||
|
|
fbf5c9e3b0 | ||
|
|
af0b5e1ea0 | ||
|
|
4d608a6697 | ||
|
|
afd9df87c1 | ||
|
|
4987cea8e0 | ||
|
|
0dce0fef14 | ||
|
|
fac8be622c | ||
|
|
8ae615d0e3 | ||
|
|
f8482414e4 | ||
|
|
05093190b9 | ||
|
|
7debff02fe | ||
|
|
25a46b8e13 | ||
|
|
0bbaf443e1 | ||
|
|
f82731eb77 | ||
|
|
8f57649832 | ||
|
|
b72136a461 | ||
|
|
2a65abb8c3 | ||
|
|
4c0f29918c | ||
|
|
5de97082aa | ||
|
|
8b094bcb36 | ||
|
|
62b80d06dc | ||
|
|
81a61c0836 | ||
|
|
cee22230ea | ||
|
|
2947ad2125 | ||
|
|
1235ccffbd | ||
|
|
d688e9bb8e | ||
|
|
805b65bc07 | ||
|
|
682983e411 | ||
|
|
4abe6e4d1a | ||
|
|
19fe134762 | ||
|
|
5445b4df64 | ||
|
|
4f6cf7fac7 | ||
|
|
243060a32a | ||
|
|
924b9bcc36 | ||
|
|
611caa30f6 | ||
|
|
a8f7f2bd17 | ||
|
|
ff5caddab3 | ||
|
|
a00e42a896 | ||
|
|
165caa9127 | ||
|
|
031c1e8b69 | ||
|
|
bb02b0c5bd | ||
|
|
e7365e3005 | ||
|
|
1b0f2646fe | ||
|
|
31d725ff84 | ||
|
|
21fa445ff8 | ||
|
|
e7cccfbd99 | ||
|
|
f12c97cf8b | ||
|
|
cc8690d264 | ||
|
|
b705dbdc18 | ||
|
|
862717a47e | ||
|
|
88984719c5 | ||
|
|
684292de76 | ||
|
|
293157b3f8 | ||
|
|
d6fdf67bc9 | ||
|
|
3449babbe0 | ||
|
|
ba0286bd07 | ||
|
|
e3d5eb0200 | ||
|
|
25a8d7a651 | ||
|
|
dbaf6a0da9 | ||
|
|
f44da9a467 |
No files matched your search
@@ -1,6 +1,11 @@
|
||||
name: Build and Release
|
||||
|
||||
|
||||
# 并行构建:原来 8 个 Build step 串行跑在一个 job 里,现在拆成 8 个矩阵任务同时跑
|
||||
# (2 个程序 × 4 个目标系统),构建完各自上传 artifact,最后统一发 Release。
|
||||
#
|
||||
# 元数据(VERSION / COMMIT / BUILD_TIME)由 meta job 算一次分发下去:
|
||||
# 若放到每个矩阵任务里各算一遍,BUILD_TIME 会互不相同,同一个 Release 里的
|
||||
# 二进制时间戳就对不上了。
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
@@ -8,95 +13,131 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-release:
|
||||
# 只负责算版本元数据,秒级完成,不产出 artifact
|
||||
meta:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
ldflags: ${{ steps.meta.outputs.ldflags }}
|
||||
steps:
|
||||
- name: Compute version metadata
|
||||
id: meta
|
||||
run: |
|
||||
echo "ldflags=-X main.VERSION=${GITHUB_REF_NAME} -X main.COMMIT=${GITHUB_SHA} -X main.BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
needs: meta
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
# 一个目标挂了不影响其余目标,全部跑完再统一看结果
|
||||
fail-fast: false
|
||||
# 纯 include 模式:每条自带全部字段、各自独立成一个任务。
|
||||
# 不要把 app 写成顶层数组再和 os 组合——GitHub 会把能匹配现有组合的
|
||||
# include 条目合并进组合本身,任务数被折叠(docker.yml 里踩过,见 v3.3.0 事故)
|
||||
matrix:
|
||||
include:
|
||||
- app: lemonipw
|
||||
dir: src
|
||||
os: linux
|
||||
- app: lemonipw
|
||||
dir: src
|
||||
os: windows
|
||||
- app: lemonipw
|
||||
dir: src
|
||||
os: darwin
|
||||
- app: lemonipw
|
||||
dir: src
|
||||
os: freebsd
|
||||
- app: middleware-go
|
||||
dir: middleware-go
|
||||
os: linux
|
||||
- app: middleware-go
|
||||
dir: middleware-go
|
||||
os: windows
|
||||
- app: middleware-go
|
||||
dir: middleware-go
|
||||
os: darwin
|
||||
- app: middleware-go
|
||||
dir: middleware-go
|
||||
os: freebsd
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
# v4 基于 Node 16,GitHub 已不再支持该运行时(actionlint 会报 runner too old)
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.26.6' # 与 src/go.mod 声明保持一致,避免依赖 GOTOOLCHAIN 隐式下载
|
||||
- name: Set version metadata
|
||||
run: |
|
||||
echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
|
||||
echo "COMMIT=${GITHUB_SHA}" >> $GITHUB_ENV
|
||||
echo "BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
|
||||
|
||||
- name: Build for Linux
|
||||
working-directory: src
|
||||
# 产物统一写到仓库根目录(working-directory 的上一级),命名规则与原串行版完全一致
|
||||
- name: Build ${{ matrix.app }} for ${{ matrix.os }}
|
||||
working-directory: ${{ matrix.dir }}
|
||||
env:
|
||||
APP: ${{ matrix.app }}
|
||||
LDFLAGS: ${{ needs.meta.outputs.ldflags }}
|
||||
run: |
|
||||
LDFLAGS="-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.BUILD_TIME=${BUILD_TIME}"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$LDFLAGS" -o ../lemonipw-linux-386
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o ../lemonipw-linux-amd64
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$LDFLAGS" -o ../lemonipw-linux-arm64
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "$LDFLAGS" -o ../lemonipw-linux-armv7
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "$LDFLAGS" -o ../lemonipw-linux-armv6
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=loong64 go build -ldflags "$LDFLAGS" -o ../lemonipw-linux-loong64
|
||||
- name: Build for Windows
|
||||
working-directory: src
|
||||
run: |
|
||||
LDFLAGS="-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.BUILD_TIME=${BUILD_TIME}"
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "$LDFLAGS" -o ../lemonipw-windows-386.exe
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$LDFLAGS" -o ../lemonipw-windows-amd64.exe
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags "$LDFLAGS" -o ../lemonipw-windows-arm64.exe
|
||||
- name: Build for macOS
|
||||
working-directory: src
|
||||
run: |
|
||||
LDFLAGS="-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.BUILD_TIME=${BUILD_TIME}"
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$LDFLAGS" -o ../lemonipw-darwin-amd64
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "$LDFLAGS" -o ../lemonipw-darwin-arm64
|
||||
- name: Build for FreeBSD
|
||||
working-directory: src
|
||||
run: |
|
||||
LDFLAGS="-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.BUILD_TIME=${BUILD_TIME}"
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "$LDFLAGS" -o ../lemonipw-freebsd-386
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "$LDFLAGS" -o ../lemonipw-freebsd-amd64
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -ldflags "$LDFLAGS" -o ../lemonipw-freebsd-arm64
|
||||
- name: Build middleware-go for Linux
|
||||
working-directory: middleware-go
|
||||
run: |
|
||||
LDFLAGS="-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.BUILD_TIME=${BUILD_TIME}"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$LDFLAGS" -o ../middleware-go-linux-386
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o ../middleware-go-linux-amd64
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$LDFLAGS" -o ../middleware-go-linux-arm64
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "$LDFLAGS" -o ../middleware-go-linux-armv7
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "$LDFLAGS" -o ../middleware-go-linux-armv6
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=loong64 go build -ldflags "$LDFLAGS" -o ../middleware-go-linux-loong64
|
||||
- name: Build middleware-go for Windows
|
||||
working-directory: middleware-go
|
||||
run: |
|
||||
LDFLAGS="-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.BUILD_TIME=${BUILD_TIME}"
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "$LDFLAGS" -o ../middleware-go-windows-386.exe
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$LDFLAGS" -o ../middleware-go-windows-amd64.exe
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags "$LDFLAGS" -o ../middleware-go-windows-arm64.exe
|
||||
- name: Build middleware-go for macOS
|
||||
working-directory: middleware-go
|
||||
run: |
|
||||
LDFLAGS="-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.BUILD_TIME=${BUILD_TIME}"
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$LDFLAGS" -o ../middleware-go-darwin-amd64
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "$LDFLAGS" -o ../middleware-go-darwin-arm64
|
||||
- name: Build middleware-go for FreeBSD
|
||||
working-directory: middleware-go
|
||||
run: |
|
||||
LDFLAGS="-X main.VERSION=${VERSION} -X main.COMMIT=${COMMIT} -X main.BUILD_TIME=${BUILD_TIME}"
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "$LDFLAGS" -o ../middleware-go-freebsd-386
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "$LDFLAGS" -o ../middleware-go-freebsd-amd64
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -ldflags "$LDFLAGS" -o ../middleware-go-freebsd-arm64
|
||||
set -euo pipefail
|
||||
case "${{ matrix.os }}" in
|
||||
linux)
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags "$LDFLAGS" -o "../${APP}-linux-386"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o "../${APP}-linux-amd64"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags "$LDFLAGS" -o "../${APP}-linux-arm64"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags "$LDFLAGS" -o "../${APP}-linux-armv7"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go build -ldflags "$LDFLAGS" -o "../${APP}-linux-armv6"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=loong64 go build -ldflags "$LDFLAGS" -o "../${APP}-linux-loong64"
|
||||
;;
|
||||
windows)
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags "$LDFLAGS" -o "../${APP}-windows-386.exe"
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$LDFLAGS" -o "../${APP}-windows-amd64.exe"
|
||||
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -ldflags "$LDFLAGS" -o "../${APP}-windows-arm64.exe"
|
||||
;;
|
||||
darwin)
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$LDFLAGS" -o "../${APP}-darwin-amd64"
|
||||
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "$LDFLAGS" -o "../${APP}-darwin-arm64"
|
||||
;;
|
||||
freebsd)
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags "$LDFLAGS" -o "../${APP}-freebsd-386"
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags "$LDFLAGS" -o "../${APP}-freebsd-amd64"
|
||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm64 go build -ldflags "$LDFLAGS" -o "../${APP}-freebsd-arm64"
|
||||
;;
|
||||
esac
|
||||
|
||||
- name: Upload ${{ matrix.app }}-${{ matrix.os }}
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.app }}-${{ matrix.os }}
|
||||
# 只捞本任务自己产出的二进制;middleware-go/ 目录名不带连字符,不会误匹配
|
||||
path: ${{ matrix.app }}-*
|
||||
if-no-files-found: error
|
||||
|
||||
# 只在打 tag 时发 Release;workflow_dispatch 手动跑则只构建、可从 run 页面下载 artifact
|
||||
release:
|
||||
needs: build
|
||||
if: github.ref_type == 'tag'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download all build artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
path: dist
|
||||
merge-multiple: true
|
||||
|
||||
- name: Prepare config files for release
|
||||
run: |
|
||||
# 后端:发布 src/ 下的 setting.json.example;中间件:只发布 setting.json.example
|
||||
cp src/setting.json.example setting.json.example
|
||||
cp middleware-go/setting.json.example middleware.setting.json.example
|
||||
cp src/setting.json.example dist/setting.json.example
|
||||
cp middleware-go/setting.json.example dist/middleware.setting.json.example
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v3
|
||||
if: github.ref_type == 'tag'
|
||||
with:
|
||||
name: Release ${{ github.ref_name }}
|
||||
tag_name: ${{ github.ref_name }}
|
||||
token: ${{ secrets.MINT_TOKEN }}
|
||||
|
||||
|
||||
generate_release_notes: true
|
||||
body: |
|
||||
## 配置文件说明
|
||||
@@ -116,34 +157,4 @@ jobs:
|
||||
cp middleware.setting.json.example middleware-go/setting.json
|
||||
```
|
||||
|
||||
files: |
|
||||
lemonipw-linux-386
|
||||
lemonipw-linux-amd64
|
||||
lemonipw-linux-arm64
|
||||
lemonipw-linux-armv7
|
||||
lemonipw-linux-armv6
|
||||
lemonipw-linux-loong64
|
||||
lemonipw-windows-386.exe
|
||||
lemonipw-windows-amd64.exe
|
||||
lemonipw-windows-arm64.exe
|
||||
lemonipw-darwin-amd64
|
||||
lemonipw-darwin-arm64
|
||||
lemonipw-freebsd-386
|
||||
lemonipw-freebsd-amd64
|
||||
lemonipw-freebsd-arm64
|
||||
middleware-go-linux-386
|
||||
middleware-go-linux-amd64
|
||||
middleware-go-linux-arm64
|
||||
middleware-go-linux-armv7
|
||||
middleware-go-linux-armv6
|
||||
middleware-go-linux-loong64
|
||||
middleware-go-windows-386.exe
|
||||
middleware-go-windows-amd64.exe
|
||||
middleware-go-windows-arm64.exe
|
||||
middleware-go-darwin-amd64
|
||||
middleware-go-darwin-arm64
|
||||
middleware-go-freebsd-386
|
||||
middleware-go-freebsd-amd64
|
||||
middleware-go-freebsd-arm64
|
||||
setting.json.example
|
||||
middleware.setting.json.example
|
||||
files: dist/*
|
||||
@@ -1,11 +1,15 @@
|
||||
name: Build and Deploy to Cloudflare Workers
|
||||
name: (已停用自动部署) frontend-ssr → Cloudflare Workers
|
||||
|
||||
# 前端已迁移到 frontend-svelte(SvelteKit + shadcn-svelte,包管理器 bun),
|
||||
# 自动部署改由 .github/workflows/frontend-svelte.yml 负责。
|
||||
#
|
||||
# 这里**刻意去掉 push 触发**:两个 workflow 都部署同名 Worker(wrangler.jsonc 里的 "ipw-cn"),
|
||||
# 若继续按 push 触发,改 frontend-ssr 会把新前端的线上版本覆盖掉。
|
||||
# 保留 workflow_dispatch 只是为了万一还需要临时用旧站顶一下(手动触发)。
|
||||
# 新前端确认稳定后,这个文件可以直接删除。
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
paths:
|
||||
- 'frontend-ssr/**'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -31,4 +35,13 @@ jobs:
|
||||
run: |
|
||||
cd frontend-ssr
|
||||
pnpm install
|
||||
pnpm run deploy --keep-vars
|
||||
pnpm run deploy --keep-vars
|
||||
|
||||
# 部署成功后把 sitemap 全量提交给 IndexNow(Bing/Yandex/Seznam 等共用端点),
|
||||
# 新页面/新文档以天级收录代替等爬虫回访。
|
||||
# key 是公开所有权凭证(对应 frontend-ssr/public/<key>.txt,IndexNow 靠抓取它验证)。
|
||||
- name: Submit sitemap to IndexNow
|
||||
if: success()
|
||||
run: |
|
||||
cd frontend-ssr
|
||||
node scripts/indexnow-submit.mjs --site https://nipw.cn --key d49c90fb2fb160cdd2cd4b09532bc380
|
||||
@@ -0,0 +1,33 @@
|
||||
name: Build and Deploy frontend-svelte to Cloudflare Workers
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ['main']
|
||||
paths:
|
||||
- 'frontend-svelte/**'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# 包管理器是 bun(见 frontend-svelte/bun.lock),不再用 pnpm/npm
|
||||
- name: Setup bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
# 部署到 Cloudflare Workers
|
||||
# --keep-vars:保留 Worker 上已配置的环境变量(如 API_KEYS),别被本次部署清掉
|
||||
- name: Deploy to Cloudflare Workers
|
||||
env:
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
run: |
|
||||
cd frontend-svelte
|
||||
bun install --frozen-lockfile
|
||||
bun run build
|
||||
bunx wrangler deploy --keep-vars
|
||||
@@ -25,3 +25,11 @@ docs/.vitepress/*.timestamp-*
|
||||
tmp/
|
||||
setting.json
|
||||
*.BIN
|
||||
|
||||
# 本地调试脚本与实测产物(不入库,与 ipw-boce 的约定一致)
|
||||
tmp-smoke/
|
||||
|
||||
# Agent 工具产物(本机技能安装/会话状态,不入库)
|
||||
.agents/
|
||||
.zcode/
|
||||
skills-lock.json
|
||||
@@ -0,0 +1,41 @@
|
||||
# Changelog
|
||||
|
||||
本文件记录面向用户/运维的版本变更。格式参照 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循语义化版本(SemVer)。
|
||||
|
||||
## [v4.2.0] - 2026-10-25
|
||||
|
||||
> DNSSEC 从不可用变为可用、请求级解析能力同步 EO 特供、全站文档图灯箱、SEO 与部署链路整体升级。
|
||||
|
||||
### ✨ 新功能
|
||||
|
||||
- **DNSSEC 验证重写**:默认解析器内置境外 DO 友好列表(1.1.1.1 / 8.8.8.8 等,IPv4/IPv6 双栈 14 地址);新增 DNSKEY 自验签(TLD 与无 A 记录域名可验);DS 与 A 并行查询;解析器不支持 DNSSEC 时给出配置提示
|
||||
- **SSL 检查新增 SAN 字段**:返回证书全部主体别名(DNS + IP)
|
||||
- **IndexNow 接入**:key 静态文件 + 提交端点(GET 全量 / POST 增量)+ 部署后自动向 Bing/Yandex 提交 sitemap
|
||||
- **文档图灯箱**:全站文档图片点击放大(el-image-viewer),支持多图切换、滚轮缩放、旋转、Esc 关闭、路由切换自动关闭
|
||||
- **高级选项输入规整**:DNS 服务器填纯域名自动补全为 `https://域名/dns-query`,缺 scheme/路径/端口的写法自动补齐
|
||||
- **EO 特供获得请求级解析**:`dns=` / `dns4=` / `dns6=` / `resolve=` 全套参数与主线对齐,DialContext DNS 接管 + SSRF 预检同源
|
||||
- **ipdb 后台初始化**:首次启动不再被 450MB 下载阻塞,服务降级运行、库就绪一个上线一个
|
||||
- **DNSSEC 原理文档**:/dnssec 页新增原理介绍、验证链图(OpenAI 风)与字段说明
|
||||
|
||||
### 🛠 修复
|
||||
|
||||
- **DNSSEC「一直用不了」**:国内公共解析器带 DO 位也不返回 RRSIG(根因,实测 6 家);TLD/无 A 记录域没有验签路径;DS 只在失败路径查询——三项全修
|
||||
- **构建 EBUSY 静默失败**:运行中的服务锁住 `.output` 导致产物不更新,`.gitignore` 同步补齐 agent 工具目录
|
||||
- **内置中间件**:h3 不解码路径 `%2F`,带协议头的拨测目标经兜底转发必然拼坏——已与 fiber 语义对齐
|
||||
- **/ipv6 空壳页**:改为服务端 301(消除无 h1/无 title 的低质量页)
|
||||
- **sitemap**:全站显式枚举 + 权重标注
|
||||
- whois 摘除自定义解析后回归系统解析器;EO 同步
|
||||
|
||||
### ⚡ 优化(ipdb)
|
||||
|
||||
- 条件下载(ETag/Last-Modified):日更不再全量重拉 450MB
|
||||
- 单文件下载超时 60s → 10 分钟(大文件慢链路不再必然失败)
|
||||
- bilibili 并行查询 + 负缓存 + singleflight(/v1/location 首查 292ms → 复查 1.7ms)
|
||||
- 数据库加载器原子换指针:日更重载零服务真空窗
|
||||
|
||||
### ⚠️ 行为变化
|
||||
|
||||
- `/v1/whois` 不再接受 `dns=` 参数(静默忽略)
|
||||
- `/ipv6` 改为服务端 301 到 `/location`
|
||||
- DNSSEC 默认走境外解析器:网络屏蔽/劫持这些 UDP 53 时需配置 `dnssec-server`
|
||||
- 部署/构建前需停掉 3000/4000 端口的服务进程(EBUSY 会静默失败,本次已验证此坑)
|
||||
@@ -21,6 +21,39 @@ curl -fsSL https://raw.githubusercontent.com/nomdn/ipw-cn/main/install.sh -o ins
|
||||
- [节点 API 与协议](docs/guide/node-api.md)(业务接口、管理接口、WS 协议、上报协议)
|
||||
- [公开 API(/api/v1)](docs/guide/public-api.md)(收集中心程序化接口:鉴权、端点与响应示例、公开状态接口)
|
||||
|
||||
## 贡献节点
|
||||
|
||||
把一台闲置的 Linux 机器(VPS、软路由、小主机)贡献为公共拨测节点:
|
||||
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/nomdn/ipw-cn/main/contribute.sh -o contribute.sh && sudo bash contribute.sh
|
||||
```
|
||||
|
||||
脚本静默完成全部步骤,中途无需任何交互:
|
||||
|
||||
- 自动挑选一个空闲高位端口(20000-65000),节点标识(节点 id / 注册 key / access-token)随机生成
|
||||
- 默认以 WS 方式**同时接入官方两个中间件**(多活,节点主动出站连接,无需公网放行端口)
|
||||
- 安装到 `/opt/lemon-ipw`,注册为 systemd 服务 `lemon-ipw` 并设置开机自启
|
||||
- 结束时打印节点信息(同时备份在 `/opt/lemon-ipw/node-info.txt`)
|
||||
|
||||
把打印出来的信息发给管理员登记,节点即可上线(联系方式见文末)。
|
||||
|
||||
| 选项 | 说明 |
|
||||
| --- | --- |
|
||||
| `--ipdb` | 启用 IP 数据库(首次启动后台下载约 450MB,默认关闭) |
|
||||
| `--port <n>` | 指定监听端口(默认随机空闲端口) |
|
||||
| `--ws-url <url>` | 改为接入自建中间件,逗号分隔可填多个(默认官方两个) |
|
||||
| `--version <tag>` | 指定版本(默认取 GitHub 最新 release) |
|
||||
| `--gh-proxy <p>` | GitHub 下载加速前缀,如 `https://ghfast.top/` |
|
||||
| `--dry-run` | 只检查环境并打印信息,不下载、不写 systemd |
|
||||
|
||||
日常运维:
|
||||
|
||||
```bash
|
||||
systemctl status lemon-ipw # 查看状态
|
||||
journalctl -u lemon-ipw -f # 跟踪日志
|
||||
```
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
@@ -30,7 +63,8 @@ ipw-cn/
|
||||
├── serverless/ # 独立组件 边缘/Serverless(edgeone、edgeone-getip、lemon-getip)
|
||||
├── frontend-ssr/ # Nuxt 4 SSR 前端
|
||||
├── docs/ # 文档站
|
||||
└── install.sh # 一键安装脚本
|
||||
├── install.sh # 一键安装脚本(自建完整部署)
|
||||
└── contribute.sh # 贡献节点脚本(一台闲置机器接为公共节点)
|
||||
```
|
||||
## 友情链接
|
||||
### 来自社区的IPW版本
|
||||
@@ -49,6 +83,12 @@ ipw-cn/
|
||||
| DNS 查询 | miekg/dns(DoH / UDP 双通道 + 主从 failover) |
|
||||
| 部署 | Docker、Cloudflare Workers、EdgeOne Pages、systemd |
|
||||
|
||||
## 联系方式
|
||||
|
||||
- 邮箱:[iduhih777@outlook.com](mailto:iduhih777@outlook.com)
|
||||
- GitHub:[@nomdn](https://github.com/nomdn)
|
||||
- 站点:[nipw.cn](https://nipw.cn) | 拨测控制台:[boce.wsmdn.top](https://boce.wsmdn.top)
|
||||
|
||||
## 许可证
|
||||
|
||||
[GPL-3.0](LICENSE)
|
||||
@@ -0,0 +1,541 @@
|
||||
#!/usr/bin/bash
|
||||
# ============================================================
|
||||
# 节点贡献脚本(静默安装)
|
||||
#
|
||||
# 用途:把一台闲置 Linux 机器贡献为拨测节点。
|
||||
# - 全程无交互:端口自动挑一个空闲高位端口,节点标识随机生成
|
||||
# - 命名与官方 install.sh 保持一致:二进制 lemonipw / 目录 /opt/lemon-ipw / 服务 lemon-ipw
|
||||
# - 默认同时接入柠檬的两个中间件 WS 通道(多活,节点主动出站,无需公网放行端口)
|
||||
# - 安装完成后打印节点信息,提交给管理员登记即可上线
|
||||
#
|
||||
# 用法:
|
||||
# sudo bash contribute.sh # 全默认:系统级安装 + 自动端口 + 接 WS
|
||||
# sudo bash contribute.sh --ipdb # 启用 IP 数据库(首启后台下载 ~450MB)
|
||||
# sudo bash contribute.sh --port 34567 # 指定端口
|
||||
# bash contribute.sh # 非 root:自动装成 systemd --user 用户级服务(不询问)
|
||||
# bash contribute.sh --user # 显式指定用户级(与上面的自动降级等价)
|
||||
# sudo bash contribute.sh --dry-run # 只生成并打印信息,不下载、不落盘
|
||||
# ============================================================
|
||||
|
||||
set -e
|
||||
|
||||
# 默认同时接入的两个中间件(逗号分隔 = 节点侧同时连接全部、多活;
|
||||
# 任一断开只重连自己,不影响另一条连接)。顺序无关,收集中心放前面便于阅读。
|
||||
WS_URL_DEFAULT="wss://boce-api.api-ipw.wsmdn.top/ws,wss://middleware-1.api-ipw.wsmdn.top/ws"
|
||||
CONTACT_EMAIL="iduhih777@outlook.com"
|
||||
PORT_MIN=20000
|
||||
PORT_MAX=65000
|
||||
|
||||
OPT_PORT=""
|
||||
OPT_WS_URL=""
|
||||
OPT_VERSION=""
|
||||
OPT_GH_PROXY=""
|
||||
OPT_IPDB="false"
|
||||
OPT_SCOPE=""
|
||||
DRY_RUN="false"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
用法: sudo bash contribute.sh [选项]
|
||||
|
||||
--port <n> 监听端口(默认:20000-65000 中的随机空闲端口)
|
||||
--ws-url <url> 中间件 WS 地址,逗号分隔可多个(默认:柠檬两个中间件,同时连接)
|
||||
--version <tag> 指定版本(默认:取 GitHub 最新 release)
|
||||
--gh-proxy <p> GitHub 下载加速前缀,如 https://ghfast.top/
|
||||
--ipdb 启用 IP 数据库(首次启动后台下载,约 450MB;默认关闭)
|
||||
--user 用户级安装(systemd --user,unit 写 ~/.config/systemd/user,无需 root)
|
||||
--system 系统级安装(unit 写 /etc/systemd/system,需 root;非 root 下指定会直接报错)
|
||||
--dry-run 只做检查与信息生成,不下载、不写 systemd
|
||||
-h, --help 显示本帮助
|
||||
EOF
|
||||
}
|
||||
|
||||
# ---------- 参数解析 ----------
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
key="$1"
|
||||
case "$key" in
|
||||
--ipdb) OPT_IPDB="true"; shift; continue ;;
|
||||
--user) OPT_SCOPE="user"; shift; continue ;;
|
||||
--system) OPT_SCOPE="system"; shift; continue ;;
|
||||
--dry-run) DRY_RUN="true"; shift; continue ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
--port|--ws-url|--version|--gh-proxy) ;;
|
||||
*) echo "错误:未知参数 $key(用 --help 查看用法)" >&2; exit 1 ;;
|
||||
esac
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "错误:$key 缺少参数值(用 --help 查看用法)" >&2
|
||||
exit 1
|
||||
fi
|
||||
case "$key" in
|
||||
--port) OPT_PORT="$2" ;;
|
||||
--ws-url) OPT_WS_URL="$2" ;;
|
||||
--version) OPT_VERSION="$2" ;;
|
||||
--gh-proxy) OPT_GH_PROXY="$2" ;;
|
||||
esac
|
||||
shift 2
|
||||
done
|
||||
|
||||
# ---------- 随机值生成 ----------
|
||||
|
||||
# 生成 UUID(优先 /proc,其次 uuidgen,最后 /dev/urandom)
|
||||
gen_uuid() {
|
||||
if [ -r /proc/sys/kernel/random/uuid ]; then
|
||||
cat /proc/sys/kernel/random/uuid
|
||||
elif command -v uuidgen >/dev/null 2>&1; then
|
||||
uuidgen | tr 'A-Z' 'a-z'
|
||||
else
|
||||
od -An -N16 -tx1 /dev/urandom | tr -d ' \n' \
|
||||
| sed 's/\(........\)\(....\)\(....\)\(....\)\(............\)/\1-\2-\3-\4-\5/'
|
||||
fi
|
||||
}
|
||||
|
||||
# 32 位十六进制令牌(去横线的 UUID)
|
||||
gen_token() { gen_uuid | tr -d '-'; }
|
||||
|
||||
# ---------- 端口 ----------
|
||||
|
||||
# 列出本机监听端口(ss 优先,netstat 次之)
|
||||
listening_ports() {
|
||||
if command -v ss >/dev/null 2>&1; then
|
||||
ss -ltn 2>/dev/null | awk 'NR>1 {print $4}'
|
||||
elif command -v netstat >/dev/null 2>&1; then
|
||||
netstat -ltn 2>/dev/null | awk 'NR>2 {print $4}'
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# 0 = 端口已被占用,1 = 空闲
|
||||
port_in_use() {
|
||||
local p="$1" ports
|
||||
ports=$(listening_ports || true)
|
||||
if [ -n "$ports" ]; then
|
||||
if printf '%s\n' "$ports" | sed 's/.*[.:]//' | grep -qx "$p"; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
fi
|
||||
# 兜底:连得上即视为被占用(无 ss / netstat 的极简系统)
|
||||
if (exec 3<>"/dev/tcp/127.0.0.1/$p") 2>/dev/null; then
|
||||
exec 3>&-
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# 随机高位端口(20000-65000),连续试探直到落到空闲端口
|
||||
pick_port() {
|
||||
local i p
|
||||
for i in $(seq 1 50); do
|
||||
p=$(( (RANDOM * 32768 + RANDOM) % (PORT_MAX - PORT_MIN + 1) + PORT_MIN ))
|
||||
if ! port_in_use "$p"; then
|
||||
printf '%s' "$p"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
echo "错误:连续 50 次未找到空闲的高位端口,请用 --port 指定" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# ---------- 权限与 systemd 作用域 ----------
|
||||
|
||||
# system = 系统级:写 /etc/systemd/system,开机自启走 multi-user.target(需 root)
|
||||
# user = 用户级:写 ~/.config/systemd/user,开机自启走 default.target(systemd --user)
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
case "$OPT_SCOPE" in
|
||||
system)
|
||||
# dry-run 只在本地打印信息,不落盘,不必真有 root
|
||||
if [ "$DRY_RUN" != "true" ]; then
|
||||
echo "错误:--system 需要 root 权限(写 /etc/systemd/system),请用 sudo 运行或改用 --user" >&2
|
||||
exit 1
|
||||
fi
|
||||
SYSTEMD_MODE="system"
|
||||
;;
|
||||
user)
|
||||
SYSTEMD_MODE="user"
|
||||
;;
|
||||
*)
|
||||
# 非 root 且未指定作用域:本脚本定位是"静默安装",直接降为用户级,不打断询问
|
||||
SYSTEMD_MODE="user"
|
||||
echo "提示:当前不是 root 环境,自动改用 systemd --user(用户级服务,仅对当前用户生效)。" >&2
|
||||
echo " 如需系统级安装,请用 sudo 重新运行。" >&2
|
||||
;;
|
||||
esac
|
||||
else
|
||||
SYSTEMD_MODE="system"
|
||||
if [ "$OPT_SCOPE" = "user" ]; then
|
||||
SYSTEMD_MODE="user"
|
||||
echo "提示:以 root 身份使用 --user,unit 会写到 root 的用户级目录(~/.config/systemd/user)" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# ---------- 环境检查 ----------
|
||||
|
||||
if [ "$DRY_RUN" != "true" ]; then
|
||||
if ! command -v systemctl >/dev/null 2>&1; then
|
||||
echo "错误:未检测到 systemd(systemctl 不存在),无法创建守护进程" >&2
|
||||
exit 1
|
||||
fi
|
||||
# 用户级实例依赖登录会话与 DBus,容器 / cron 等环境常常拿不到,提前拦掉
|
||||
if [ "$SYSTEMD_MODE" = "user" ] && ! systemctl --user list-units >/dev/null 2>&1; then
|
||||
echo "错误:当前环境无法使用 systemd --user(无用户级 systemd 实例或缺少 DBus 会话)" >&2
|
||||
echo " 可改用 sudo bash contribute.sh 做系统级安装" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! command -v wget >/dev/null 2>&1 && ! command -v curl >/dev/null 2>&1; then
|
||||
echo "错误:未找到 wget 或 curl,无法下载" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# 运维命令按作用域切换(用户级必须带 --user,否则查的是系统级命名空间)
|
||||
if [ "$SYSTEMD_MODE" = "user" ]; then
|
||||
CTL_CMD="systemctl --user"
|
||||
JRN_CMD="journalctl --user -u"
|
||||
SCOPE_LABEL="用户级 systemd --user"
|
||||
else
|
||||
CTL_CMD="systemctl"
|
||||
JRN_CMD="journalctl -u"
|
||||
SCOPE_LABEL="系统级 systemd"
|
||||
fi
|
||||
sc() { if [ "$SYSTEMD_MODE" = "user" ]; then systemctl --user "$@"; else systemctl "$@"; fi; }
|
||||
jc() { if [ "$SYSTEMD_MODE" = "user" ]; then journalctl --user "$@"; else journalctl "$@"; fi; }
|
||||
|
||||
# ---------- 架构检测 ----------
|
||||
case "$(uname -m)" in
|
||||
x86_64) ARCH_TAG="amd64" ;;
|
||||
i386|i486|i586|i686) ARCH_TAG="386" ;;
|
||||
aarch64|arm64) ARCH_TAG="arm64" ;;
|
||||
armv7l|armv7hl) ARCH_TAG="armv7" ;;
|
||||
armv6l) ARCH_TAG="armv6" ;;
|
||||
loongarch64) ARCH_TAG="loong64" ;;
|
||||
*)
|
||||
echo "错误:不支持的架构 '$(uname -m)'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
RELEASE_ASSET="lemonipw-linux-${ARCH_TAG}"
|
||||
|
||||
# ---------- 命名(与 install.sh 保持一致) ----------
|
||||
|
||||
# 二进制 / 安装目录 / 服务名统一固定为 lemon 系列,便于运维识别与排查;
|
||||
# 一台机器只跑一份,重跑本脚本 = 覆盖同名服务与目录。
|
||||
BIN_BASE="lemonipw"
|
||||
SERVICE_NAME="lemon-ipw"
|
||||
if [ "$SYSTEMD_MODE" = "user" ]; then
|
||||
INSTALL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/lemon-ipw"
|
||||
SERVICE_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/${SERVICE_NAME}.service"
|
||||
UNIT_USER_LINE=""
|
||||
UNIT_NETWORK_LINES=""
|
||||
UNIT_WANTED_BY="default.target"
|
||||
else
|
||||
INSTALL_DIR="/opt/lemon-ipw"
|
||||
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
|
||||
# 系统级 unit 的 User= 行与 network-online 依赖;用户级没有这两个概念
|
||||
UNIT_USER_LINE="User=root
|
||||
"
|
||||
UNIT_NETWORK_LINES="After=network-online.target
|
||||
Wants=network-online.target
|
||||
"
|
||||
UNIT_WANTED_BY="multi-user.target"
|
||||
fi
|
||||
|
||||
# 同名服务已存在(例如这台机器已经跑着一个节点):再跑一次会用新生成的
|
||||
# 节点标识覆盖旧配置,旧节点在收集中心的记录就失效了,先提醒一句。
|
||||
if [ "$DRY_RUN" != "true" ] && [ -f "$SERVICE_FILE" ]; then
|
||||
echo "提示:已存在服务 ${SERVICE_NAME},本次会覆盖其配置并生成新的节点标识(旧标识在收集中心将失效)" >&2
|
||||
fi
|
||||
|
||||
PORTS="${OPT_PORT:-$(pick_port)}"
|
||||
case "$PORTS" in
|
||||
""|*[!0-9]*)
|
||||
echo "错误:端口必须是数字(当前值:$PORTS)" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
# 10# 前缀强制十进制:避免 "0800" 这类带前导 0 的值被当成八进制解析
|
||||
PORTS=$((10#$PORTS))
|
||||
if [ "$PORTS" -lt 1 ] || [ "$PORTS" -gt 65535 ]; then
|
||||
echo "错误:端口超出范围 1-65535(当前值:$PORTS)" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -n "$OPT_PORT" ] && port_in_use "$PORTS"; then
|
||||
echo "警告:端口 $PORTS 当前已被占用,节点可能启动失败" >&2
|
||||
fi
|
||||
|
||||
WS_URL="${OPT_WS_URL:-$WS_URL_DEFAULT}"
|
||||
# 逐段校验(逗号分隔可多个),并去掉段内空格:节点侧虽会 trim,
|
||||
# 但空格会原样进 systemd 的 Environment 值,还是在这里清掉更干净。
|
||||
WS_URL_SEGMENTS=""
|
||||
_old_ifs="$IFS"; IFS=','
|
||||
for _seg in $WS_URL; do
|
||||
# 去前导/尾随空白(IFS 只含逗号,空白不会被自动去掉)
|
||||
_seg="${_seg#"${_seg%%[![:space:]]*}"}"
|
||||
_seg="${_seg%"${_seg##*[![:space:]]}"}"
|
||||
[ -n "$_seg" ] || continue
|
||||
case "$_seg" in
|
||||
ws://*|wss://*) ;;
|
||||
*)
|
||||
IFS="$_old_ifs"
|
||||
echo "错误:WS 地址的每一段都需以 ws:// 或 wss:// 开头(问题段:${_seg})" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
case "$_seg" in
|
||||
*/ws|*/ws/) ;;
|
||||
*) echo "警告:WS 地址 ${_seg} 看起来不含 /ws 路径,节点可能连不上(节点默认连 <地址>/ws)" >&2 ;;
|
||||
esac
|
||||
WS_URL_SEGMENTS="${WS_URL_SEGMENTS:+${WS_URL_SEGMENTS},}${_seg}"
|
||||
done
|
||||
IFS="$_old_ifs"
|
||||
if [ -z "$WS_URL_SEGMENTS" ]; then
|
||||
echo "错误:WS 地址为空(当前值:${WS_URL})" >&2
|
||||
exit 1
|
||||
fi
|
||||
WS_URL="$WS_URL_SEGMENTS"
|
||||
|
||||
NODE_ID=$(gen_uuid)
|
||||
NODE_KEY=$(gen_token)
|
||||
ACCESS_TOKEN=$(gen_token)
|
||||
|
||||
# ---------- 公网地址探测(失败不阻断) ----------
|
||||
|
||||
detect_ip() {
|
||||
local url="$1" out=""
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
out=$(curl -fsS -m 5 "$url" 2>/dev/null || true)
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
out=$(wget -qO- --timeout=5 "$url" 2>/dev/null || true)
|
||||
fi
|
||||
printf '%s' "$out" | tr -d ' \t\r\n'
|
||||
}
|
||||
|
||||
is_ipv4() { printf '%s' "$1" | grep -qE '^([0-9]{1,3}\.){3}[0-9]{1,3}$'; }
|
||||
is_ipv6() {
|
||||
printf '%s' "$1" | grep -qE '^[0-9A-Fa-f:]+$' || return 1
|
||||
printf '%s' "$1" | grep -q ':' || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
IPV4=$(detect_ip "https://4.wsmdn.top/")
|
||||
is_ipv4 "$IPV4" || IPV4=""
|
||||
IPV6=$(detect_ip "https://6.wsmdn.top/")
|
||||
is_ipv6 "$IPV6" || IPV6=""
|
||||
|
||||
# 单栈判定:只有一侧能出网就按单栈跑,避免另一协议的拨测全失败刷错误日志
|
||||
SINGLE_STACK=""
|
||||
STACK_LABEL="双栈"
|
||||
if [ -n "$IPV4" ] && [ -z "$IPV6" ]; then
|
||||
SINGLE_STACK="ipv4"
|
||||
STACK_LABEL="IPv4"
|
||||
elif [ -z "$IPV4" ] && [ -n "$IPV6" ]; then
|
||||
SINGLE_STACK="ipv6"
|
||||
STACK_LABEL="IPv6"
|
||||
fi
|
||||
|
||||
# ---------- 版本与下载地址 ----------
|
||||
|
||||
fetch_latest_version() {
|
||||
local api="https://api.github.com/repos/nomdn/ipw-cn/releases/latest" raw=""
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
raw=$(curl -fsS -m 20 "$api" 2>/dev/null || true)
|
||||
else
|
||||
raw=$(wget -qO- --timeout=20 "$api" 2>/dev/null || true)
|
||||
fi
|
||||
printf '%s' "$raw" | grep -o '"tag_name": *"[^"]*"' | head -1 | cut -d'"' -f4
|
||||
}
|
||||
|
||||
VERSION="$OPT_VERSION"
|
||||
if [ -z "$VERSION" ]; then
|
||||
VERSION=$(fetch_latest_version || true)
|
||||
fi
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "错误:无法获取最新版本号(GitHub API 不可达或限流)。可用 --version <tag> 指定,例如 --version v3.7.0" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DOWNLOAD_URL="https://github.com/nomdn/ipw-cn/releases/download/${VERSION}/${RELEASE_ASSET}"
|
||||
if [ -n "$OPT_GH_PROXY" ]; then
|
||||
DOWNLOAD_URL="${OPT_GH_PROXY%/}/${DOWNLOAD_URL}"
|
||||
fi
|
||||
|
||||
# ---------- 输出节点信息 ----------
|
||||
|
||||
print_info() {
|
||||
local dry_note=""
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
dry_note="(dry-run,未实际安装)"
|
||||
fi
|
||||
local ipv4_disp="${IPV4:-检测失败}"
|
||||
local ipv6_disp="${IPV6:-检测失败}"
|
||||
local ipdb_disp="未启用(仅影响 IP 归属地/ASN 类拨测,需要时用 --ipdb 重装启用)"
|
||||
if [ "$OPT_IPDB" = "true" ]; then
|
||||
ipdb_disp="已启用(首次启动后台下载,约 450MB)"
|
||||
fi
|
||||
# WS 地址逐个列出(可能接多个中间件),首个带标签、其余对齐缩进
|
||||
local ws_block=""
|
||||
local _first="true" _u=""
|
||||
local _old_ifs="$IFS"; IFS=','
|
||||
for _u in $WS_URL; do
|
||||
if [ "$_first" = "true" ]; then
|
||||
ws_block=" WS 地址: ${_u}"
|
||||
_first="false"
|
||||
else
|
||||
ws_block="${ws_block}
|
||||
${_u}"
|
||||
fi
|
||||
done
|
||||
IFS="$_old_ifs"
|
||||
cat << EOF
|
||||
|
||||
========================================
|
||||
贡献节点${dry_note}已就绪,请把以下信息提交给管理员
|
||||
========================================
|
||||
节点 id: ${NODE_ID}
|
||||
注册 key: ${NODE_KEY}
|
||||
${ws_block}
|
||||
监听端口: ${PORTS}
|
||||
单栈模式: ${STACK_LABEL}
|
||||
access-token: ${ACCESS_TOKEN}
|
||||
CORS: 不限
|
||||
公网 IPv4: ${ipv4_disp}
|
||||
公网 IPv6: ${ipv6_disp}
|
||||
地区-运营商: 请自行填写
|
||||
----------------------------------------
|
||||
中间件 ws-keys(**每个 WS 地址对应的中间件都要登记**,缺一个该条连接会被拒 401):
|
||||
"${NODE_ID}": "${NODE_KEY}"
|
||||
中心 / 中间件 api-keys(HTTP 直连本节点时的鉴权):
|
||||
"${NODE_ID}": "${ACCESS_TOKEN}"
|
||||
----------------------------------------
|
||||
提交邮箱: ${CONTACT_EMAIL}
|
||||
说明:
|
||||
1. 本节点默认以 WS 方式同时接入上面的中间件(节点主动出站连接),无需公网放行 ${PORTS}/TCP。
|
||||
2. 若接收方希望以 HTTP 方式直连本节点,需放行 ${PORTS}/TCP 且该端口公网可达。
|
||||
3. IP 数据库: ${ipdb_disp}
|
||||
----------------------------------------
|
||||
运维命令(${SCOPE_LABEL}):
|
||||
状态: ${CTL_CMD} status ${SERVICE_NAME}
|
||||
日志: ${JRN_CMD} ${SERVICE_NAME} -f
|
||||
重启: ${CTL_CMD} restart ${SERVICE_NAME}
|
||||
卸载: ${CTL_CMD} disable --now ${SERVICE_NAME} && rm -f ${SERVICE_FILE} && rm -rf ${INSTALL_DIR}
|
||||
节点信息备份: ${INSTALL_DIR}/node-info.txt
|
||||
========================================
|
||||
EOF
|
||||
}
|
||||
|
||||
# ---------- dry-run:只展示 ----------
|
||||
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo "架构: $(uname -m) → ${RELEASE_ASSET}"
|
||||
echo "版本: ${VERSION}"
|
||||
echo "下载地址: ${DOWNLOAD_URL}"
|
||||
echo "安装目录: ${INSTALL_DIR}"
|
||||
echo "服务名: ${SERVICE_NAME}"
|
||||
echo "作用域: ${SCOPE_LABEL}"
|
||||
echo "随机: 端口=${PORTS} 节点id=${NODE_ID}"
|
||||
print_info
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ---------- 下载二进制 ----------
|
||||
|
||||
echo "正在下载 ${VERSION} / ${RELEASE_ASSET} ..."
|
||||
mkdir -p "$INSTALL_DIR"
|
||||
if command -v wget >/dev/null 2>&1; then
|
||||
wget -q -O "${INSTALL_DIR}/${BIN_BASE}" "$DOWNLOAD_URL"
|
||||
else
|
||||
# -f 让 4xx 直接失败,避免把 GitHub 的 Not Found 页面存成二进制
|
||||
curl -fsSL -o "${INSTALL_DIR}/${BIN_BASE}" "$DOWNLOAD_URL"
|
||||
fi
|
||||
chmod +x "${INSTALL_DIR}/${BIN_BASE}"
|
||||
|
||||
# ---------- 生成 systemd 服务 ----------
|
||||
|
||||
# 仅非空项写入,避免空值覆盖节点自身默认值。
|
||||
# 值内的双引号 / 反斜杠 / % 必须转义:前两者会破坏 systemd 的引号包裹,
|
||||
# % 是 unit 说明符(要写成 %% 才是字面量)。
|
||||
ENV_LINES=""
|
||||
add_env() {
|
||||
local name="$1" value="$2"
|
||||
[ -n "$value" ] || return 0
|
||||
value="${value//\\/\\\\}"
|
||||
value="${value//\"/\\\"}"
|
||||
value="${value//%/%%}"
|
||||
ENV_LINES="${ENV_LINES}Environment=\"${name}=${value}\"
|
||||
"
|
||||
}
|
||||
add_env PORTS "$PORTS"
|
||||
add_env SINGLE_STACK "$SINGLE_STACK"
|
||||
add_env WS_URL "$WS_URL"
|
||||
add_env NODE_ID "$NODE_ID"
|
||||
add_env NODE_KEY "$NODE_KEY"
|
||||
add_env ACCESS_TOKEN "$ACCESS_TOKEN"
|
||||
add_env IPDB "$OPT_IPDB"
|
||||
|
||||
# 用户级 unit 目录(~/.config/systemd/user)默认可能不存在
|
||||
mkdir -p "$(dirname "$SERVICE_FILE")"
|
||||
|
||||
cat > "$SERVICE_FILE" << EOF
|
||||
[Unit]
|
||||
Description=Lemon IPW Backend Node
|
||||
${UNIT_NETWORK_LINES}
|
||||
[Service]
|
||||
Type=simple
|
||||
${UNIT_USER_LINE}WorkingDirectory=${INSTALL_DIR}
|
||||
ExecStart=${INSTALL_DIR}/${BIN_BASE}
|
||||
${ENV_LINES}Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=${UNIT_WANTED_BY}
|
||||
EOF
|
||||
|
||||
# ---------- 启动服务 ----------
|
||||
|
||||
sc daemon-reload
|
||||
sc enable --now "$SERVICE_NAME" >/dev/null 2>&1 || true
|
||||
sleep 2
|
||||
if ! sc is-active --quiet "$SERVICE_NAME"; then
|
||||
echo "错误:服务未能启动,最近日志:" >&2
|
||||
jc -u "$SERVICE_NAME" --no-pager -n 20 >&2 || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 用户级服务默认随最后一个会话结束而停止,注销后要继续跑必须开 linger
|
||||
if [ "$SYSTEMD_MODE" = "user" ]; then
|
||||
if loginctl show-user "$(id -un)" -p Linger 2>/dev/null | grep -q 'Linger=yes'; then
|
||||
echo "linger 已启用:用户注销后服务继续运行"
|
||||
elif loginctl enable-linger "$(id -un)" >/dev/null 2>&1; then
|
||||
echo "已启用 linger:用户注销后服务继续运行"
|
||||
else
|
||||
echo "提示:未能自动启用 linger,注销后服务会被停止。请手动执行:" >&2
|
||||
echo " sudo loginctl enable-linger $(id -un)" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# ---------- 落一份信息备份(节点标识随机,记不住) ----------
|
||||
|
||||
{
|
||||
echo "node_id=${NODE_ID}"
|
||||
echo "node_key=${NODE_KEY}"
|
||||
echo "access_token=${ACCESS_TOKEN}"
|
||||
echo "ws_url=${WS_URL}"
|
||||
echo "port=${PORTS}"
|
||||
echo "single_stack=${SINGLE_STACK:-双栈}"
|
||||
echo "service=${SERVICE_NAME}"
|
||||
echo "install_dir=${INSTALL_DIR}"
|
||||
echo "version=${VERSION}"
|
||||
} > "${INSTALL_DIR}/node-info.txt"
|
||||
chmod 600 "${INSTALL_DIR}/node-info.txt"
|
||||
|
||||
# 本地存活自检(只打本机回环,不依赖接收方是否已登记)
|
||||
LOCAL_CHECK="失败"
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
if curl -fsS -m 5 "http://127.0.0.1:${PORTS}/" >/dev/null 2>&1; then
|
||||
LOCAL_CHECK='正常({"status":"ok"})'
|
||||
fi
|
||||
fi
|
||||
echo "本地自检: ${LOCAL_CHECK}"
|
||||
|
||||
print_info
|
||||
@@ -22,20 +22,40 @@
|
||||
- `dnssec-server`:**DNSSEC 专用** DNS 服务器(同样支持主从逗号分隔);留空则沿用 `dns-server`;`dns-server` 与 `dnssec-server` **都留空时自动探测系统 DNS** 兜底
|
||||
- `block-private-ips`:SSRF 防护开关(拒绝出站连接内网/私有地址;探测目标命中私有网段时直接返回伪造结果,禁止跨跳重定向)
|
||||
- `single-stack`:单栈模式,`ipv4` / `ipv6` / 留空(双栈)。声明单栈的节点跳过另一栈的探测(直接返回 `Skipped due to SINGLE_STACK=...`),EdgeOne / Vercel 等 IPv4-only 环境建议设为 `ipv4`
|
||||
- `ipdb`:IP 数据库开关。**不配置时默认启用**(首次启动自动下载约 450MB,之后每 24h 更新);仓库的 `setting.json.example` 里显式写为 `"false"`,即**示例配置是关闭状态**——关闭后不加载任何数据库,`/v1/location`、`/v1/asn` 路由不注册,适合只做网络拨测的轻量节点
|
||||
- `ipdb`:IP 数据库开关。**不配置时默认启用**(首次启动自动下载约 450MB,之后每 24h 更新);仓库的 `setting.json.example` 里显式写为 `false`,即**示例配置是关闭状态**——关闭后不加载任何数据库,`/v1/location`、`/v1/asn` 路由不注册,适合只做网络拨测的轻量节点
|
||||
- `cors`:允许的请求来源(逗号分隔)
|
||||
- `trusted-proxies`:可信代理 IP/CIDR(逗号分隔,如 `"10.0.0.0/8,173.245.48.0/20"`)。配置后 `ClientIP` 与 `/v1/location` 归属地接口只信任这些代理转发的 `X-Forwarded-For`,直连公网的节点可防止访客伪造 XFF;**留空保持默认行为(信任所有代理,XFF 可被伪造)**
|
||||
- `access-token`:API 访问令牌,留空则不启用鉴权。**它同时是 HTTP 管理面的开关**:留空时 `/v1/config`、`/v1/ota` 整组返回 `403`,只能走 WS 通道管理
|
||||
- `gh-proxy`:GitHub 下载代理前缀(如 `"https://ghproxy.com/"`),用于 IP 数据库拉取与 OTA 下载加速;留空直连
|
||||
- `node-ota`:OTA 开关,缺省 `true`(允许收集中心下发)。设为 `false` 时节点拒绝一切 OTA 指令并回传原因,适合只读文件系统 / 编排托管(升级走各自部署渠道)的部署。**支持运行时热改**(`PATCH /v1/config` 或 WS `config` 下发即时生效,改后按新值判定后续 OTA 指令)
|
||||
- `access-log`:访问日志开关,缺省 `true`(每个请求输出一条 `http` 记录:method / path / status / latency_ms / ip)。设为 `false` 后不再输出访问日志,**适合高吞吐节点**——访问日志是每请求一次同步写,压测中即便业务逻辑极轻(`/` 健康检查)吞吐也会被它压住。关闭后 panic 兜底与其余日志不受影响,仍会记录 500 与堆栈。**支持运行时热改**(`PATCH /v1/config` 或 WS `config` 下发即时生效,无需重启)
|
||||
- `ws-url`:WS 通道地址——接入独立中间件的 WebSocket 地址(如 `"wss://middleware-1.api-ipw.wsmdn.top/ws"`,须含 `wss://` 前缀与 `/ws` 路径);支持**逗号分隔多个中间件,同时连接全部(多活)**,任一断开只重连自己,不影响其他连接;留空 = 不启用 WS 客户端,走原 HTTP 接口
|
||||
- `node-id`:WS 节点 id(与中间件 `api-keys`/`ws-keys` 键、前端配置的节点 `id` 一致;建议用 UUID 唯一标识)
|
||||
- `node-key`:WS 注册 key(与中间件 `ws-keys[节点id]` 一致;**必填**——节点未配置该 key 时中间件拒绝注册并返回 401)
|
||||
- `report-url`:**数据上报收集中心** HTTP 基址(如 `"https://collector.example.com"`,即 ipw-boce 中间件)。节点把自身观测的统计/拨测按 `report-interval-seconds` 周期上报;`ws-url` 已启用时优先走 WS `report` 消息(所有已连接中间件广播),WS 未启用或全部掉线时 HTTP POST 到 `<report-url>/report` 兜底;远端配置可覆盖(在 `remote-ignore-config` 里加上 `report-url` 可禁止覆盖)
|
||||
- `report-token`:收集中心 `/report` 鉴权 token(与中间件 `report-token` 配置一致);属凭据类键,GET 快照里遮蔽为 `***`;**不随远端配置覆盖**(硬编码保护,清单见本页末的「远端配置」一节)
|
||||
- `report-interval-seconds`:上报周期秒,缺省 15
|
||||
- `max-response-body`:单次拨测可读的响应体上限,**按解压后大小**算,缺省 `32MB`(33554432 字节);支持裸数字与 `K`/`M`/`G` 后缀(`32MB` / `8M` / `1g` / `8MiB` 均可,大小写不敏感)。`detail` / `speed` / `ssl` 只需要一个字节数,正常网页远小于默认值;超过上限**直接返回错误,而不是截断上报**——报一个"截断后的大小/速度"比报错更误导人。**支持运行时热改**(`PATCH /v1/config` 下发即应用到出站客户端)
|
||||
- `memory-limit`:Go 运行时的**软**内存上限(等价 `GOMEMLIMIT`),字节数,写法同上;**留空(=0)表示自动取容器内存限额的 90%**,探测不到容器限额就不设置、保持 Go 默认 GC 行为。不设时 Go 只按 `GOGC` 比例回收,够不到突增,小内存机器上堆会一路涨到被内核 OOM kill,中间没有减速带。**软上限不是硬闸**:必要时运行时仍会越过它,只是付出更多 GC 代价。**支持运行时热改**
|
||||
|
||||
以上字段均可用环境变量覆盖(`PORTS` / `SINGLE_STACK` / `DNS_SERVER` / `DNSSEC_DNS_SERVER` / `BLOCK_PRIVATE_IPS` / `IPDB` / `CORS` / `TRUSTED_PROXIES` / `GH_PROXY` / `ACCESS_TOKEN` / `WS_URL` / `NODE_ID` / `NODE_KEY` / `NODE_OTA` / `REPORT_URL` / `REPORT_TOKEN` / `REPORT_INTERVAL_SECONDS`)。需要从远端拉取配置时,设置 `remote-config-url` 或环境变量 `REMOTE_CONFIG_URL`(优先级:远端 > 环境变量 > setting.json);`remote-ignore-config` 对应的环境变量为 `REMOTE_IGNORE_CONFIG`(JSON 数组字符串)。
|
||||
以上字段均可用环境变量覆盖(`PORTS` / `SINGLE_STACK` / `DNS_SERVER` / `DNSSEC_DNS_SERVER` / `BLOCK_PRIVATE_IPS` / `ACCESS_LOG` / `IPDB` / `CORS` / `TRUSTED_PROXIES` / `GH_PROXY` / `ACCESS_TOKEN` / `WS_URL` / `NODE_ID` / `NODE_KEY` / `NODE_OTA` / `REPORT_URL` / `REPORT_TOKEN` / `REPORT_INTERVAL_SECONDS` / `MAX_RESPONSE_BODY` / `MEMORY_LIMIT`)。需要从远端拉取配置时,设置 `remote-config-url` 或环境变量 `REMOTE_CONFIG_URL`(优先级:远端 > 环境变量 > setting.json);`remote-ignore-config` 对应的环境变量为 `REMOTE_IGNORE_CONFIG`(JSON 数组字符串)。
|
||||
|
||||
> [!TIP]
|
||||
> 后端字段共 22 个,`src/setting.json.example` 只列**最小可用集**(11 个:端口 / 代理 / 单栈 / DNS / IP 库 / CORS / 令牌 / WS 身份)——其余按需加,完整定义以本页为准。
|
||||
|
||||
<a id="bool-switches"></a>
|
||||
|
||||
> [!NOTE]
|
||||
> **四个开关(`ipdb` / `block-private-ips` / `node-ota` / `access-log`)共用一套字面值口径**(忽略大小写与首尾空白):
|
||||
>
|
||||
> - 开:`true` / `1` / `yes` / `on` / `enable` / `enabled`
|
||||
> - 关:`false` / `0` / `no` / `off` / `disable` / `disabled`
|
||||
>
|
||||
> 不配置(空值)时各用各的默认值(`block-private-ips` / `node-ota` / `access-log` / `ipdb` 都缺省**开**)。JSON 里写布尔 `true` 或字符串 `"true"` 均可,数字 `1` / `0` 也可以 —— 四条来源(`setting.json` / 环境变量 / `PATCH /v1/config` / 远端下发)会先归一成同一张字面量表再判定,所以布尔与字符串的结果必然一致。
|
||||
>
|
||||
> **认不出来的值不再静默当成"开"**:启动阶段告警并按默认值处理;`PATCH /v1/config` 与远端下发会把它计入应答的 `unknown` 并保留原值,便于发现拼错的键值。
|
||||
>
|
||||
> 历史差异(升级时注意):旧版本里只有 `node-ota` 认 `yes`/`no`/`off`,在 `ipdb` / `block-private-ips` / `access-log` 上写 `no` / `off` 会被当成**开**,`ipdb` 还大小写敏感(`"False"` 也是开)。现在四个开关统一按上表判定。
|
||||
|
||||
### 运行时配置管理
|
||||
|
||||
@@ -51,7 +71,7 @@
|
||||
|
||||
- **凭据类键不回显明文**:`access-token` / `node-key` / `report-token` 在快照里是 `***`。下发时必须剔除这些键,否则会把真值覆盖成三个星号(收集中心控制台已自动剔除)。
|
||||
- **凭据类键中 `access-token` / `report-token` 不受远端配置影响**:它们被硬编码进节点侧的保护名单(`configRemoteProtectedKeys`),远端配置里写了也会被跳过,并在应答 `protectedIgnored` 与日志中如实回报;本地 PATCH 不受此限。原因见本页末的「远端配置」一节。
|
||||
- **节点不自行重启**:`port` / `cors` / `ipdb` / `report-interval-seconds` / `trusted-proxies` / `node-id` / `node-key` / `access-token` 是启动期固定的,改动后在应答 `restartRequired` 里如实列出,但**不会自动重启**;只有"值真的变了"才报,避免每次全量下发都误报。**`ws-url` 是例外,热生效**(控制器按新地址多退少补);`dns-server` / `dnssec-server` / `block-private-ips` / `single-stack` / `node-ota` 每次消费重读,同样即时生效。
|
||||
- **节点不自行重启**:`port` / `cors` / `ipdb` / `report-interval-seconds` / `trusted-proxies` / `node-id` / `node-key` / `access-token` 是启动期固定的,改动后在应答 `restartRequired` 里如实列出,但**不会自动重启**;只有"值真的变了"才报,避免每次全量下发都误报。**`ws-url` 是例外,热生效**(控制器按新地址多退少补);`dns-server` / `dnssec-server` / `block-private-ips` / `single-stack` / `node-ota` / `access-log` / `max-response-body` / `memory-limit` 每次消费重读,同样即时生效。
|
||||
- **内存改动会被重启顶掉**:节点侧优先级为 远端 > 环境变量 > `setting.json`。只 PATCH 内存(或 `persist` 写本地文件)时,重启后仍可能被 ENV 顶掉;要长期生效应 **`refresh`**(改远端配置)或把改动合并进托管配置。
|
||||
|
||||
> [!NOTE]
|
||||
|
||||
@@ -103,6 +103,10 @@ node .output/server/index.mjs # 默认监听 3000 端口
|
||||
- **所需 Secrets**:`CLOUDFLARE_API_TOKEN`、`CLOUDFLARE_ACCOUNT_ID`
|
||||
- **注意**:工作流设置了 `NITRO_PRESET: cloudflare_module`
|
||||
|
||||
## 缓存
|
||||
|
||||
缓存头不在应用侧设置,全部交由前置 CDN(EdgeOne)控制。
|
||||
|
||||
## 常见问题
|
||||
|
||||
- **部署后接口 403 / 跨域**:检查后端 `cors` 配置(独立中间件见 `middleware-go/setting.json` 的 `cors` 字段,逗号分隔允许域名);服务端转发请求不带 `Origin`,浏览器直接调用才受 CORS 限制。
|
||||
|
||||
@@ -224,7 +224,7 @@ systemctl restart lemon-ipw
|
||||
|
||||
节点无论是否接入 WS,都会上报自身版本与支持的管理能力:
|
||||
|
||||
- **版本号**来自构建时注入的 `VERSION`,随 WS `register` 报文上报(字段 `version`);纯 HTTP 节点(无 WS 连接)由收集中心探活 `GET /` 时一并取回(响应体含 `version`)。
|
||||
- **版本号**来自构建时注入的 `VERSION`,随 WS `register` 报文上报(字段 `version`);纯 HTTP 主节点(无 WS 连接)由收集中心探活后再请求 `GET /info` 取回(`GET /` 只返回 `{"status":"ok"}`)。边缘函数版本不提供 `/info`。
|
||||
- **能力清单**(`capabilities`)取值为 `probe` / `report` / `config` / `ota`,用于让收集中心在下发管理指令前判断该节点能否理解——老版本节点的消息循环没有对应分支,收到管理消息会**静默忽略**,只能靠超时暴露。
|
||||
- 收集中心「节点状态」页展示每个节点的版本号,并据此判断哪些节点需要升级;节点升级部署后重新注册即为新版本。
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
| 通道 | 鉴权方式 | 未配置凭据时 |
|
||||
|------|----------|--------------|
|
||||
| 业务探测 `/v1/*` | `access-token` 非空时校验 `Authorization: Bearer <access-token>`,不符返回 `401` | 不启用鉴权,公开可访问 |
|
||||
| 健康检查 `/` | 无 | — |
|
||||
| 健康检查 `/`、节点信息 `/info` | 无 | — |
|
||||
| 管理接口 `/v1/config`、`/v1/ota`(HTTP) | 同业务接口,复用 `tokenCheck` | **整组关闭**,一律返回 `403`(节点未配 `access-token` 时业务接口本身也无鉴权,暴露配置读写等于公网可改配置) |
|
||||
| WS 通道 | 中间件 `ws-keys` 校验注册报文 | WS **常开**:节点是客户端,指令只来自已通过中间件校验的连接,与节点是否配 `access-token` 无关 |
|
||||
|
||||
@@ -17,13 +17,19 @@
|
||||
|
||||
---
|
||||
|
||||
## 一、健康检查
|
||||
## 一、健康检查与节点信息
|
||||
|
||||
```
|
||||
GET / → {"status":"ok","version":"v1.2.3","capabilities":["probe","report","config","ota"]}
|
||||
GET / → {"status":"ok"}
|
||||
GET /info → {"version":"v1.2.3","capabilities":["probe","report","config","ota"]}
|
||||
```
|
||||
|
||||
无鉴权、不计入统计。除存活外同时回报**版本号**与**能力清单**:收集中心对纯 HTTP 节点(无 WS 连接)探活时一并取回,用于节点状态页展示版本、以及下发管理指令前判断该节点能否理解对应指令。
|
||||
两个端点都无鉴权、不计入统计,且都注册在 `/v1` 组之外——因此既不受 `access-token` 约束,也不经过业务统计中间件。
|
||||
|
||||
- **健康检查 `/`**:只回答"进程是否活着"。给负载均衡、OTA 就绪探测(`otaWaitChildReady`)与运维 `curl` 用。**不回报版本**:它是免鉴权的对外端点,回版本号等于向公网公开节点版本。
|
||||
- **节点信息 `/info`**:回报节点身份。`version` 为版本号,`capabilities` 为能力清单(与 WS `register` 报文同源,见 `ws.go nodeCapabilities`)。收集中心对纯 HTTP 节点(无 WS 连接)探活后单独取回,用于节点状态页展示版本、以及下发管理指令前判断该节点能否理解对应指令。
|
||||
|
||||
> 老版本节点没有 `/info`(返回 `404`),边缘函数版节点同样不提供;收集中心取不到就留空,不影响判活。
|
||||
|
||||
---
|
||||
|
||||
@@ -36,7 +42,7 @@ GET / → {"status":"ok","version":"v1.2.3","capabilities":["probe","
|
||||
| GET | `/v1/detail/*url` | 目标 URL(路径传入,自动补全协议) | 网站探测明细:DNS/TCP/HTTP 各阶段耗时、状态码、页面体积、下载速度、可达性;双栈分别返回 |
|
||||
| GET | `/v1/ssl/*url` | 目标 URL | SSL 证书检查:剩余有效天数、颁发/主体、TLS 版本、是否过期;双栈分别返回 |
|
||||
| GET | `/v1/speed/:version/*url` | `version` = `v4` / `v6`,目标 URL | 下载测速 |
|
||||
| GET | `/v1/tcping/:ip` | `port`(默认 80)、`count`(默认 4,上限 20) | TCP 连通性与 RTT 统计 |
|
||||
| GET | `/v1/tcping/:ip` | `port`(默认 80)、`count`(默认 4,上限 20)、`version`(见下文「请求级参数」) | TCP 连通性与 RTT 统计 |
|
||||
| GET | `/v1/dns/:type/*domain` | `type` ∈ `a`/`aaaa`/`cname`/`mx`/`ns`/`ptr`/`srv`/`txt`/`caa` | DNS 记录查询(`dns-server` 支持主从 failover 与 DoH) |
|
||||
| GET | `/v1/dnssec/:domain` | 域名 | DNSSEC 链式验证(`dnssec-server`,留空沿用 `dns-server`) |
|
||||
| GET | `/v1/whois/:domain` | 域名 | Whois 注册信息 |
|
||||
@@ -48,7 +54,36 @@ GET / → {"status":"ok","version":"v1.2.3","capabilities":["probe","
|
||||
|
||||
**单栈模式**:`single-stack` 配为 `ipv4` / `ipv6` 时只跑对应栈,另一栈直接返回 `Skipped due to SINGLE_STACK=...`,不发起无意义的探测与超时。
|
||||
|
||||
**SSRF 防护**:`block-private-ips` 开启时,`detail` / `ssl` 对解析到内网/私有地址的目标直接返回伪造结果,出站客户端同时拒绝连接私有 IP、禁止跨跳重定向。
|
||||
**SSRF 防护**:`block-private-ips` 开启时,`detail` / `ssl` 对解析到内网/私有地址的目标直接返回伪造结果,出站客户端同时拒绝连接私有 IP、禁止跨跳重定向。`tcping` 是裸 TCP、不经过出站客户端,故在 `webtest.ResolveHostWith` 内单独把关:**字面 IP**、**DNS 解析结果**、**`resolve*` 改写后的目标**三者只要落在私网/回环/链路本地/组播网段一律拒绝,该栈返回 `Error: connection to private/internal address <IP> is not allowed`(`sent` 仍为请求次数、`success=0`、`loss_rate=100`);关闭开关时三者一并放行。
|
||||
|
||||
### 请求级参数
|
||||
|
||||
除路径参数与常规 query 外,`/v1/tcping/:ip` 与所有走 DNS 的探测接口还接受一组**请求级参数**,用于按次覆盖解析行为。参数统一由 `webtest.ParseReqResolve` 解析,HTTP 拨测经 context、`tcping` 经形参透传到解析层;HTTP 与 WS 两条通道语义一致。
|
||||
|
||||
| 参数 | 取值 | 作用接口 | 说明 |
|
||||
|------|------|----------|------|
|
||||
| `dns` | 逗号分隔的 `ip:port` 或 `http(s)://` DoH URL | `detail` / `ssl` / `speed` / `tcping` / `whois` / `dns` | 本次探测改用指定 DNS 服务器,取代配置的 `dns-server` |
|
||||
| `dns4` | 同上 | 同上 | 只覆盖 IPv4 族解析,**优先于 `dns`** |
|
||||
| `dns6` | 同上 | 同上 | 只覆盖 IPv6 族解析,**优先于 `dns`** |
|
||||
| `resolve` | 逗号分隔的 `域名:目标`,目标为 IP 或域名 | `detail` / `ssl` / `speed` / `tcping` | 强制改写某域名的解析结果(两栈通用) |
|
||||
| `resolve4` | 同上 | 同上 | 只影响 IPv4 侧;非空时 IPv4 侧**只用这张表**(与 `dns4` 同口径) |
|
||||
| `resolve6` | 同上 | 同上 | 只影响 IPv6 侧;非空时 IPv6 侧**只用这张表** |
|
||||
| `version` | `ipv4` / `ipv6`(兼容 `v4` / `v6`,大小写与首尾空格不敏感) | `tcping` | 请求级指定单栈 |
|
||||
|
||||
`dns*` 与 `resolve*` 是两类正交的覆盖:前者「换服务器去问」,后者「直接改答案」,可同时使用。
|
||||
|
||||
**`resolve*` 的目标可以是 IP,也可以是域名**:
|
||||
|
||||
- 目标是 **IP**(`resolve4=example.com:1.2.3.4`,IPv6 可写 `[::1]` 或裸地址)→ 拨号阶段不再查 DNS,直接对该 IP 做私网校验后连接;
|
||||
- 目标是 **域名**(`resolve=www.example.com:origin.internal`)→ 把它当作新的 host 继续走解析,解析服务器仍取 `dns*`/配置,且**不再查映射表**(因此不会绕成环)。
|
||||
|
||||
行为要点:
|
||||
|
||||
- **取值与配置侧同一套校验**(`NormalizeServers`):合法项为 `ip:port`(UDP)或 DoH URL,非法项被丢弃;**参数存在但所有项都非法时返回 `400`**,不静默忽略——避免「看起来指定了、实际按默认跑」。`resolve*` 同理:每组必须形如 `域名:目标`,目标为 IP 或形如域名(不含端口、空格),非法项丢弃、全非法返回 `400`。
|
||||
- **`version` 不越权单栈配置**:节点 `single-stack` 非空时一律以配置为准(单栈机指定另一栈也跑不起来);仅当配置为空(双栈机)时 `version` 才生效。跳过文案借此区分来源:配置造成记 `SINGLE_STACK`,参数造成记 `version`。
|
||||
- **作用止于「域名 → IP」这一步**:`dns*` 只更换解析服务器、`resolve*` 只改写解析结果,都不改变探测目标与端口;`dnssec` / `location` / `asn` 三类接口不接受上述参数,`whois` / `dns` 只取 `dns*`、忽略 `resolve*`(`dns` 拨测问的就是真实解析,改写会自相矛盾)。
|
||||
- **SSRF 预检同源**:开启 `block-private-ips` 时,预检校验的是**拨号真正会连的地址**(即 `resolve*` 改写后的目标),不会拿原域名的解析结果去判定。`tcping` 没有独立的预检步骤,同一判断落在 `ResolveHostWith` 进入拨号之前,口径与上述一致。
|
||||
- **带覆盖时按独立缓存键缓存**:规范化后的参数会拼进缓存键(见「七、缓存与并发」),不同服务器/不同映射的结果各占一条,既不串味、也不牺牲命中率。
|
||||
|
||||
---
|
||||
|
||||
@@ -174,7 +209,7 @@ POST /v1/ota
|
||||
|
||||
## 六、能力清单(capabilities)
|
||||
|
||||
节点在 `register` 报文与 `GET /` 中上报自身支持的管理能力,取值为 `probe` / `report` / `config` / `ota` 的数组。
|
||||
节点在 `register` 报文与主节点的 `GET /info` 中上报自身支持的管理能力,取值为 `probe` / `report` / `config` / `ota` 的数组。边缘函数版本不提供 `/info`,也不回报能力清单。
|
||||
|
||||
收集中心据此做**三态判定**,绝不能把"未知"当作"不支持":
|
||||
|
||||
@@ -192,16 +227,47 @@ POST /v1/ota
|
||||
|
||||
业务探测结果在节点侧缓存,避免同 key 洪打把上游打崩:
|
||||
|
||||
| 缓存 | 键 | TTL |
|
||||
|------|-----|-----|
|
||||
| `detail` | 归一化 URL | 5 分钟 |
|
||||
| `ssl` | URL | 5 分钟 |
|
||||
| `speed` | `url:version` | 5 分钟 |
|
||||
| `tcping` | `host:port:count` | 5 分钟 |
|
||||
| `whois` | 域名 | 5 分钟 |
|
||||
| `asn whois` | `AS<asn>` | 5 分钟 |
|
||||
| Bilibili 归属地(在线 API) | IP | 24 小时 |
|
||||
| 缓存 | 键(末尾拼请求级解析片段) | TTL(成功 / 失败) |
|
||||
|------|-----|--------------------|
|
||||
| `detail` | 归一化 URL | 30s / 5s |
|
||||
| `ssl` | URL | 30s / 5s |
|
||||
| `speed` | `url:version` | 30s / 5s |
|
||||
| `tcping` | `host:port:count:stack` | 30s / 5s |
|
||||
| `whois` | 域名 | 30s / 5s |
|
||||
| `asn whois` | `AS<asn>` | 30s / 5s |
|
||||
| Bilibili 归属地(在线 API) | IP | 24 小时(不分成败) |
|
||||
|
||||
- **失败结果 30s 后删除**:探测失败(如目标不可达)不缓存整 5 分钟,避免故障恢复后长时间返回旧结论。
|
||||
- **singleflight 合并**:`detail` / `ssl` / `tcping` / `speed` 的并发同 key 请求合并为一次真实探测。
|
||||
- **定时清扫**:每 10 分钟清理过期缓存条目与 Bilibili 缓存,防止只靠"同 key 重访才淘汰"时内存无限增长。
|
||||
- **TTL 按结果分档**(`cacheTTL`):成功 30s、失败 5s。失败结果不缓存太久,避免故障恢复后长时间返回旧结论;TTL 记在条目里、读时判断,无需后台协程唤醒。
|
||||
- **缓存键含生效栈**:`tcping` 的键为 `host:port:count:stack`,`version=ipv6` 的结果与默认双栈不会互相污染。
|
||||
- **singleflight 合并**:`detail` / `ssl` / `tcping` / `speed` 的并发同 key 请求合并为一次真实探测(合并键同缓存键)。
|
||||
- **请求级解析参数进键**:`dns*` 与 `resolve*` 一并拼入,详见下一节。
|
||||
- **定时清扫**:每 1 分钟清理过期缓存条目,防止只靠「同 key 重访才淘汰」时内存无限增长。
|
||||
|
||||
### 7.1 请求级解析参数如何进入缓存键
|
||||
|
||||
缓存键的基础部分只含**目标**维度(URL / host),但探测结果依赖**怎么解析**——同一域名经不同服务器、或经 `resolve*` 改写后可能指向完全不同的 IP(企业内网、CDN 调度、分线路权威、上线前的强制指向)。若把两者混在一条键里,会双向串味且无从察觉:
|
||||
|
||||
- 带 `dns=1.1.1.1:53` 的结果写进 `example.com` 这条 → 随后的普通请求(用配置的 `dns-server`)读出来,用户以为是自己默认 DNS 的结果;
|
||||
- 反过来,普通请求的结果也会被带 `dns=` 的请求读走——用户明明指定了服务器,却拿到别人用另一台服务器查的结果;
|
||||
- `resolve*` 更直接:强制指向 A 与强制指向 B 是两次不同探测,共用一条键等于互相覆盖。
|
||||
|
||||
因此把**规范化后的参数片段拼在键末尾**(`ReqResolve.CacheKey()`),两件事同时成立:不同解析配置各占一条,相同配置仍能命中。
|
||||
|
||||
```
|
||||
https://example.com ← 无请求级参数
|
||||
https://example.com;dns=1.1.1.1:53 ← dns=
|
||||
https://example.com:v4;dns=8.8.8.8:53;dns6=[2400::1]:53 ← speed,按栈覆盖
|
||||
qq.com:80:4:ipv4;dns=1.1.1.1:53 ← tcping
|
||||
https://example.com;resolve4=example.com:127.0.0.1 ← resolve4,强制解析
|
||||
```
|
||||
|
||||
片段规则:
|
||||
|
||||
- **字段顺序固定**为 `dns` → `dns4` → `dns6` → `resolve` → `resolve4` → `resolve6`。所以参数在 URL 里谁先谁后不影响键(`?dns6=…&dns=…` 与 `?dns=…&dns6=…` 是同一个键)。
|
||||
- **`dns*` 内部按输入顺序,`resolve*` 内部按域名排序**:映射表本质是 map,迭代顺序随机;不排序的话同一请求每次算出的键都不同,缓存永远命不中。
|
||||
- **无参数时片段为空串** ⇒ 键与未引入该特性时**逐字节一致**,升级后旧缓存条目照常命中。
|
||||
- **按规范化结果拼**:非法项在校验阶段已被丢弃,故 `dns=1.1.1.1:53,garbage` 与 `dns=1.1.1.1:53` 落在同一个键上;`resolve4=Example.COM.:1.2.3.4` 与 `resolve4=example.com:1.2.3.4` 同理(域名统一小写、去尾点)。
|
||||
- **键空间随组合增长**:每条仍受 30s / 5s 的 TTL 约束,由每分钟的清扫兜住,不会无限堆积。
|
||||
- `asn` / `location` / `dnssec` 不接这些参数,键与以前相同。
|
||||
|
||||
> 已知残留(与本次改动无关):`detail` 与 `ssl` 的 singleflight 合并键都是「URL + 片段」,两种探测**并发**打同一 URL 时会撞在一起,后到者按另一类型断言会 panic(被 `recover` 接住 → 500)。修法是给合并键加探测类型前缀,暂未处理。
|
||||
@@ -31,5 +31,5 @@ features:
|
||||
- title: 远程运维
|
||||
details: 节点上报版本号与能力清单,收集中心展示版本、远程读写运行时配置,并可下发一次性 OTA 升级任务(下载 → 校验 → 替换 → 重启,失败自动回滚)。
|
||||
- title: 多平台部署
|
||||
details: 支持二进制,Docker,乃至AWS Lambda,EdgeOne Makers,Vercel和阿里云函数计算
|
||||
details: 支持二进制、Docker,以及 EdgeOne Makers 和 Vercel 部署
|
||||
---
|
||||
@@ -74,6 +74,6 @@
|
||||
|------|------|
|
||||
| 二进制 / systemd | `install.sh` 一键安装,配置以环境变量注入 |
|
||||
| Docker | `src/Dockerfile` 多阶段构建,多架构(amd64 / arm64 / armv7);镜像不含 IP 库,首次运行现场拉取 |
|
||||
| Serverless | EdgeOne Makers、Vercel、AWS Lambda、阿里云函数计算等(均为 IPv4-only,需声明 `SINGLE_STACK=ipv4`) |
|
||||
| Serverless | EdgeOne Go 边缘函数、Vercel 部署入口(仓库提供实现;均为 IPv4-only,需声明 `SINGLE_STACK=ipv4`) |
|
||||
|
||||
各形态的详细步骤见 [后端节点部署](/guide/deploy-node)。
|
||||
@@ -32,7 +32,7 @@ Lemon IPW(柠檬味 ipw.cn 替代品)是一个开源的分布式站点测试
|
||||
- 后端(Go)提供全部检测 API,可在任意地区部署测试节点,是分布式查询的核心
|
||||
- 独立中间件(middleware-go)使用Fiber技术栈 负责请求转发和 Key 注入
|
||||
|
||||
后端支持二进制、Docker 自托管,也支持 AWS Lambda、EdgeOne Makers、Vercel、阿里云函数计算等 Serverless 平台部署。
|
||||
后端支持二进制、Docker 自托管,以及仓库中提供的 EdgeOne Go 边缘函数和对应的 Vercel 部署入口。AWS Lambda、阿里云函数计算目前没有对应的实现或部署配置。
|
||||
|
||||
## 技术栈
|
||||
|
||||
|
||||
@@ -783,8 +783,8 @@ packages:
|
||||
shiki@2.1.0:
|
||||
resolution: {integrity: sha512-yvKPdNGLXZv7WC4bl7JBbU3CEcUxnBanvMez8MG3gZXKpClGL4bHqFyLhTx+2zUvbjClUANs/S22HXb7aeOgmA==}
|
||||
|
||||
source-map-js@1.2.1:
|
||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||
source-map-js@1.2.2:
|
||||
resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
space-separated-tokens@2.0.2:
|
||||
@@ -839,8 +839,8 @@ packages:
|
||||
vfile@6.0.3:
|
||||
resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==}
|
||||
|
||||
vite@5.4.14:
|
||||
resolution: {integrity: sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA==}
|
||||
vite@5.4.21:
|
||||
resolution: {integrity: sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==}
|
||||
engines: {node: ^18.0.0 || >=20.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
@@ -1302,9 +1302,9 @@ snapshots:
|
||||
|
||||
'@ungap/structured-clone@1.3.3': {}
|
||||
|
||||
'@vitejs/plugin-vue@5.2.1(vite@5.4.14)(vue@3.5.41)':
|
||||
'@vitejs/plugin-vue@5.2.1(vite@5.4.21)(vue@3.5.41)':
|
||||
dependencies:
|
||||
vite: 5.4.14
|
||||
vite: 5.4.21
|
||||
vue: 3.5.41
|
||||
|
||||
'@vue/compiler-core@3.5.41':
|
||||
@@ -1313,7 +1313,7 @@ snapshots:
|
||||
'@vue/shared': 3.5.41
|
||||
entities: 7.0.1
|
||||
estree-walker: 2.0.2
|
||||
source-map-js: 1.2.1
|
||||
source-map-js: 1.2.2
|
||||
|
||||
'@vue/compiler-dom@3.5.41':
|
||||
dependencies:
|
||||
@@ -1330,7 +1330,7 @@ snapshots:
|
||||
estree-walker: 2.0.2
|
||||
magic-string: 0.30.21
|
||||
postcss: 8.5.26
|
||||
source-map-js: 1.2.1
|
||||
source-map-js: 1.2.2
|
||||
|
||||
'@vue/compiler-ssr@3.5.41':
|
||||
dependencies:
|
||||
@@ -1603,7 +1603,7 @@ snapshots:
|
||||
dependencies:
|
||||
nanoid: 3.3.18
|
||||
picocolors: 1.1.1
|
||||
source-map-js: 1.2.1
|
||||
source-map-js: 1.2.2
|
||||
|
||||
preact@10.29.8: {}
|
||||
|
||||
@@ -1672,7 +1672,7 @@ snapshots:
|
||||
'@shikijs/vscode-textmate': 10.0.2
|
||||
'@types/hast': 3.0.5
|
||||
|
||||
source-map-js@1.2.1: {}
|
||||
source-map-js@1.2.2: {}
|
||||
|
||||
space-separated-tokens@2.0.2: {}
|
||||
|
||||
@@ -1733,7 +1733,7 @@ snapshots:
|
||||
'@types/unist': 3.0.3
|
||||
vfile-message: 4.0.3
|
||||
|
||||
vite@5.4.14:
|
||||
vite@5.4.21:
|
||||
dependencies:
|
||||
esbuild: 0.21.3
|
||||
postcss: 8.5.26
|
||||
@@ -1806,7 +1806,7 @@ snapshots:
|
||||
'@shikijs/transformers': 2.1.0
|
||||
'@shikijs/types': 2.1.0
|
||||
'@types/markdown-it': 14.1.2
|
||||
'@vitejs/plugin-vue': 5.2.1(vite@5.4.14)(vue@3.5.41)
|
||||
'@vitejs/plugin-vue': 5.2.1(vite@5.4.21)(vue@3.5.41)
|
||||
'@vue/devtools-api': 7.7.10
|
||||
'@vue/shared': 3.5.41
|
||||
'@vueuse/core': 12.4.0
|
||||
@@ -1815,7 +1815,7 @@ snapshots:
|
||||
mark.js: 8.11.1
|
||||
minisearch: 7.2.0
|
||||
shiki: 2.1.0
|
||||
vite: 5.4.14
|
||||
vite: 5.4.21
|
||||
vue: 3.5.41
|
||||
optionalDependencies:
|
||||
postcss: 8.5.26
|
||||
|
||||
@@ -1,16 +1,36 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onBeforeUnmount, ref } from 'vue';
|
||||
import { computed, nextTick, onMounted, onBeforeUnmount, ref } from 'vue';
|
||||
import { useDark, useToggle } from '@vueuse/core';
|
||||
import { Moon, Sunny, Expand } from '@element-plus/icons-vue';
|
||||
import { config } from '../config/index';
|
||||
|
||||
const isNarrow = ref(false);
|
||||
// ==================== 窄屏判定(水合前就必须定下来) ====================
|
||||
// 为什么不能等到 onMounted 才算:SSR 不知道视口宽度,只能按宽屏输出 ——
|
||||
// 于是整条桌面版顶栏菜单(10 个条目 + 分隔线 + 3 个下拉)会被下发给手机;
|
||||
// 水合时 isNarrow 还是 false,手机就先把这一整套水合一遍
|
||||
// (实测 375×812:header-menu 区域 268 次 DOM 变更、70 次事件绑定),
|
||||
// 紧接着 onMounted 把它改成窄屏、再整棵销毁重建 —— 这一整轮纯属白干。
|
||||
// 所以改成「服务端按请求头判定、客户端直接沿用服务端序列化下来的结论」,
|
||||
// 两边输入一致 ⇒ 结论一致 ⇒ 水合期不产生任何分歧,桌面上仍是原来的形态。
|
||||
// 权威值依旧由 onMounted 的 matchMedia 覆盖,管「桌面窗口被拖窄」这类请求头判不出的情形。
|
||||
//
|
||||
// 注意:**不要**在客户端重新嗅探 navigator.userAgent。SSR 页两边大概率巧合一致,
|
||||
// 但预渲染页没有请求头(服务端恒判宽屏),客户端一嗅探就必然分叉 ——
|
||||
// 实测那会让整个 /doc/** 在真手机上水合失配、Nuxt 直接渲染 500 页。
|
||||
// 判定逻辑与文档见 app/composables/useShellNarrow.ts。
|
||||
const isNarrow = useShellNarrow()
|
||||
let mediaQueryList: MediaQueryList | null = null;
|
||||
const drawer = ref(false);
|
||||
|
||||
const isDark = useDark();
|
||||
const toggleDark = useToggle(isDark);
|
||||
|
||||
// ==================== 抽屉里的文档菜单 ====================
|
||||
// 窄屏下 /doc 页面自己的左侧侧栏会被隐藏(见 app/pages/doc/*.vue),
|
||||
// 文档导航改由这里的抽屉承载;宽屏不渲染抽屉,一切照旧。
|
||||
const route = useRoute()
|
||||
const isDocRoute = computed(() => route.path === '/doc' || route.path.startsWith('/doc/'))
|
||||
|
||||
function cleanChineseCharacters(str:string) {
|
||||
return str.replace(/[\u4e00-\u9fa5]/g, '');
|
||||
}
|
||||
@@ -84,20 +104,90 @@ const hidden = computed<Array<NavItem | NavGroup>>(
|
||||
entry.kind !== 'divider' && viewportWidth.value < entry.minWidth),
|
||||
)
|
||||
|
||||
// EP 的 Menu.init() 会在挂载时(以及菜单项集合变化时)遍历顶栏 <ul> 的**每个直接子元素**、
|
||||
// 统一写 tabindex="0" —— 连纯装饰的分隔条也不放过。调用栈实测:
|
||||
// Menu.init → Array.forEach → new MenuItem(el).init → setAttribute('tabindex','0')
|
||||
// 分隔条是 aria-hidden 的装饰元素,留着 tabindex="0" 会被 axe 判为 aria-hidden-focus
|
||||
// ("Focusable content should have tabindex=-1 or be removed from the DOM")——
|
||||
// 这一条比它替换掉的 aria-required-attr 更靠后,所以必须显式改回去。
|
||||
// 改的时机:子组件 mounted 早于父组件,onMounted 里 EP 已经 init 完;
|
||||
// 但要等 DOM 更新落定 —— updateViewport() 会改 visible、让 el-menu 重渲染并再 init 一遍。
|
||||
function fixDividerTabindex() {
|
||||
document.querySelectorAll('.menu-divider').forEach((el) => {
|
||||
el.setAttribute('tabindex', '-1')
|
||||
})
|
||||
}
|
||||
|
||||
// 实时同步视口宽度(resize 触发,驱动折叠)
|
||||
function updateViewport() {
|
||||
viewportWidth.value = window.innerWidth
|
||||
nextTick(fixDividerTabindex)
|
||||
}
|
||||
let umamiScript: HTMLScriptElement | null = null
|
||||
|
||||
// ==================== 全站级 SEO 兜底 ====================
|
||||
// 以下标签对每一页生效,页面级 useHead 不必再重复声明(index/whois 原有的
|
||||
// canonical / og:url / twitter:card 已上收到这里,避免 head 出现两条 canonical)。
|
||||
//
|
||||
// canonical 按纯路径(不含 query):工具页普遍接受 ?ip= / ?site= 等参数,
|
||||
// 同一内容会以无限多组 query 变体出现,SEO 审计由此判定「sitemap 缺少重要页面」;
|
||||
// 统一收敛到裸路径,爬虫就不会把 ?ip=x 当独立页面收录。
|
||||
const siteOrigin = config.siteUrl.endsWith('/') ? config.siteUrl : config.siteUrl + '/'
|
||||
const canonicalUrl = computed(() => new URL(route.path, siteOrigin).href)
|
||||
// 站点级结构化数据(WebSite + Organization):给搜索引擎的实体锚点,
|
||||
// 各工具页的 WebApplication 与文档页的 BreadcrumbList 通过 url 与之关联。
|
||||
const siteJsonLd = JSON.stringify({
|
||||
'@context': 'https://schema.org',
|
||||
'@graph': [
|
||||
{
|
||||
'@type': 'WebSite',
|
||||
'@id': siteOrigin + '#website',
|
||||
name: config.siteName,
|
||||
alternateName: 'Lemon IPW',
|
||||
url: siteOrigin,
|
||||
inLanguage: 'zh-CN',
|
||||
description: '专业IP查询与网络测试工具平台:IPv4/IPv6地址查询、归属地定位、网站测速、DNS解析、SSL证书检测、TCPing、Whois查询。'
|
||||
},
|
||||
{
|
||||
'@type': 'Organization',
|
||||
'@id': siteOrigin + '#organization',
|
||||
name: config.siteName,
|
||||
url: siteOrigin,
|
||||
logo: siteOrigin + 'favicon.svg',
|
||||
sameAs: ['https://github.com/nomdn/ipw-cn']
|
||||
}
|
||||
]
|
||||
})
|
||||
useHead({
|
||||
// 页面没写 title 时的兜底(正常页面各自已带完整标题)
|
||||
titleTemplate: (title?: string) => title || config.siteName,
|
||||
link: [
|
||||
{ rel: 'canonical', href: canonicalUrl },
|
||||
],
|
||||
meta: config.noindex
|
||||
? [
|
||||
{ name: 'robots', content: 'noindex, nofollow' },
|
||||
{ name: 'googlebot', content: 'noindex, nofollow' },
|
||||
{ name: 'bingbot', content: 'noindex, nofollow' },
|
||||
{ name:'baidu-site-verification', content: 'codeva-xzdbvF8gQu'}
|
||||
{ name:'baidu-site-verification', content: 'codeva-xzdbvF8gQu'},
|
||||
{ property: 'og:url', content: canonicalUrl },
|
||||
{ property: 'og:site_name', content: config.siteName },
|
||||
{ property: 'og:locale', content: 'zh_CN' },
|
||||
{ name: 'twitter:card', content: 'summary_large_image' },
|
||||
]
|
||||
: [{ name:'baidu-site-verification', content: 'codeva-xzdbvF8gQu'}],
|
||||
: [
|
||||
{ name:'baidu-site-verification', content: 'codeva-xzdbvF8gQu'},
|
||||
{ property: 'og:url', content: canonicalUrl },
|
||||
{ property: 'og:site_name', content: config.siteName },
|
||||
{ property: 'og:locale', content: 'zh_CN' },
|
||||
{ name: 'twitter:card', content: 'summary_large_image' },
|
||||
],
|
||||
script: [
|
||||
{
|
||||
type: 'application/ld+json',
|
||||
innerHTML: siteJsonLd,
|
||||
}
|
||||
]
|
||||
});
|
||||
onMounted(() => {
|
||||
mediaQueryList = window.matchMedia('(max-width: 768px)');
|
||||
@@ -117,19 +207,28 @@ onMounted(() => {
|
||||
window.removeEventListener('resize', updateViewport);
|
||||
});
|
||||
|
||||
if (!umamiScript && config.umamiScriptUrl) {
|
||||
// 统计脚本延迟到浏览器空闲再注入:umami 源响应慢(实测 ~1.6s),
|
||||
// 挂在 onMounted 里会和首页首屏的拨测请求抢慢速网络的带宽,
|
||||
// 拖累 Speed Index;统计本身不需要抢首屏前的任何窗口。
|
||||
const loadUmami = () => {
|
||||
if (umamiScript || !config.umamiScriptUrl) return
|
||||
umamiScript = document.createElement('script')
|
||||
umamiScript.src = config.umamiScriptUrl
|
||||
umamiScript.async = true
|
||||
umamiScript.setAttribute('data-website-id', config.umamiWebsiteId)
|
||||
document.head.appendChild(umamiScript)
|
||||
}
|
||||
if ('requestIdleCallback' in window) {
|
||||
requestIdleCallback(loadUmami, { timeout: 4000 })
|
||||
} else {
|
||||
setTimeout(loadUmami, 2000)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
<el-drawer v-if="isNarrow" v-model="drawer" direction="ltr" style="height: 100%;" size="50%">
|
||||
<el-drawer v-if="isNarrow" v-model="drawer" direction="ltr" style="height: 100%;" :size="isDocRoute ? '80%' : '60%'">
|
||||
<router-link to="/ipv6webcheck">
|
||||
<p class="menu-item-text">IPv6 网站检测</p>
|
||||
</router-link>
|
||||
@@ -150,16 +249,46 @@ onMounted(() => {
|
||||
<router-link to="/whois"><p class="menu-item-text">Whois查询</p></router-link>
|
||||
<router-link to="/asn"><p class="menu-item-text">ASN查询</p></router-link>
|
||||
<router-link to="/dnssec"><p class="menu-item-text">DNSSEC验证</p></router-link>
|
||||
<!-- 窄屏唯一的文档入口:非文档页面抽屉里不挂整份文档菜单(太长),
|
||||
只留这一个链接,对应宽屏顶栏 index 9 的「文档」项。
|
||||
进入文档页后,抽屉里才会出现完整的文档导航。 -->
|
||||
<router-link v-if="!isDocRoute" to="/doc" @click="drawer = false"><p class="menu-item-text">文档</p></router-link>
|
||||
<!-- 文档导航并进同一个左侧菜单:与 /doc 页面用的是同一个组件。
|
||||
只在文档路由下出现(非文档页面抽屉里就只留工具链接);
|
||||
文档路由下分组默认展开(手机上没 hover,省一次点击)。
|
||||
:key 是为了让分组开合重新初始化 —— el-menu 只在挂载时读一次 default-openeds,
|
||||
抽屉一旦打开过就不会重挂,不加 key 会停在首次打开时的开合状态。 -->
|
||||
<DocMenu
|
||||
v-if="isDocRoute"
|
||||
:key="'doc-expanded'"
|
||||
expand-all
|
||||
@select="drawer = false"
|
||||
/>
|
||||
</el-drawer>
|
||||
<el-menu
|
||||
mode="horizontal"
|
||||
:ellipsis="false"
|
||||
|
||||
>
|
||||
<el-menu-item index="0">
|
||||
<!-- 宽屏不给 aria-label:这个 <li> 里有可见文本(右侧的 h2 站名),而 axe 的
|
||||
label-content-name-mismatch 要求 aria-label 必须把可见文本包含进去 ——
|
||||
写死「返回首页」只会被判不匹配(Lighthouse 桌面独有项,权重 0 不扣分,但语义是错的)。
|
||||
窄屏 h2 被 v-if 隐藏、img 的 alt 留空、el-icon 也没有文本 ⇒ 那时才需要
|
||||
aria-label 兜底,否则承载 role="menuitem" 的 <li> 就没有可访问名(aria-command-name)。
|
||||
里面那个 <router-link> 同理(它自己也是一个可访问名有冲突的目标),
|
||||
宽屏靠 h2 的「柠檬味ipw.cn」当名字,窄屏才补「返回首页」。 -->
|
||||
<el-menu-item index="0" :aria-label="isNarrow ? '返回首页' : undefined">
|
||||
<el-icon v-if="isNarrow" @click="drawer = !drawer"><Expand /></el-icon>
|
||||
<router-link to="/">
|
||||
<el-image src="/favicon.svg" style="margin-top: 20px;" />
|
||||
<router-link to="/" :aria-label="isNarrow ? '返回首页' : undefined">
|
||||
<!-- alt 留空是有意的:logo 属装饰图,可访问名由外层链接提供。
|
||||
若把 alt 写成站名,宽屏下会与旁边的 h2 一起被读两遍。
|
||||
这里用原生 <img> 而不是 el-image:el-image 默认 lazy,SSR 只输出一个
|
||||
`.el-image__placeholder` 空壳,真正的 <img> 要等客户端水合后由
|
||||
IntersectionObserver 插进去 ⇒ logo 在首屏 HTML 里不存在(无 JS 时永不显示,
|
||||
有 JS 时也要闪一下)。原生 <img> 直接进 HTML,还顺带省掉 el-image
|
||||
及其 image-viewer 的样式。宽高属性声明固有比例,显示宽度由下文
|
||||
:deep(.el-menu-item a img) 定为 50px。 -->
|
||||
<img src="/favicon.svg" alt="" width="50" height="50" style="margin-top: 20px;" />
|
||||
<h2 style="display: inline-block; margin-left: 10px" v-if="!isNarrow">{{ config.siteName }}</h2>
|
||||
</router-link>
|
||||
</el-menu-item>
|
||||
@@ -176,7 +305,13 @@ onMounted(() => {
|
||||
<router-link :to="child.to"><p class="menu-item-text">{{ child.label }}</p></router-link>
|
||||
</el-menu-item>
|
||||
</el-sub-menu>
|
||||
<el-divider v-else style="margin-top: 20px;height: 1.2em;" direction="vertical"/>
|
||||
<!-- 分组之间的竖分隔条。原来是 <el-divider direction="vertical">,但它在客户端水合后
|
||||
会被 EP 补上 tabindex="0"(SSR HTML 里干净、没有这个属性),于是 axe 把
|
||||
role="separator" 当成「可聚焦控件」并要求它带 aria-valuenow —— 这就是桌面端
|
||||
aria-required-attr 那一条(Lighthouse 权重 10,是桌面 a11y 掉 12 分里的最大单项)。
|
||||
换成 aria-hidden 的原生 <span>:装饰元素不参与焦点,也不会被 EP 改写属性。
|
||||
视觉与 .el-divider--vertical 等价,数值见下方 .menu-divider 的注释。 -->
|
||||
<span v-else class="menu-divider" aria-hidden="true"></span>
|
||||
</template>
|
||||
<!-- 折叠项:统一收进「更多」子菜单(分组用 el-menu-item-group 保留组名) -->
|
||||
<el-sub-menu v-if="hidden.length" index="more">
|
||||
@@ -193,7 +328,8 @@ onMounted(() => {
|
||||
</template>
|
||||
</el-sub-menu>
|
||||
</template>
|
||||
<el-menu-item index="10">
|
||||
<!-- 纯图标菜单项:无可访问名,补 aria-label(图标本身不带文字) -->
|
||||
<el-menu-item index="10" aria-label="切换深色/浅色模式">
|
||||
<ClientOnly>
|
||||
<el-icon @click="toggleDark()" v-if="isDark" style="cursor: pointer;"><Moon style="height: 20px; width: 20px;"/></el-icon>
|
||||
<el-icon @click="toggleDark()" v-else style="cursor: pointer;"><Sunny style="height: 20px; width: 20px;"/></el-icon>
|
||||
@@ -208,15 +344,24 @@ onMounted(() => {
|
||||
<NuxtPage />
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<!-- 文档路由不渲染页脚:文档页是阅读页,正文底部加备案/版权块会打断阅读,
|
||||
且窄屏下与侧栏抽屉的可滚动区域互相挤压。 -->
|
||||
<footer v-if="!isDocRoute">
|
||||
<div class="one-line">
|
||||
Copyright © nomdn & IP 查询 2026 | <img src="/ipv6-s1.svg" alt="IPv6 相关标识"/> | <img src="/ssl-s1.svg" alt="SSL 相关标识"/> | All right reserved
|
||||
<!-- 这两张 svg 补上 width/height 属性(= 各自的固有尺寸 190×36 / 85×36):
|
||||
浏览器要在图下载完之前就知道占位比例,否则会先把整行按 0 高度排一遍、
|
||||
图到了再重排(Lighthouse 的 unsized-images 就是这条)。
|
||||
属性只声明固有比例,不改变显示尺寸:桌面端本来就是按固有尺寸渲染,
|
||||
窄屏由 style.css 的 `footer .one-line img { height:1.2em; width:auto }` 接管。 -->
|
||||
Copyright © nomdn & IP 查询 2026 | <img src="/ipv6-s1.svg" alt="IPv6 相关标识" width="190" height="36"/> | <img src="/ssl-s1.svg" alt="SSL 相关标识" width="85" height="36"/> | All right reserved
|
||||
</div>
|
||||
<div class="one-line">
|
||||
<a v-if="config.ICP" href="https://beian.miit.gov.cn/" target="_blank" rel="noreferrer" >{{ config.ICP }}</a>
|
||||
<span v-if="config.ICP"> | </span>
|
||||
<el-image v-if="config.GongAn" style="height: 1em; width: 1em;" src="/备案图标.png" />
|
||||
<a :href="'https://beian.mps.gov.cn/#/query/webSearch?code=' + cleanChineseCharacters(config.GongAn)" target="_blank" rel="noreferrer" >{{ config.GongAn }}</a>
|
||||
<!-- 同上:原生 <img> 而非 el-image(1em 见方的小图标,用不着 lazy/预览器)。
|
||||
显示尺寸由行内 style 定死;width/height 属性只声明固有比例(36×40),防抖动。 -->
|
||||
<img v-if="config.GongAn" src="/备案图标.png" alt="" width="36" height="40" style="height: 1em; width: 1em;" />
|
||||
<a v-if="config.GongAn" :href="'https://beian.mps.gov.cn/#/query/webSearch?code=' + cleanChineseCharacters(config.GongAn)" target="_blank" rel="noreferrer" >{{ config.GongAn }}</a>
|
||||
<span v-if="config.GongAn"> | </span>
|
||||
<a href="https://www.china-ipv6.cn/" target="_blank" rel="noreferrer" >国家IPv6发展监测平台</a>
|
||||
| 请遵守中国法律法规 |
|
||||
@@ -228,6 +373,8 @@ onMounted(() => {
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- 全站文档图片灯箱:委托拦截 .markdown / .markdown-body 内的图片点击 -->
|
||||
<ImageLightbox />
|
||||
</template>
|
||||
<style scoped>
|
||||
@import "~/style.css";
|
||||
@@ -262,41 +409,107 @@ onMounted(() => {
|
||||
margin-bottom: 20px;
|
||||
|
||||
}
|
||||
/* 顶栏分组之间的竖分隔条(template 里那个 aria-hidden 的 span)。
|
||||
数值抄自 element-plus 的 .el-divider--vertical:1px 左边框、1.2em 高、
|
||||
margin 左右各 8px、vertical-align: middle;再加上原来行内 style 的 margin-top: 20px
|
||||
与 height: 1.2em,保证与替换前的排布一致。 */
|
||||
.menu-divider {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
width: 1px;
|
||||
height: 1.2em;
|
||||
margin: 20px 8px 0;
|
||||
vertical-align: middle;
|
||||
border-left: 1px solid var(--el-border-color);
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
/* 正文/页脚链接色:亮色白底需 ≥4.5:1(axe color-contrast 审计线)。
|
||||
#299764 白底只有 3.68:1,加深到 #1d7a4a = 5.34:1,留足余量。
|
||||
主题色(按钮/高亮等 --el-color-primary 消费方)保持 #299764 不动,只分流链接。 */
|
||||
--link-color: #1d7a4a;
|
||||
}
|
||||
html.dark {
|
||||
--el-color-primary: #3EAF7C;
|
||||
/* 暗色模式下根元素的文字色与页面底色。
|
||||
这两条必须在【非 scoped】块里:<html> 永远不会带上组件 scope 属性,
|
||||
若写在 <style scoped>(含被 scoped @import 进来的 style.css)里,会被改写成
|
||||
`html.dark[data-v-xxxx]` —— 整条规则永不匹配,底色只能靠浏览器的 color-scheme 兜底。 */
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
--el-color-primary: #299764;
|
||||
/* 暗底 #242424 上 #299764 对比 ~4.2:1,且再加深只会更差 —— 暗色链接保持原色 */
|
||||
--link-color: #299764;
|
||||
}
|
||||
|
||||
/* Drawer 内部链接占满一行 */
|
||||
/* Drawer 内部链接占满一行。
|
||||
注意用直接子选择器(> a):文档菜单(DocMenu)里的 <a> 嵌在 el-menu-item 里,
|
||||
不能被这套「整行大按钮」规则吃掉,否则菜单项会变成上下带 1em 内边距的块。
|
||||
间距三层叠加会挤没文字(body 20px + a 1em + p margin-left 10px),
|
||||
所以 body 归零、a 只留一层、p 的 margin 清掉,字号定死 15px 保证最长的
|
||||
「IPv6/IPv4 地址查询」在 320px 屏的 60% 抽屉里也放得下。 */
|
||||
.el-drawer__body {
|
||||
overflow-x: hidden;
|
||||
padding: 6px 0;
|
||||
font-size: 15px;
|
||||
}
|
||||
.el-drawer__body a {
|
||||
.el-drawer__body > a {
|
||||
display: block !important;
|
||||
width: 100% !important;
|
||||
box-sizing: border-box;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
padding: 1em;
|
||||
padding: 12px 16px;
|
||||
font-size: 15px;
|
||||
}
|
||||
.el-drawer__body a p {
|
||||
.el-drawer__body > a p.menu-item-text {
|
||||
display: block !important;
|
||||
width: 100% !important;
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* 并进抽屉的文档菜单:与上面的工具链接视觉上分段,并去掉菜单自带底色与右边框
|
||||
(.el-menu 默认 border-right,竖排菜单是给页面侧栏用的,在抽屉里会多出一条竖线) */
|
||||
.el-drawer__body .el-menu {
|
||||
background-color: transparent;
|
||||
border-right: none;
|
||||
border-top: 1px solid var(--el-border-color-lighter);
|
||||
padding-top: 8px;
|
||||
}
|
||||
/* 手机上条目多,行高压到 44px 让一屏能多看几项(默认 56px)。
|
||||
文档标题可能很长(如「Windows 10/11 设置 IPv4/IPv6 访问优先级」),
|
||||
截断会丢信息 → 允许换行,高度改 auto 只保 44px 最小行高。 */
|
||||
/* 手机上条目多,行高压到 44px 让一屏能多看几项(默认 56px)。
|
||||
注意:element-plus 竖排菜单规则是
|
||||
`.el-menu--vertical:not(..)×3 .el-menu-item`(特异性 5 个类),
|
||||
这里必须 !important 才压得住 height / line-height / white-space。
|
||||
文档标题可能很长(如「Windows 10/11 设置 IPv4/IPv6 访问优先级」),
|
||||
截断会丢信息 → 允许换行,高度改 auto 只保 44px 最小行高。 */
|
||||
.el-drawer__body .el-menu .el-menu-item,
|
||||
.el-drawer__body .el-menu .el-sub-menu__title {
|
||||
height: auto !important;
|
||||
min-height: 44px;
|
||||
line-height: 1.45 !important;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
white-space: normal !important; /* 长标题裸文本在 li 上,必须解掉 nowrap */
|
||||
}
|
||||
.el-drawer__body .el-menu .el-menu-item a,
|
||||
.el-drawer__body .el-menu .el-menu-item p {
|
||||
white-space: normal;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* 窄屏(≤768px,与 script 中 isNarrow 的 matchMedia 断点一致):
|
||||
在水合前由 CSS 兜底隐藏宽屏菜单项,避免窄屏设备闪现宽屏布局 */
|
||||
@media (max-width: 768px) {
|
||||
.el-menu--horizontal > .el-divider {
|
||||
.el-menu--horizontal > .menu-divider {
|
||||
display: none !important;
|
||||
}
|
||||
.el-menu--horizontal > .el-menu-item[index="1"],
|
||||
@@ -318,6 +531,39 @@ html.dark {
|
||||
--el-menu-bg-color: transparent !important;
|
||||
}
|
||||
|
||||
/* 顶栏菜单项的点击目标:让内层 <a> 撑满整个 <li>。
|
||||
axe 的 target-size(WCAG 2.2 的 2.5.8,24×24 最小目标)会把 <li role="menuitem">
|
||||
减掉内层 <a> 之后剩下的「侧翼」算成被遮挡的空间:EP 默认给 li 左右各 20px 内边距,
|
||||
而 <a> 只占中间 97px 宽,于是报
|
||||
"partially obscured (smallest space is 20px by 59px)" —— 桌面 7 条、权重 7。
|
||||
有两条路:① 把 --el-menu-base-level-padding 提到 >24px —— 顶栏整体就变宽,
|
||||
1350px 下直接横向溢出 45px(各档折叠阈值还得跟着重算);② 让 <a> 撑满 li —— 本条。
|
||||
选②:li 宽度、文字位置、分隔条位置与改动前【逐像素一致】(CDP 量 rect 比对过),
|
||||
可点区域却从 97×59 变成整项 137×59,远超 24×24。
|
||||
- flex + align-items:center 是为了复现原来 inline 盒子靠 line-height 得到的垂直居中
|
||||
(logo 的 img 顶边仍在 li 顶 +4.5px 处,改完不位移);
|
||||
- 负 margin 抵消 li 的左右内边距,与 padding 取同一个变量,改内边距时不会脱节;
|
||||
- height:100% 成立是因为 EP 给 .el-menu-item 写了确定的 height(--el-menu-item-height)。
|
||||
必须写在这个【非 scoped】块里:el-menu 是 fragment 根,scope 属性在它自己身上而不是
|
||||
祖先,<style scoped> 里的 :deep(.el-menu--horizontal) 选不到它。
|
||||
只作用于顶栏这条 ul —— sub-menu 的弹层被 teleport 到 body,跑不到这个选择器下。 */
|
||||
.el-menu--horizontal > .el-menu-item > a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
height: 100%;
|
||||
margin: 0 calc(-1 * var(--el-menu-base-level-padding));
|
||||
padding: 0 var(--el-menu-base-level-padding);
|
||||
}
|
||||
|
||||
/* logo 那个 <a> 单独放开 overflow(选择器多一层 :nth-child(1),免得靠书写顺序
|
||||
去压 scoped 块里 :deep(.el-menu-item a) 的 overflow:hidden)。
|
||||
它的 img 带 20px 上下外边距、总高 90px 塞在 59px 的 li 里:原来 <a> 是 inline
|
||||
元素、overflow 本来就不生效才没被裁;上面改成 flex 后若不显式放开,logo 会被切掉。 */
|
||||
.el-menu--horizontal > .el-menu-item:nth-child(1) > a {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.el-menu--horizontal > .el-menu-item:nth-child(1) {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,267 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { isIPv6 } from 'is-ip'
|
||||
|
||||
/**
|
||||
* 高级选项:请求级解析参数(与 ipw-ak 的 AdvancedOptions 同源)
|
||||
*
|
||||
* - 展开后按地址族分列:IPv4 → dns4 / resolve4,IPv6 → dns6 / resolve6
|
||||
* - stack 非空时(单栈页)只渲染对应栈那一列,且不显示 dns / resolve 通用行:
|
||||
* 单栈页里两者与 dns4=/dns6= 等价,双份输入框只会让人纠结该填哪个;
|
||||
* tcping / speed 的前端两个栈是分开的页面,另一列的参数永远吃不到。
|
||||
* - dns / resolve 是双栈页的两栈通用兜底,dns4/dns6、resolve4/resolve6 非空时覆盖它们。
|
||||
*
|
||||
* 用法:
|
||||
* <AdvancedOptions ref="adv" /> 双栈页(dns4/dns6 + resolve4/resolve6)
|
||||
* <AdvancedOptions ref="adv" stack="ipv4" /> 单栈页,只给 IPv4 一列
|
||||
* <AdvancedOptions ref="adv" :show-resolve="false" /> 仅 dns4/dns6(dns、whois 页不支持强制解析)
|
||||
*
|
||||
* 页面里取参数:
|
||||
* withQuery(baseUrl, adv.value?.query() ?? {})
|
||||
*/
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** 是否显示 resolve / resolve4 / resolve6(dns、whois 页不支持强制解析) */
|
||||
showResolve?: boolean
|
||||
/** 只显示某一栈的配置项;单栈页面(tcping / speed 的 v4、v6 页)传,双栈页面不传 */
|
||||
stack?: 'ipv4' | 'ipv6' | ''
|
||||
}>(),
|
||||
{ showResolve: true, stack: '' },
|
||||
)
|
||||
|
||||
const expanded = ref(false)
|
||||
/** 两栈通用的 DNS 服务器:dns4/dns6 非空时覆盖它 */
|
||||
const dns = ref('')
|
||||
const dns4 = ref('')
|
||||
const dns6 = ref('')
|
||||
/** 两栈通用的强制解析:resolve4/resolve6 非空时覆盖它 */
|
||||
const resolve = ref('')
|
||||
const resolve4 = ref('')
|
||||
const resolve6 = ref('')
|
||||
|
||||
/** 域名 HOST 判定:含点、标签为字母数字/连字符/下划线(宽松匹配,畸形值交给后端报错) */
|
||||
const DOMAIN_RE = /^[a-z0-9_](?:[a-z0-9_-]*[a-z0-9_])?(?:\.[a-z0-9_](?:[a-z0-9_-]*[a-z0-9_])?)+$/i
|
||||
const IPV4_RE = /^\d{1,3}(?:\.\d{1,3}){3}$/
|
||||
|
||||
/**
|
||||
* 把用户输入的单个 DNS 服务器条目规整成后端认可的形式:
|
||||
* - 已带协议的 URL:路径为空或仅 "/" 时补上 DoH 标准路径 /dns-query
|
||||
* - 无协议但含 "/"(缺了 scheme 的 DoH 地址):补 https:// 前缀,路径按上条处理
|
||||
* - 纯域名 HOST(无端口无路径):包裹为 https://域名/dns-query
|
||||
* - 无端口的裸 IP(v4 / 裸 v6):补默认端口 53(v6 顺手加方括号)
|
||||
* - 其余(host:port、[v6]:53 等)原样返回,交给后端校验
|
||||
*/
|
||||
function normalizeDnsEntry(raw: string): string {
|
||||
const v = raw.trim()
|
||||
if (!v) return ''
|
||||
|
||||
// 1) 已带协议的 URL
|
||||
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(v)) return completeDohPath(v)
|
||||
// 2) 无协议但含 "/":缺 scheme 的 DoH 地址
|
||||
if (v.includes('/')) return completeDohPath('https://' + v)
|
||||
// 3) 带方括号的 v6(含/含端口均原样,端口要求交后端校验)
|
||||
if (v.startsWith('[')) return v
|
||||
// 4) host:port:IP 或域名都按 UDP 语义原样(写了端口就尊重端口)
|
||||
if (/^[^:]+:\d+$/.test(v)) return v
|
||||
// 5) 无方括号的裸 v6:补 [..]:53
|
||||
if (isIPv6(v)) return `[${v}]:53`
|
||||
// 6) 裸 IPv4:补 :53
|
||||
if (IPV4_RE.test(v)) return `${v}:53`
|
||||
// 7) 纯域名 HOST:包裹为标准 DoH URL
|
||||
if (DOMAIN_RE.test(v)) return `https://${v}/dns-query`
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
/** 补齐 DoH URL 的标准路径:空路径/根路径 → /dns-query;自带路径(如 /custom)原样保留 */
|
||||
function completeDohPath(url: string): string {
|
||||
try {
|
||||
const u = new URL(url)
|
||||
if (!u.hostname) return url
|
||||
if (u.pathname === '/' || u.pathname === '') u.pathname = '/dns-query'
|
||||
return u.toString()
|
||||
} catch {
|
||||
return url
|
||||
}
|
||||
}
|
||||
|
||||
/** 逗号分隔列表逐项规整(空项丢弃) */
|
||||
function normalizeDnsList(value: string): string {
|
||||
return value
|
||||
.split(',')
|
||||
.map(p => normalizeDnsEntry(p))
|
||||
.filter(Boolean)
|
||||
.join(',')
|
||||
}
|
||||
|
||||
/** 组装请求级解析参数(空值不下发;DNS 服务器逐项规整) */
|
||||
function query(): Record<string, string> {
|
||||
const q: Record<string, string> = {}
|
||||
if (dns.value.trim()) q.dns = normalizeDnsList(dns.value)
|
||||
if (dns4.value.trim()) q.dns4 = normalizeDnsList(dns4.value)
|
||||
if (dns6.value.trim()) q.dns6 = normalizeDnsList(dns6.value)
|
||||
if (props.showResolve) {
|
||||
if (resolve.value.trim()) q.resolve = resolve.value.trim()
|
||||
if (resolve4.value.trim()) q.resolve4 = resolve4.value.trim()
|
||||
if (resolve6.value.trim()) q.resolve6 = resolve6.value.trim()
|
||||
}
|
||||
return q
|
||||
}
|
||||
|
||||
defineExpose({ query })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="adv">
|
||||
<!-- 用原生 button:页面的全局 .el-button{width:165px} 会把 el-button 撑成实心大按钮 -->
|
||||
<button type="button" class="adv__toggle" :aria-expanded="expanded" @click="expanded = !expanded">
|
||||
<span class="adv__caret" :class="{ 'is-open': expanded }">▸</span>
|
||||
<span>高级选项</span>
|
||||
</button>
|
||||
|
||||
<div v-if="expanded" class="adv__body">
|
||||
<!-- 两栈通用的 DNS 服务器(dns4/dns6 非空时覆盖它)。仅双栈页显示:
|
||||
单栈页里 dns= 与 dns4=/dns6= 对该栈请求效果等价(后端按栈取值),
|
||||
再给一个"两栈通用"行只会让人纠结该填哪个 —— 单栈只留对应栈那一列。 -->
|
||||
<div v-if="!stack" class="adv__field adv__field--wide">
|
||||
<span class="adv__label">DNS 服务器(dns,两栈通用)</span>
|
||||
<el-input v-model="dns" clearable placeholder="如 1.1.1.1:53 / doh.pub / dns.google,逗号分隔" />
|
||||
</div>
|
||||
|
||||
<!-- 两栈通用的强制解析(resolve4/6 非空时覆盖它),同上仅双栈页显示 -->
|
||||
<div v-if="!stack && showResolve" class="adv__field adv__field--wide">
|
||||
<span class="adv__label">强制解析(resolve,两栈通用)</span>
|
||||
<el-input v-model="resolve" clearable placeholder="如 example.com:1.2.3.4,逗号分隔" />
|
||||
</div>
|
||||
|
||||
<div class="adv__grid" :class="{ 'is-single': !!stack }">
|
||||
<section v-if="!stack || stack === 'ipv4'" class="adv__col">
|
||||
<h4 class="adv__col-title">IPv4</h4>
|
||||
<div class="adv__field">
|
||||
<span class="adv__label">DNS 服务器(dns4)</span>
|
||||
<el-input v-model="dns4" clearable placeholder="如 1.1.1.1:53 / doh.pub,逗号分隔" />
|
||||
</div>
|
||||
<div v-if="showResolve" class="adv__field">
|
||||
<span class="adv__label">强制解析(resolve4)</span>
|
||||
<el-input v-model="resolve4" clearable placeholder="如 example.com:1.2.3.4" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="!stack || stack === 'ipv6'" class="adv__col">
|
||||
<h4 class="adv__col-title">IPv6</h4>
|
||||
<div class="adv__field">
|
||||
<span class="adv__label">DNS 服务器(dns6)</span>
|
||||
<el-input v-model="dns6" clearable placeholder="如 [2400:3200::1]:53,逗号分隔" />
|
||||
</div>
|
||||
<div v-if="showResolve" class="adv__field">
|
||||
<span class="adv__label">强制解析(resolve6)</span>
|
||||
<el-input v-model="resolve6" clearable placeholder="如 example.com:[::1]" />
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<p class="adv__hint">
|
||||
DNS 服务器可填 <code>ip:port</code>、DoH 地址或纯域名(自动补全为
|
||||
<code>https://域名/dns-query</code>),逗号分隔多个;强制解析格式
|
||||
<code>域名:IP</code> 或 <code>域名:CNAME</code>,IPv6 目标写 <code>[::1]</code>。{{
|
||||
stack ? '参数直接作用于本栈解析;双栈页的 dns / resolve 通用项在此页不展示。'
|
||||
: 'dns4 / dns6、resolve4 / resolve6 非空时覆盖 dns / resolve,分别只作用于对应栈。'
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.adv {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.adv__toggle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
width: auto;
|
||||
height: auto;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--el-color-primary, #299764);
|
||||
font: inherit;
|
||||
font-size: 0.85rem;
|
||||
letter-spacing: 0.03em;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.adv__caret {
|
||||
display: inline-block;
|
||||
font-size: 0.7rem;
|
||||
transition: transform 150ms ease;
|
||||
}
|
||||
|
||||
.adv__caret.is-open {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.adv__body {
|
||||
margin-top: 0.5rem;
|
||||
padding: 0.75rem 0.9rem;
|
||||
border: 1px solid var(--el-border-color-lighter, #ebeef5);
|
||||
border-radius: 6px;
|
||||
background: var(--el-fill-color-lighter, #fafafa);
|
||||
}
|
||||
|
||||
.adv__grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0 1rem;
|
||||
}
|
||||
|
||||
/* 单栈页只渲染一列:撑满,别再留半幅空白 */
|
||||
.adv__grid.is-single {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.adv__col-title {
|
||||
margin: 0 0 0.4rem;
|
||||
font-size: 0.8rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
color: var(--el-text-color-secondary, #909399);
|
||||
}
|
||||
|
||||
.adv__field {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.adv__field--wide {
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.adv__label {
|
||||
display: block;
|
||||
margin-bottom: 0.25rem;
|
||||
font-size: 0.78rem;
|
||||
color: var(--el-text-color-secondary, #909399);
|
||||
}
|
||||
|
||||
.adv__hint {
|
||||
margin: 0.35rem 0 0;
|
||||
font-size: 0.75rem;
|
||||
line-height: 1.6;
|
||||
color: var(--el-text-color-secondary, #909399);
|
||||
}
|
||||
|
||||
.adv__hint code {
|
||||
padding: 0 0.2rem;
|
||||
border-radius: 2px;
|
||||
background: var(--el-fill-color, #f0f2f5);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.adv__grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,111 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* 文档导航菜单(全站唯一实现,结构别在别处再抄一份)
|
||||
*
|
||||
* - 宽屏:由 /doc 与 /doc/** 页面直接渲染成左侧固定侧边栏(由页面传 class="sidebar-menu")
|
||||
* - 窄屏:页面那边把侧边栏整个隐藏,改由根布局的左侧抽屉菜单挂同一份本组件,
|
||||
* 这样手机上不需要两个菜单,也不至于没入口进文档。
|
||||
*/
|
||||
const route = useRoute()
|
||||
const activeIndex = computed(() => route.path)
|
||||
|
||||
// 所有可展开分组的 index(含嵌套的「最佳实践」)。
|
||||
// 抽屉里给展开态用:手机上没有 hover,分组默认收着的话用户还得先点开一层才能看到目的地。
|
||||
const ALL_GROUPS = [
|
||||
'IPv6 用户端',
|
||||
'最佳实践',
|
||||
'云服务器配置 IPv6',
|
||||
'IPv6 协议规范',
|
||||
'API 接口',
|
||||
]
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
/** true = 所有分组初始展开(抽屉用);false = 保持 element-plus 默认的收起态(页面侧栏用) */
|
||||
expandAll?: boolean
|
||||
}>(), { expandAll: false })
|
||||
|
||||
// undefined 让 element-plus 走自己的默认值,宽屏下行为与改造前完全一致
|
||||
const openeds = computed(() => (props.expandAll ? ALL_GROUPS : undefined))
|
||||
|
||||
const emit = defineEmits<{ select: [index: string] }>()
|
||||
</script>
|
||||
<template>
|
||||
<el-menu
|
||||
:default-active="activeIndex"
|
||||
:default-openeds="openeds"
|
||||
router
|
||||
@select="(index: string) => emit('select', index)"
|
||||
>
|
||||
<!-- 1. 独立菜单项 -->
|
||||
<el-menu-item index="/doc">
|
||||
<span>IPv6 工具箱使用文档</span>
|
||||
</el-menu-item>
|
||||
|
||||
<!-- 2. IPv6 用户端 -->
|
||||
<el-sub-menu index="IPv6 用户端">
|
||||
<template #title>
|
||||
<span>IPv6 用户端</span>
|
||||
</template>
|
||||
|
||||
<el-menu-item index="/doc/user/enable_ipv6">个人宽带如何开启IPv6网络访问</el-menu-item>
|
||||
<el-menu-item index="/doc/user/cmd_bash_disable_ipv6">命令行禁用/启用IPv6本地网络</el-menu-item>
|
||||
<el-menu-item index="/doc/user/cmd_getip">命令行(curl)获取 IPv4 和 IPv6 地址</el-menu-item>
|
||||
<el-menu-item index="/doc/user/view_ipv6_adress_url">浏览器访问 IPv6 地址</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv4_ipv6_prefix_precedence">Windows 10/11 设置 IPv4/IPv6 访问优先级</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv6_daohang">国内 IPv6 资源导航</el-menu-item>
|
||||
<el-menu-item index="/doc/user/pure_ipv6_website">国内纯 IPv6 网站导航</el-menu-item>
|
||||
<el-menu-item index="/doc/user/dns">全国各省 DNS 服务器列表</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv6_dns">IPv6 DNS 地址列表</el-menu-item>
|
||||
<el-menu-item index="/doc/user/code_getip">Python/Go 获取 IPv4 和 IPv6 地址</el-menu-item>
|
||||
<el-menu-item index="/doc/user/dns_dig">DNS 解析流程</el-menu-item>
|
||||
|
||||
<!-- 嵌套子菜单:最佳实践 -->
|
||||
<el-sub-menu index="最佳实践">
|
||||
<template #title>
|
||||
<span>最佳实践</span>
|
||||
</template>
|
||||
<el-menu-item index="/doc/user/AliyunAuthorizeSecurityGroup">阿里云自动化添加安全组</el-menu-item>
|
||||
<el-menu-item index="/doc/user/TencentCloudAddSecurityGroup">腾讯云自动化添加安全组</el-menu-item>
|
||||
</el-sub-menu>
|
||||
</el-sub-menu>
|
||||
|
||||
<!-- 3. 云服务器配置 IPv6 -->
|
||||
<el-sub-menu index="云服务器配置 IPv6">
|
||||
<template #title>
|
||||
<span>云服务器配置 IPv6</span>
|
||||
</template>
|
||||
<el-menu-item index="/doc/server/website_enable_ipv6">网站开启 IPv6 的三种方式</el-menu-item>
|
||||
<el-menu-item index="/doc/server/tencent_cloud_cvm_ipv6">腾讯云 cvm 开启 IPv6</el-menu-item>
|
||||
<el-menu-item index="/doc/server/nginx_ipv6">Nginx 开启 IPv6</el-menu-item>
|
||||
<el-menu-item index="/doc/server/ipv6webcheck">如何确认一个网站是否开启 IPv6</el-menu-item>
|
||||
<el-menu-item index="/doc/server/ipv6_sign">网站增加支持IPv6访问标识</el-menu-item>
|
||||
<el-menu-item index="/doc/server/ipv6_domain_record">如何为域名添加 IPv6 解析记录</el-menu-item>
|
||||
<el-menu-item index="/doc/server/http2">网站如何开启 HTTP/2</el-menu-item>
|
||||
<el-menu-item index="/doc/server/check_userip_ipv4_ipv6">JS 检查网络是 IPv4 还是 IPv6</el-menu-item>
|
||||
<el-menu-item index="/doc/server/tls">网站如何开启 TLS</el-menu-item>
|
||||
</el-sub-menu>
|
||||
|
||||
<!-- 4. IPv6 协议规范 -->
|
||||
<el-sub-menu index="IPv6 协议规范">
|
||||
<template #title>
|
||||
<span>IPv6 协议规范</span>
|
||||
</template>
|
||||
<el-menu-item index="/doc/rfc/rfc8200">IPv6 RFC8200 解读</el-menu-item>
|
||||
<el-menu-item index="/doc/rfc/ipv6_address_format">IPv6 地址标识方法</el-menu-item>
|
||||
<el-menu-item index="/doc/user/tcpdump_ipv6">tcpdump 分析IPv6包</el-menu-item>
|
||||
<el-menu-item index="/doc/user/wireshark_ipv6">WireShark 分析IPv6包头</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv6_ping">IPv6 Ping 原理</el-menu-item>
|
||||
</el-sub-menu>
|
||||
|
||||
<!-- 5. API 接口 -->
|
||||
<el-sub-menu index="API 接口">
|
||||
<template #title>
|
||||
<span>API 接口</span>
|
||||
</template>
|
||||
<el-menu-item index="/doc/api/ip/locate">获取客户端公网 IP 及位置</el-menu-item>
|
||||
<el-menu-item index="/doc/api/ip/myip">获取客户端公网 IP 地址</el-menu-item>
|
||||
<el-menu-item index="/doc/api/ip/query">查询指定 IP 地址的位置信息</el-menu-item>
|
||||
<el-menu-item index="/doc/api/whois/query">查询域名的 WHOIS 信息</el-menu-item>
|
||||
</el-sub-menu>
|
||||
</el-menu>
|
||||
</template>
|
||||
@@ -0,0 +1,78 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted, onBeforeUnmount } from 'vue'
|
||||
|
||||
/**
|
||||
* 全站文档图片灯箱:全局点击委托 + Element Plus 自带查看器(el-image-viewer)。
|
||||
*
|
||||
* 在 app.vue 挂载一次即覆盖所有 v-html 文档容器(.markdown / .markdown-body),
|
||||
* 页面无需任何接线。命中规则:容器内的 <img>,且不在 <a> 链接里(放行导航)。
|
||||
* 查看器自带 Esc 关闭、滚轮缩放、旋转工具栏;hide-on-click-modal 允许点遮罩关闭。
|
||||
*/
|
||||
const visible = ref(false)
|
||||
const urlList = ref<string[]>([])
|
||||
const initialIndex = ref(0)
|
||||
|
||||
function onClick(e: MouseEvent) {
|
||||
const target = e.target as HTMLElement
|
||||
const img = target.closest?.<HTMLImageElement>('.markdown img, .markdown-body img')
|
||||
if (!img) return
|
||||
if (img.closest('a')) return // 图片套在链接里 → 放行导航,不开灯箱
|
||||
if (img.complete && img.naturalWidth === 0) return // 加载失败的裂图不进灯箱
|
||||
const src = img.currentSrc || img.src
|
||||
if (!src) return
|
||||
e.preventDefault()
|
||||
|
||||
// 收集同一容器内的全部图片:EP 查看器由此获得左右箭头/键盘多图切换
|
||||
// (doc 页一篇文章带几十张截图,单图模式等于白瞎了查看器的切换能力)
|
||||
const container = img.closest('.markdown, .markdown-body')
|
||||
const imgs = container ? Array.from(container.querySelectorAll('img')) : [img]
|
||||
const list = imgs
|
||||
.filter(i => !(i.complete && i.naturalWidth === 0))
|
||||
.map(i => i.currentSrc || i.src)
|
||||
.filter(Boolean)
|
||||
if (!list.length) return
|
||||
|
||||
urlList.value = list
|
||||
initialIndex.value = Math.max(0, list.indexOf(src))
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
// 打开期间锁 body 滚动(EP 查看器自带 Esc 关闭与缩放/旋转工具栏)
|
||||
watch(visible, (v) => {
|
||||
document.body.style.overflow = v ? 'hidden' : ''
|
||||
})
|
||||
|
||||
// 路由切换时强制关闭:灯箱开着按浏览器后退,查看器不能跨页面残留
|
||||
const route = useRoute()
|
||||
watch(
|
||||
() => route.path,
|
||||
() => {
|
||||
visible.value = false
|
||||
}
|
||||
)
|
||||
|
||||
onMounted(() => document.addEventListener('click', onClick))
|
||||
onBeforeUnmount(() => {
|
||||
document.removeEventListener('click', onClick)
|
||||
document.body.style.overflow = ''
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-image-viewer
|
||||
v-if="visible"
|
||||
:url-list="urlList"
|
||||
:initial-index="initialIndex"
|
||||
:z-index="3000"
|
||||
hide-on-click-modal
|
||||
@close="visible = false"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
/* 文档图片可点的视觉暗示(非 scoped:v-html 内容拿不到 scope id) */
|
||||
.markdown img,
|
||||
.markdown-body img {
|
||||
cursor: zoom-in;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 顶栏 / 抽屉「宽屏还是窄屏」的唯一判定入口(服务端算一次,客户端沿用)。
|
||||
*
|
||||
* 为什么客户端不自己嗅探 navigator.userAgent:
|
||||
* SSR 出的 HTML 是跟着【服务端】的判定走的。客户端若各算各的,只要两边结论不一致,
|
||||
* Vue 水合就会整棵树失配 —— 实测在预渲染的 /doc/** 上是直接抛
|
||||
* `Cannot read properties of null (reading 'nodeType')`,然后被 Nuxt 渲染成 500 页
|
||||
* (真手机打开文档站必然复现:预渲染时没有请求头 ⇒ 服务端恒判宽屏)。
|
||||
* 把服务端的判定序列化进 payload 当客户端的初值,首帧 vdom 与 HTML 必然一致;
|
||||
* 顺带还免疫「CDN 把桌面版缓存回给手机」——那种情况下客户端也会乖乖按 HTML 走宽屏。
|
||||
*
|
||||
* 权威值仍由 app.vue 的 onMounted 用 matchMedia 覆盖,管「桌面窗口被拖窄」这类
|
||||
* 请求头判不出的情形。窄屏判定是全局共享状态(useState),文档页据此决定要不要
|
||||
* 渲染侧栏,所以两边读的必须是同一个 ref。
|
||||
*/
|
||||
const CRAWLER_RE =
|
||||
/bot|crawler|spider|slurp|bingbot|baiduspider|yandex|duckduckbot|facebookexternalhit|preview/i
|
||||
|
||||
export function uaIsNarrow(ua: string, chMobile?: string) {
|
||||
if (!ua && !chMobile) return false // 两个都拿不到(含预渲染):按宽屏,与改造前一致
|
||||
if (CRAWLER_RE.test(ua)) return false // 抓取端一律宽屏,否则顶栏导航链接会从 HTML 里消失
|
||||
if (chMobile) return chMobile === '?1' // Chromium 的 Client Hint,最准
|
||||
return /Android|iPhone|iPod|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile|Mobile/i.test(ua)
|
||||
}
|
||||
|
||||
export function useShellNarrow() {
|
||||
// 只有服务端拿得到请求头;客户端分支只为类型与「init 被意外调用」兜底。
|
||||
const headers: Record<string, string | undefined> = import.meta.server
|
||||
? useRequestHeaders(['user-agent', 'sec-ch-ua-mobile'])
|
||||
: {}
|
||||
return useState<boolean>('ipw-shell-narrow', () =>
|
||||
uaIsNarrow(headers['user-agent'] || '', headers['sec-ch-ua-mobile']),
|
||||
)
|
||||
}
|
||||
@@ -9,10 +9,10 @@ html.dark .markdown-body {
|
||||
/* GitHub 暗色主题的核心颜色 */
|
||||
--color-fg-default: #e6edf3;
|
||||
--color-fg-muted: #8b949e;
|
||||
--color-fg-accent: #3EAF7C;
|
||||
--color-fg-accent: #299764;
|
||||
--color-bg-default: #242424;
|
||||
--color-bg-muted: #080707;
|
||||
--color-bg-accent: #3EAF7C;
|
||||
--color-bg-accent: #299764;
|
||||
--color-border-default: #242424;
|
||||
--color-border-muted: #242424;
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ useHead({
|
||||
|
||||
interface ASNResult {
|
||||
ip: string
|
||||
lemondb_asn?: { asn: string; org: string }
|
||||
geolite2_asn?: { asn: string; org: string }
|
||||
dbip_asn?: { asn: string; org: string }
|
||||
ip2location_asn?: { asn: string; as: string }
|
||||
@@ -56,7 +57,12 @@ const result = ref<ASNResult | null>(null)
|
||||
const error = ref('')
|
||||
const userIP = ref('')
|
||||
|
||||
const apiList = config.IPLocationAPI
|
||||
// ASN 页节点池:DualStack ∩ IPLocationAPI 的交集(按 id 取两个池都有的节点)。
|
||||
// 交集保证:节点在 IPLocationAPI 里(中间件 asn 分支按它解析转发),
|
||||
// 同时也是双栈池在册的全功能节点;任一池单独加节点都不会进本页。
|
||||
const apiList = config.IPLocationAPI.filter((loc) =>
|
||||
config.APIBaseURL.DualStack.some((d) => d.id === loc.id)
|
||||
)
|
||||
const currentApiIndex = ref(0)
|
||||
const backendID = computed(() => apiList[currentApiIndex.value]?.id || '')
|
||||
|
||||
@@ -145,6 +151,7 @@ function getStatusClass(status: string): string {
|
||||
<el-input
|
||||
v-model="tmpIP"
|
||||
placeholder="请输入IP地址(如:1.1.1.1)"
|
||||
clearable
|
||||
/>
|
||||
<el-button
|
||||
@click="queryASN()"
|
||||
@@ -172,17 +179,24 @@ function getStatusClass(status: string): string {
|
||||
<td class="table-label">IP 地址</td>
|
||||
<td class="table-value">{{ result.ip }}</td>
|
||||
</tr>
|
||||
<tr v-if="result.lemondb_asn?.asn">
|
||||
<td class="table-label">LemonDB ASN</td>
|
||||
<td class="table-value">
|
||||
{{ result.lemondb_asn.asn }}
|
||||
<span v-if="result.lemondb_asn.org" style="color: #999; font-size: 0.9em;">{{ result.lemondb_asn.org }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="result.geolite2_asn?.asn">
|
||||
<td class="table-label">Maxmind ASN</td>
|
||||
<td class="table-value">
|
||||
AS{{ result.geolite2_asn.asn }}
|
||||
{{ result.geolite2_asn.asn }}
|
||||
<span v-if="result.geolite2_asn.org" style="color: #999; font-size: 0.9em;">{{ result.geolite2_asn.org }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="result.dbip_asn?.asn">
|
||||
<td class="table-label">DB-IP ASN</td>
|
||||
<td class="table-value">
|
||||
AS{{ result.dbip_asn.asn }}
|
||||
{{ result.dbip_asn.asn }}
|
||||
<span v-if="result.dbip_asn.org" style="color: #999; font-size: 0.9em;">{{ result.dbip_asn.org }}</span>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -261,10 +275,10 @@ function getStatusClass(status: string): string {
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
html.dark {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
.el-icon{
|
||||
font-size: 1.3em;
|
||||
|
||||
@@ -4,7 +4,8 @@ import { useRoute } from 'vue-router'
|
||||
import { config } from '../../config/index';
|
||||
import { useMiddlewareFetch } from '../../utils/middleware';
|
||||
import { isIPv6 } from 'is-ip';
|
||||
import { formatTime } from '../../utils/tools';
|
||||
import { formatTime, withQuery } from '../../utils/tools';
|
||||
import AdvancedOptions from '../components/AdvancedOptions.vue';
|
||||
const route = useRoute()
|
||||
|
||||
useHead({
|
||||
@@ -74,12 +75,15 @@ const recordTypes = [
|
||||
{ value: 'ptr', label: 'PTR 记录' }
|
||||
]
|
||||
|
||||
// 高级选项:DNS 拨测问的就是真实解析结果,只取 DNS 服务器(dns4/dns6),不支持强制解析
|
||||
const adv = ref<InstanceType<typeof AdvancedOptions> | null>(null)
|
||||
|
||||
const dnsServerFetches = [
|
||||
...config.APIBaseURL.DualStack,
|
||||
...config.APIBaseURL.IPv4,
|
||||
...config.APIBaseURL.IPv6
|
||||
].map((server) => {
|
||||
const url = computed(() => "/middleware/" + server.id + "/dns/" + recordType.value + "/" + encodeURIComponent(domain.value));
|
||||
const url = computed(() => withQuery("/middleware/" + server.id + "/dns/" + recordType.value + "/" + encodeURIComponent(domain.value), adv.value?.query() ?? {}));
|
||||
const { data, error, execute } = useMiddlewareFetch(url, {
|
||||
immediate: false,
|
||||
watch: false,
|
||||
@@ -157,6 +161,16 @@ async function queryDNS() {
|
||||
}
|
||||
|
||||
|
||||
// 行内「数据格是否该渲染」判定。
|
||||
//
|
||||
// 结果表共 6 列(服务器 / 类型 / 记录 / 记录数 / 耗时 / TTL);后三列(记录数、耗时、TTL)
|
||||
// 只在真正拿到结果时才有意义。加载中与失败两种状态由「记录」那格用 colspan=4 横跨到表尾,
|
||||
// 若此时再渲染后三格,整行就会变成 2+4+3=9 格 —— 表格按最大列数排版,凭空多出 3 列,
|
||||
// 表头只剩 6 列、右侧留出空档,错误行也跟着错位。
|
||||
function hasData(result: any) {
|
||||
return !result?.loading && !result?.error
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
const domainParam = route.query.domain as string
|
||||
@@ -189,9 +203,11 @@ const doc = page.value;
|
||||
<div class="one-line">
|
||||
<el-input
|
||||
v-model="tmpDomain"
|
||||
placeholder="请输入域名(如:example.com)"
|
||||
placeholder="请输入域名(如:example.com)"
|
||||
clearable
|
||||
/>
|
||||
<el-select v-model="recordType" style="width: 150px;" class="custom-height-select">
|
||||
<!-- aria-label 落到 EP select 内部的原生 input 上,否则 Lighthouse 的 label 审计必挂 -->
|
||||
<el-select v-model="recordType" style="width: 150px;" class="custom-height-select" aria-label="DNS 记录类型">
|
||||
<el-option
|
||||
v-for="item in recordTypes"
|
||||
:key="item.value"
|
||||
@@ -208,6 +224,9 @@ const doc = page.value;
|
||||
查询
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<AdvancedOptions ref="adv" :show-resolve="false" />
|
||||
|
||||
<div class="result-section">
|
||||
<table class="result-table" v-if="results.length > 0">
|
||||
<thead>
|
||||
@@ -242,9 +261,11 @@ const doc = page.value;
|
||||
</span>
|
||||
</td>
|
||||
|
||||
<td class="table-value" v-if="!result.loading">{{result.data?.record?.length || 0}}</td>
|
||||
<td class="table-value" v-if="!result.loading">{{formatTime(result.data?.duration)}}</td>
|
||||
<td class="table-value" v-if="!result.loading">{{result.data?.ttl}}</td>
|
||||
<!-- 后三格必须与「记录」格的 colspan 互斥:加载中/失败时该格已跨满到表尾,
|
||||
这里再渲染就会多出 3 列(见 hasData 注释) -->
|
||||
<td class="table-value" v-if="hasData(result)">{{result.data?.record?.length || 0}}</td>
|
||||
<td class="table-value" v-if="hasData(result)">{{formatTime(result.data?.duration)}}</td>
|
||||
<td class="table-value" v-if="hasData(result)">{{result.data?.ttl}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -280,12 +301,30 @@ const doc = page.value;
|
||||
@import "../style.css";
|
||||
@import "../../assets/css/tool-common.css";
|
||||
|
||||
/* 本页行内容比通用行宽(input 420 + select 150 + button 165 + 间距 ≈ 765px),
|
||||
换行点更高:容器低于 780px(≈自然换行点)时换行元素铺满整行,
|
||||
消除 615~780px 之间「换行但仍固定宽」的夹缝(tool-common 的通用阈值只覆盖到 615px)。
|
||||
select 的 width 是行内 style,需 !important 才能覆盖。 */
|
||||
@container (max-width: 780px) {
|
||||
.el-input,
|
||||
.el-select,
|
||||
.el-button {
|
||||
width: 100% !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
|
||||
.el-input,
|
||||
.el-select {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.el-menu--horizontal > .el-menu-item:nth-child(1) {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.markdown :deep(a) {
|
||||
color: #3EAF7C !important;
|
||||
color: #299764 !important;
|
||||
font-size: 1.3em;
|
||||
text-decoration: none
|
||||
}
|
||||
@@ -293,11 +332,11 @@ const doc = page.value;
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
|
||||
html.dark {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
|
||||
.el-icon {
|
||||
|
||||
@@ -168,6 +168,11 @@ async function getUserIP() {
|
||||
}
|
||||
return userIP.value
|
||||
}
|
||||
|
||||
const { data: page, error } = await useAsyncData('dnssec-page', () =>
|
||||
$fetch('/api/markdown/dnssec')
|
||||
)
|
||||
const doc = page.value;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -182,6 +187,7 @@ async function getUserIP() {
|
||||
<el-input
|
||||
v-model="tmpDomain"
|
||||
placeholder="请输入域名(如:example.com)"
|
||||
clearable
|
||||
/>
|
||||
<el-button
|
||||
@click="checkDNSSEC()"
|
||||
@@ -255,10 +261,12 @@ async function getUserIP() {
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="markdown">
|
||||
<div v-html="doc"></div>
|
||||
</div>
|
||||
|
||||
<blockquote>
|
||||
DNSSEC 原理介绍即将上线<br/>
|
||||
DNSSEC 通过 DNSKEY、RRSIG、DS 记录为 DNS 数据提供完整性验证,防止 DNS 欺骗攻击。<br/>
|
||||
如果显示 "验证失败",可能原因:域名未配置 DNSSEC、DNSKEY 密钥不匹配、DS 记录缺失等。<br/>
|
||||
如果显示 "验证失败",可能原因:域名未配置 DNSSEC、DNSKEY 密钥不匹配、DS 记录缺失等(详见上方原理介绍)。<br/>
|
||||
<a href="/dns" target="_blank">DNS 解析查询</a> | <a href="/whois" target="_blank">Whois 查询</a><br/>
|
||||
访客IP: {{ userIP || '获取中...' }},您的网络{{ isIPv6(userIP) ? 'IPv6' : 'IPv4' }}优先<br/>
|
||||
</blockquote>
|
||||
@@ -269,6 +277,26 @@ async function getUserIP() {
|
||||
@import "../style.css";
|
||||
@import "../../assets/css/tool-common.css";
|
||||
|
||||
.markdown :deep(a) {
|
||||
color: #299764 !important;
|
||||
font-size: 1.3em;
|
||||
text-decoration: none
|
||||
}
|
||||
/* 1240px 宽的验证链图必须缩进 60% 的内容列,桌面端也要约束(仅移动端限制不够) */
|
||||
.markdown :deep(img) {
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.markdown :deep(a) {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
.markdown :deep(img) {
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.el-menu--horizontal > .el-menu-item:nth-child(1) {
|
||||
margin-right: auto;
|
||||
}
|
||||
@@ -284,10 +312,10 @@ async function getUserIP() {
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
html.dark {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
.el-icon{
|
||||
font-size: 1.3em;
|
||||
|
||||
@@ -1,85 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
import { getDocMeta } from '../../../config/doc'
|
||||
import { config } from '../../../config/index'
|
||||
|
||||
// 窄屏下这条侧栏被 CSS 隐藏(导航在顶栏抽屉里),但照样要花钱水合 ——
|
||||
// 详见 app/pages/doc/index.vue 的同名注释。
|
||||
const isNarrow = useShellNarrow()
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
const path = computed(() => route.path)
|
||||
const { data: page } = await useFetch(() => `/api/markdown${path.value}`)
|
||||
const activeIndex = computed(() => route.path)
|
||||
|
||||
const meta = computed(() => getDocMeta(route.path))
|
||||
// <title>/meta 优先取 seoXxx 加长版(Bing 审计判文档页标题与描述过短);
|
||||
// 侧栏菜单与卡片仍读原字段展示,不受影响。
|
||||
const seoTitle = computed(() => meta.value.seoTitle ?? meta.value.title)
|
||||
const seoDescription = computed(() => meta.value.seoDescription ?? meta.value.description)
|
||||
const docUrl = computed(() => new URL(route.path, config.siteUrl).href)
|
||||
useHead({
|
||||
title: computed(() => meta.value.title),
|
||||
title: seoTitle,
|
||||
titleTemplate: computed(() => `%s | ${config.siteName}`),
|
||||
meta: [
|
||||
{ name: 'description', content: computed(() => meta.value.description) }
|
||||
{ name: 'description', content: seoDescription },
|
||||
{ property: 'og:title', content: computed(() => `${seoTitle.value} | ${config.siteName}`) },
|
||||
{ property: 'og:description', content: seoDescription },
|
||||
{ property: 'og:image', content: config.siteUrl + 'favicon.svg' },
|
||||
{ property: 'og:type', content: 'article' },
|
||||
],
|
||||
script: [
|
||||
{
|
||||
type: 'application/ld+json',
|
||||
innerHTML: computed(() => JSON.stringify({
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'BreadcrumbList',
|
||||
itemListElement: [
|
||||
{ '@type': 'ListItem', position: 1, name: '首页', item: config.siteUrl },
|
||||
{ '@type': 'ListItem', position: 2, name: '文档', item: new URL('/doc', config.siteUrl).href },
|
||||
{ '@type': 'ListItem', position: 3, name: meta.value.title, item: docUrl.value }
|
||||
]
|
||||
}))
|
||||
}
|
||||
]
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="box">
|
||||
<el-menu
|
||||
:default-active="activeIndex"
|
||||
class="sidebar-menu"
|
||||
router
|
||||
>
|
||||
<!-- 1. 独立菜单项 -->
|
||||
<el-menu-item index="/doc">
|
||||
<span>IPv6 工具箱使用文档</span>
|
||||
</el-menu-item>
|
||||
|
||||
<!-- 2. IPv6 用户端 -->
|
||||
<el-sub-menu index="IPv6 用户端">
|
||||
<template #title>
|
||||
<span>IPv6 用户端</span>
|
||||
</template>
|
||||
|
||||
<el-menu-item index="/doc/user/enable_ipv6">个人宽带如何开启IPv6网络访问</el-menu-item>
|
||||
<el-menu-item index="/doc/user/cmd_bash_disable_ipv6">命令行禁用/启用IPv6本地网络</el-menu-item>
|
||||
<el-menu-item index="/doc/user/cmd_getip">命令行(curl)获取 IPv4 和 IPv6 地址</el-menu-item>
|
||||
<el-menu-item index="/doc/user/view_ipv6_adress_url">浏览器访问 IPv6 地址</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv4_ipv6_prefix_precedence">Windows 10/11 设置 IPv4/IPv6 访问优先级</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv6_daohang">国内 IPv6 资源导航</el-menu-item>
|
||||
<el-menu-item index="/doc/user/pure_ipv6_website">国内纯 IPv6 网站导航</el-menu-item>
|
||||
<el-menu-item index="/doc/user/dns">全国各省 DNS 服务器列表</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv6_dns">IPv6 DNS 地址列表</el-menu-item>
|
||||
|
||||
<!-- 嵌套子菜单:最佳实践 -->
|
||||
<el-sub-menu index="最佳实践">
|
||||
<template #title>
|
||||
<span>最佳实践</span>
|
||||
</template>
|
||||
<el-menu-item index="/doc/user/AliyunAuthorizeSecurityGroup">阿里云自动化添加安全组</el-menu-item>
|
||||
<el-menu-item index="/doc/user/TencentCloudAddSecurityGroup">腾讯云自动化添加安全组</el-menu-item>
|
||||
</el-sub-menu>
|
||||
</el-sub-menu>
|
||||
|
||||
<!-- 3. 云服务器配置 IPv6 -->
|
||||
<el-sub-menu index="云服务器配置 IPv6">
|
||||
<template #title>
|
||||
<span>云服务器配置 IPv6</span>
|
||||
</template>
|
||||
<el-menu-item index="/doc/server/website_enable_ipv6">网站开启 IPv6 的三种方式</el-menu-item>
|
||||
<el-menu-item index="/doc/server/tencent_cloud_cvm_ipv6">腾讯云 cvm 开启 IPv6</el-menu-item>
|
||||
<el-menu-item index="/doc/server/nginx_ipv6">Nginx 开启 IPv6</el-menu-item>
|
||||
<el-menu-item index="/doc/server/ipv6webcheck">如何确认一个网站是否开启 IPv6</el-menu-item>
|
||||
<el-menu-item index="/doc/server/ipv6_sign">网站增加支持IPv6访问标识</el-menu-item>
|
||||
<el-menu-item index="/doc/server/ipv6_domain_record">如何为域名添加 IPv6 解析记录</el-menu-item>
|
||||
<el-menu-item index="/doc/server/http2">网站如何开启 HTTP/2</el-menu-item>
|
||||
</el-sub-menu>
|
||||
|
||||
<!-- 4. IPv6 协议规范 -->
|
||||
<el-sub-menu index="IPv6 协议规范">
|
||||
<template #title>
|
||||
<span>IPv6 协议规范</span>
|
||||
</template>
|
||||
<el-menu-item index="/doc/rfc/rfc8200">IPv6 RFC8200 解读</el-menu-item>
|
||||
<el-menu-item index="/doc/rfc/ipv6_address_format">IPv6 地址标识方法</el-menu-item>
|
||||
<el-menu-item index="/doc/user/tcpdump_ipv6">tcpdump 分析IPv6包</el-menu-item>
|
||||
<el-menu-item index="/doc/user/wireshark_ipv6">WireShark 分析IPv6包头</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv6_ping">IPv6 Ping 原理</el-menu-item>
|
||||
</el-sub-menu>
|
||||
|
||||
</el-menu>
|
||||
<!-- 文档导航只有一份实现(app/components/DocMenu.vue)。
|
||||
宽屏:就是这条左侧固定侧栏;窄屏:本侧栏隐藏,改由顶部抽屉菜单承载 -->
|
||||
<DocMenu v-if="!isNarrow" class="sidebar-menu" />
|
||||
<div class="content">
|
||||
<div class="markdown-body" v-if="page">
|
||||
<div v-html="page" />
|
||||
@@ -119,8 +87,10 @@ html.dark .content {
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
/* 窄屏不再挤一条窄侧栏(原先 100px,长标题全被截断):
|
||||
文档导航已并入左侧抽屉菜单,这里直接撤掉,正文铺满整屏 */
|
||||
.sidebar-menu {
|
||||
width: 100px;
|
||||
display: none;
|
||||
}
|
||||
.content {
|
||||
padding: 10px;
|
||||
|
||||
@@ -1,86 +1,54 @@
|
||||
<script setup lang="ts">
|
||||
import { getDocMeta } from '../../../config/doc'
|
||||
import { config } from '../../../config/index'
|
||||
|
||||
// 窄屏(≤768px)下这条侧栏被 CSS 整个隐藏,导航改由顶栏抽屉承载。
|
||||
// 但「只是藏起来」不等于不花钱:Vue 依旧会把整棵 40 项的 el-menu 水合一遍
|
||||
// (实测手机端 doc-sidebar 区域 53 次事件绑定)。所以直接按判定结果不渲染。
|
||||
// 这里用的是全局共享的窄屏状态(服务端按请求头判定并随 payload 下发),
|
||||
// 与 app.vue 同一份 —— 首帧与服务端 HTML 一致,不会有水合分歧。
|
||||
const isNarrow = useShellNarrow()
|
||||
|
||||
const route = useRoute();
|
||||
const { data: page } = await useAsyncData('doc-index', () =>
|
||||
$fetch('/api/markdown/doc/index')
|
||||
)
|
||||
const doc = page.value;
|
||||
const activeIndex = computed(() => route.path)
|
||||
|
||||
const meta = getDocMeta('/doc')
|
||||
// <title>/meta 优先取 seoXxx 加长版(Bing 审计判文档页标题与描述过短);
|
||||
// 侧栏菜单与卡片仍读原字段展示,不受影响。
|
||||
const seoTitle = meta.seoTitle ?? meta.title
|
||||
const seoDescription = meta.seoDescription ?? meta.description
|
||||
useHead({
|
||||
title: meta.title,
|
||||
title: seoTitle,
|
||||
titleTemplate: `%s | ${config.siteName}`,
|
||||
meta: [
|
||||
{ name: 'description', content: meta.description }
|
||||
{ name: 'description', content: seoDescription },
|
||||
{ property: 'og:title', content: `${seoTitle} | ${config.siteName}` },
|
||||
{ property: 'og:description', content: seoDescription },
|
||||
{ property: 'og:image', content: config.siteUrl + 'favicon.svg' },
|
||||
{ property: 'og:type', content: 'website' },
|
||||
],
|
||||
script: [
|
||||
{
|
||||
type: 'application/ld+json',
|
||||
innerHTML: JSON.stringify({
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'BreadcrumbList',
|
||||
itemListElement: [
|
||||
{ '@type': 'ListItem', position: 1, name: '首页', item: config.siteUrl },
|
||||
{ '@type': 'ListItem', position: 2, name: meta.title, item: new URL('/doc', config.siteUrl).href }
|
||||
]
|
||||
})
|
||||
}
|
||||
]
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<div class="box">
|
||||
<el-menu
|
||||
:default-active="activeIndex"
|
||||
class="sidebar-menu"
|
||||
router
|
||||
>
|
||||
<!-- 1. 独立菜单项 -->
|
||||
<el-menu-item index="/doc">
|
||||
<span>IPv6 工具箱使用文档</span>
|
||||
</el-menu-item>
|
||||
|
||||
<!-- 2. IPv6 用户端 -->
|
||||
<el-sub-menu index="IPv6 用户端">
|
||||
<template #title>
|
||||
<span>IPv6 用户端</span>
|
||||
</template>
|
||||
|
||||
<el-menu-item index="/doc/user/enable_ipv6">个人宽带如何开启IPv6网络访问</el-menu-item>
|
||||
<el-menu-item index="/doc/user/cmd_bash_disable_ipv6">命令行禁用/启用IPv6本地网络</el-menu-item>
|
||||
<el-menu-item index="/doc/user/cmd_getip">命令行(curl)获取 IPv4 和 IPv6 地址</el-menu-item>
|
||||
<el-menu-item index="/doc/user/view_ipv6_adress_url">浏览器访问 IPv6 地址</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv4_ipv6_prefix_precedence">Windows 10/11 设置 IPv4/IPv6 访问优先级</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv6_daohang">国内 IPv6 资源导航</el-menu-item>
|
||||
<el-menu-item index="/doc/user/pure_ipv6_website">国内纯 IPv6 网站导航</el-menu-item>
|
||||
<el-menu-item index="/doc/user/dns">全国各省 DNS 服务器列表</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv6_dns">IPv6 DNS 地址列表</el-menu-item>
|
||||
|
||||
<!-- 嵌套子菜单:最佳实践 -->
|
||||
<el-sub-menu index="最佳实践">
|
||||
<template #title>
|
||||
<span>最佳实践</span>
|
||||
</template>
|
||||
<el-menu-item index="/doc/user/AliyunAuthorizeSecurityGroup">阿里云自动化添加安全组</el-menu-item>
|
||||
<el-menu-item index="/doc/user/TencentCloudAddSecurityGroup">腾讯云自动化添加安全组</el-menu-item>
|
||||
</el-sub-menu>
|
||||
</el-sub-menu>
|
||||
|
||||
<!-- 3. 云服务器配置 IPv6 -->
|
||||
<el-sub-menu index="云服务器配置 IPv6">
|
||||
<template #title>
|
||||
<span>云服务器配置 IPv6</span>
|
||||
</template>
|
||||
<el-menu-item index="/doc/server/website_enable_ipv6">网站开启 IPv6 的三种方式</el-menu-item>
|
||||
<el-menu-item index="/doc/server/tencent_cloud_cvm_ipv6">腾讯云 cvm 开启 IPv6</el-menu-item>
|
||||
<el-menu-item index="/doc/server/nginx_ipv6">Nginx 开启 IPv6</el-menu-item>
|
||||
<el-menu-item index="/doc/server/ipv6webcheck">如何确认一个网站是否开启 IPv6</el-menu-item>
|
||||
<el-menu-item index="/doc/server/ipv6_sign">网站增加支持IPv6访问标识</el-menu-item>
|
||||
<el-menu-item index="/doc/server/ipv6_domain_record">如何为域名添加 IPv6 解析记录</el-menu-item>
|
||||
<el-menu-item index="/doc/server/http2">网站如何开启 HTTP/2</el-menu-item>
|
||||
</el-sub-menu>
|
||||
|
||||
<!-- 4. IPv6 协议规范 -->
|
||||
<el-sub-menu index="IPv6 协议规范">
|
||||
<template #title>
|
||||
<span>IPv6 协议规范</span>
|
||||
</template>
|
||||
<el-menu-item index="/doc/rfc/rfc8200">IPv6 RFC8200 解读</el-menu-item>
|
||||
<el-menu-item index="/doc/rfc/ipv6_address_format">IPv6 地址标识方法</el-menu-item>
|
||||
<el-menu-item index="/doc/user/tcpdump_ipv6">tcpdump 分析IPv6包</el-menu-item>
|
||||
<el-menu-item index="/doc/user/wireshark_ipv6">WireShark 分析IPv6包头</el-menu-item>
|
||||
<el-menu-item index="/doc/user/ipv6_ping">IPv6 Ping 原理</el-menu-item>
|
||||
</el-sub-menu>
|
||||
|
||||
</el-menu>
|
||||
<!-- 文档导航只有一份实现(app/components/DocMenu.vue)。
|
||||
宽屏:就是这条左侧固定侧栏;窄屏:本侧栏隐藏,改由顶部抽屉菜单承载 -->
|
||||
<DocMenu v-if="!isNarrow" class="sidebar-menu" />
|
||||
<div class="content">
|
||||
<div class="markdown-body" v-html="doc"></div>
|
||||
</div>
|
||||
@@ -118,8 +86,10 @@ html.dark .content {
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
/* 窄屏不再挤一条窄侧栏(原先 100px,长标题全被截断):
|
||||
文档导航已并入左侧抽屉菜单,这里直接撤掉,正文铺满整屏 */
|
||||
.sidebar-menu {
|
||||
width: 100px;
|
||||
display: none;
|
||||
}
|
||||
.content {
|
||||
padding: 10px;
|
||||
|
||||
@@ -3,17 +3,15 @@ import { computed, ref, onMounted } from 'vue';
|
||||
import { isIPv6 } from 'is-ip';
|
||||
import { config } from '../../config/index';
|
||||
import { CircleCheckFilled, CircleCloseFilled } from '@element-plus/icons-vue';
|
||||
import { highlightCode } from '../../utils/shiki';
|
||||
import { isIPv4 } from '../../utils/tools';
|
||||
const route = useRoute();
|
||||
const canonicalUrl = computed(() => new URL(route.path, config.siteUrl).toString());
|
||||
// canonical 由 app.vue 全局下发(见下方 useHead 注释)。
|
||||
|
||||
useHead({
|
||||
title: `${config.siteName} | IP查询工具 | IPv4/IPv6地址查询与网络测试平台`,
|
||||
titleTemplate: '%s',
|
||||
link: [
|
||||
{ rel: 'canonical', href: canonicalUrl.value }
|
||||
],
|
||||
// canonical / og:url / twitter:card 由 app.vue 全局下发(按纯路径去 query),
|
||||
// 这里不再重复声明,避免 head 里出现两条 canonical。
|
||||
meta: [
|
||||
{ name: 'description', content: `${config.siteName}提供专业的IP查询服务,支持IPv4和IPv6地址在线查询、归属地定位、网络测速、DNS解析、SSL证书检测、TCPing测试等多种网络工具,致力于推进IPv6规模部署和应用,打造去中心化的IP查询平台` },
|
||||
{ name: 'keywords', content: 'ipv6,ipv4,ip查询,ipv6查询,ipv4查询,ipv6地址查询,ipv4地址查询,网络测速,DNS查询,SSL检测,TCPing,IP归属地,IPv6优先' },
|
||||
@@ -21,10 +19,34 @@ useHead({
|
||||
{ property: 'og:description', content: '提供IPv4/IPv6地址查询、网络测速、DNS解析、SSL检测等全方位网络诊断工具,助力IPv6普及与部署' },
|
||||
{ property: 'og:image', content: `${config.siteUrl}favicon.svg` },
|
||||
{ property: 'og:type', content: 'website' },
|
||||
{ property: 'og:url', content: canonicalUrl.value },
|
||||
{ name: 'twitter:card', content: 'summary_large_image' },
|
||||
],
|
||||
script: [
|
||||
{
|
||||
// —— IP 探测提前到 HTML 解析期(LCP 优化)——
|
||||
// 原来三个探测请求在 onMounted(水合完成后)才发出,模拟链路是
|
||||
// 「水合 → 发请求 → 等服务端 → 回填渲染」,IPv6 行作为 LCP 元素被整段串行拖住
|
||||
// (mobile 模拟 LCP 2275ms,满分线约 1600ms)。
|
||||
// 这里在 head 里用内联脚本立刻发起,与 render-blocking CSS 的下载、
|
||||
// hydration 三路并行;结果挂 window.__ipProbe,完成时派发 ip-probe 事件,
|
||||
// onMounted 只负责消费(见下方),不再等水合才起步。
|
||||
// 用原生 fetch:此刻 ofetch 还没加载;不带 retry 的语义与旧版 retry:false 一致
|
||||
// (底层 fetch 本来就不会重试)。
|
||||
innerHTML: [
|
||||
'window.__ipProbe = {};',
|
||||
'(function () {',
|
||||
` function emit(key) {`,
|
||||
` return function (text) {`,
|
||||
` window.__ipProbe[key] = text;`,
|
||||
` document.dispatchEvent(new CustomEvent('ip-probe', { detail: key }));`,
|
||||
` };`,
|
||||
` }`,
|
||||
// 与 onMounted 的语义一致:三接口各自独立、失败静默(保持「查询中」占位)
|
||||
` fetch(${JSON.stringify(config.v6OnlyAPI)}).then(function (r) { return r.text(); }).then(emit('v6')).catch(function () {});`,
|
||||
` fetch(${JSON.stringify(config.v4OnlyAPI)}).then(function (r) { return r.text(); }).then(emit('v4')).catch(function () {});`,
|
||||
` fetch(${JSON.stringify(config.DualStackAPI)}).then(function (r) { return r.text(); }).then(emit('dual')).catch(function () {});`,
|
||||
'})();',
|
||||
].join('\n'),
|
||||
},
|
||||
{
|
||||
type: 'application/ld+json',
|
||||
innerHTML: JSON.stringify({
|
||||
@@ -32,7 +54,7 @@ useHead({
|
||||
'@type': 'WebApplication',
|
||||
name: config.siteName,
|
||||
description: `${config.siteName}提供专业的IP查询服务,支持IPv4和IPv6地址在线查询、归属地定位、网络测速、DNS解析、SSL证书检测、TCPing测试等多种网络工具,致力于推进IPv6规模部署和应用,打造去中心化的IP查询平台`,
|
||||
url: canonicalUrl.value,
|
||||
url: new URL(route.path, config.siteUrl).toString(),
|
||||
applicationCategory: 'DeveloperApplication',
|
||||
operatingSystem: 'Any',
|
||||
offers: {
|
||||
@@ -75,33 +97,90 @@ curl ${config.v6OnlyAPI}
|
||||
# (访问 IPv4/IPv6 双栈站点,如果返回 IPv6 地址,则 IPv6 访问优先)
|
||||
curl ${config.DualStackAPI}
|
||||
`.trim(); // 关键:去掉首尾多余的空行
|
||||
const highlightedCode = ref('');
|
||||
|
||||
// 代码高亮放在 SSR 期算:HTML 下发时就已经是带 <span> 的高亮结果,
|
||||
// 于是 ①客户端不必再下载/执行 shiki(引擎 + 语言 + 主题 ≈ 164KB);
|
||||
// ②不会再有"先出纯文本兜底、若干秒后才换成高亮"的那次块高变化(可见重排)。
|
||||
//
|
||||
// 这段代码是构建期常量(只依赖 config,不随请求变化),所以结果可以安全地随 HTML 一起缓存。
|
||||
//
|
||||
// import 仍然写在 handler 内部(而不是文件顶层):动态 import 会把它切成独立 chunk,
|
||||
// 只在真正要高亮时加载,不会像顶层静态 import 那样被塞进首屏的 modulepreload 列表。
|
||||
// 首次进入是 SSR 执行的;客户端水合直接读 payload(Nuxt 会序列化 useAsyncData 的结果),
|
||||
// 只有客户端软导航到本页时才在浏览器里跑一次。
|
||||
const { data: highlightedCode } = await useAsyncData(
|
||||
'home-curl-code',
|
||||
async () => {
|
||||
const { highlightCode } = await import('../../utils/shiki');
|
||||
return await highlightCode(code, 'bash');
|
||||
},
|
||||
// 默认值必须留空:模板是 v-if="highlightedCode" / v-else 的双分支,
|
||||
// 给成 code 会让 v-if 命中、把纯文本当 HTML 塞进 v-html(fallback 分支永远走不到)。
|
||||
// 留空则失败时自然落到 v-else 的 code-block--fallback,与改动前 catch 里清空的行为一致。
|
||||
{ default: () => '' },
|
||||
);
|
||||
|
||||
const ipAddress = ref('');
|
||||
const yourIPv4 = ref('');
|
||||
const yourIPv6 = ref('');
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
highlightedCode.value = await highlightCode(code, 'bash');
|
||||
} catch {
|
||||
highlightedCode.value = '';
|
||||
}
|
||||
onMounted(() => {
|
||||
// (代码高亮已移到 setup 顶部的 useAsyncData,随 SSR 一起产出。)
|
||||
|
||||
const [dualStack, ipV4, ipV6] = await Promise.allSettled([
|
||||
$fetch<string>(config.DualStackAPI),
|
||||
$fetch<string>(config.v4OnlyAPI),
|
||||
$fetch<string>(config.v6OnlyAPI)
|
||||
]);
|
||||
// —— 三个 IP 探测:请求已由 head 内联脚本提前发出(见 useHead),这里只消费 ——
|
||||
// 内联脚本把结果挂 window.__ipProbe[key] 并派发 ip-probe 事件。三种时序都要覆盖:
|
||||
// ① 值已就位(事件在 onMounted 之前派发过)→ 同步读 store 直接上屏;
|
||||
// ② 值未到 → 挂监听等事件(收到匹配 key 才移除,不能 once——
|
||||
// 三个 key 共用同一事件名,once 会把别人的事件当自己的吃掉);
|
||||
// ③ window.__ipProbe 不存在(内联脚本被 CSP 拦掉/异常)→ 退回自己发请求,行为同旧版。
|
||||
//
|
||||
// retry: false —— ofetch 默认会对 GET 重发一次:网络层失败时它拿不到 response,就按 500 计
|
||||
// (500 在默认重试白名单里),且默认延迟为 0,立即重发。于是"这个节点连不上"会被原样重做一遍,
|
||||
// 用户白等一倍时间(实测 ofetch 1.5.1:裸调用触发 2 次真实 fetch,传 retry:false 后只剩 1 次;
|
||||
// 浏览器自身不会重试,底层 fetch 对同一请求只被调用过一次)。仅 ③ 的兜底路径会走到 $fetch。
|
||||
const ipFetchOptions = { retry: false } as const;
|
||||
const probeStore = (window as any).__ipProbe as Record<string, string> | undefined;
|
||||
|
||||
if (dualStack.status === 'fulfilled') {
|
||||
ipAddress.value = dualStack.value;
|
||||
const consumeProbe = (key: string, apply: (ip: string) => void): boolean => {
|
||||
if (!probeStore) return false; // ③ 内联脚本没跑起来
|
||||
if (typeof probeStore[key] === 'string') {
|
||||
apply(probeStore[key]); // ① 值已就位
|
||||
return true;
|
||||
}
|
||||
const onProbe = (e: Event) => {
|
||||
if ((e as CustomEvent).detail !== key) return;
|
||||
document.removeEventListener('ip-probe', onProbe);
|
||||
apply(probeStore[key]); // ② 事件到达
|
||||
};
|
||||
document.addEventListener('ip-probe', onProbe);
|
||||
return true;
|
||||
};
|
||||
|
||||
// 三个地址各自独立请求、各自渲染:谁先回来谁先上屏。
|
||||
// 不用 Promise.allSettled 包起来等齐——那样只要有一个慢(例如纯 IPv4 网络下 v6 接口要等超时),
|
||||
// 已经拿到的 IPv4 与双栈结果也得一起干等。
|
||||
if (!consumeProbe('dual', (ip) => { ipAddress.value = ip; })) {
|
||||
$fetch<string>(config.DualStackAPI, ipFetchOptions)
|
||||
.then((ip) => {
|
||||
ipAddress.value = ip;
|
||||
})
|
||||
.catch(() => {
|
||||
// 单个接口失败不影响其它两行展示,保持"查询中"占位
|
||||
});
|
||||
}
|
||||
if (ipV4.status === 'fulfilled') {
|
||||
yourIPv4.value = ipV4.value;
|
||||
if (!consumeProbe('v4', (ip) => { yourIPv4.value = ip; })) {
|
||||
$fetch<string>(config.v4OnlyAPI, ipFetchOptions)
|
||||
.then((ip) => {
|
||||
yourIPv4.value = ip;
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
if (ipV6.status === 'fulfilled') {
|
||||
yourIPv6.value = ipV6.value;
|
||||
if (!consumeProbe('v6', (ip) => { yourIPv6.value = ip; })) {
|
||||
$fetch<string>(config.v6OnlyAPI, ipFetchOptions)
|
||||
.then((ip) => {
|
||||
yourIPv6.value = ip;
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -115,16 +194,16 @@ onMounted(async () => {
|
||||
</header>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="one-line">
|
||||
<div class="one-line ip-row">
|
||||
<b>IPv4</b> <p>{{ yourIPv4 }} </p> <RouterLink :to="`/location?ip=${yourIPv4}`" target="_blank">查询归属地</RouterLink>
|
||||
</div>
|
||||
<div class="one-line">
|
||||
<div class="one-line ip-row ip-row-v6">
|
||||
<b>IPv6</b> <p v-if="yourIPv6">{{ yourIPv6 }}</p><RouterLink :to="`/location?ip=${yourIPv6}`" target="_blank" v-if="yourIPv6"> 查询归属地</RouterLink><RouterLink v-else to="/doc/user/enable_ipv6" target="_blank">没有IPv6地址,查看如何开启IPv6</RouterLink>
|
||||
</div>
|
||||
<div style="font-size: 1.5em;">
|
||||
<h3 v-if="ipAddress && isIPv6(ipAddress)"><el-icon><CircleCheckFilled style="color: lightgreen;"/></el-icon>您的网络IPv6优先</h3>
|
||||
<h3 v-else-if="ipAddress && isIPv4(ipAddress)"><el-icon><CircleCloseFilled style="color: red;"/></el-icon>您的网络IPv4优先</h3>
|
||||
<h3 v-else><el-icon><CircleCloseFilled /></el-icon>查询中,请稍后</h3>
|
||||
<div class="ip-priority">
|
||||
<h2 v-if="ipAddress && isIPv6(ipAddress)"><el-icon><CircleCheckFilled style="color: lightgreen;"/></el-icon>您的网络IPv6优先</h2>
|
||||
<h2 v-else-if="ipAddress && isIPv4(ipAddress)"><el-icon><CircleCloseFilled style="color: red;"/></el-icon>您的网络IPv4优先</h2>
|
||||
<h2 v-else><el-icon><CircleCloseFilled /></el-icon>查询中,请稍后</h2>
|
||||
</div>
|
||||
<blockquote>
|
||||
手机默认开启 IPv6,宽带开启 IPv6 请参阅<a href="/doc/user/enable_ipv6" target="_blank">文档</a>
|
||||
@@ -141,6 +220,31 @@ onMounted(async () => {
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
/* 网络优先级提示:原来是「div 1.5em × h3」,但 h1 之后直跳 h3 违反标题层级(heading-order),
|
||||
语义上应为 h2。style.css 给 h3 显式定了 1.3em / 窄屏 1.1em,h2 只有 1.5em 一档,
|
||||
所以这里把字号按原样补回,避免语义修正顺带改了视觉(含 margin:UA 的 h3 是 1em,h2 是 0.83em)。 */
|
||||
.ip-priority {
|
||||
font-size: 1.5em;
|
||||
}
|
||||
.ip-priority h2 {
|
||||
font-size: 1.3em;
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
/* 两行 IP 记录预留确定高度,消除 CLS。
|
||||
实测(CDP 逐帧采样 + CSS 变体对照,填值后量终态几何):
|
||||
这两个 div 的文本是 onMounted 之后才由 $fetch 填上的。IPv6 地址(39 字符)
|
||||
在窄屏下把 .one-line 从 1 行撑到 3 行,下面 .ip-priority / 代码块 / blockquote /
|
||||
footer 被整体顶下 50px —— Lighthouse 记的 `div.code-block` 那条 CLS 0.0359
|
||||
(占全页 88%)就是这么来的,而满分门槛只有 0.0396,差 3% 就被扣分。
|
||||
修法是让高度与「填完之后」一致。终态高度按视口分档(CDP 实测,不是估算):
|
||||
移动 412 宽 → ip2 终态 75px(3 行);桌面 1350 宽 → 30px(1 行,.content 宽 60%)
|
||||
所以必须分媒体查询给值:一刀切 75px 会让桌面凭空多出 45px 空白。
|
||||
代价是接口 pending 时这里空着,但换来 CLS 归零。 */
|
||||
.ip-row {
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.code-block {
|
||||
margin-top: 1rem;
|
||||
padding: 1rem;
|
||||
@@ -159,14 +263,30 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.code-block {
|
||||
padding: 0.75rem;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
.ip-priority h2 {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
.code-block {
|
||||
padding: 0.75rem;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
/* 窄屏下 IPv6 地址换 3 行(CDP 实测 412 宽终态 h=75px),见上面 .ip-row 的注释。
|
||||
75px 只给 IPv6 行:IPv4 地址窄屏仍是 1 行(~30px),一刀切 75px 会让
|
||||
IPv4 行下部空出 ~45px,两块 IP 之间出现一大段空白。
|
||||
IPv4 回填前后都是 1 行 30px,高度不变 → 不引入新的 CLS。 */
|
||||
.ip-row {
|
||||
/* style.css 窄屏给 .one-line 加了 0.5em 上下 margin(两块之间叠 16px),
|
||||
IP 行的间距由行高本身决定,这里归零。scoped 属性选择器特异性更高,稳赢。 */
|
||||
margin: 0;
|
||||
}
|
||||
.ip-row-v6 {
|
||||
min-height: 75px;
|
||||
align-content: flex-start;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
</style>
|
||||
@@ -1,26 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
onMounted(async () => {
|
||||
const urlParam = route.query.ip;
|
||||
// ip 参数缺失时不要拼出 ?ip=undefined
|
||||
await navigateTo(urlParam ? { path: '/location', query: { ip: urlParam } } : { path: '/location' });
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="redirecting">正在跳转到 IP 归属地查询…</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.redirecting {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 50vh;
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
@@ -3,7 +3,8 @@ import { ref, onMounted, computed, nextTick } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { config } from '../../config/index';
|
||||
import { useMiddlewareFetch } from '../../utils/middleware';
|
||||
import { extractHost, formatTime, formatSpeed, formatSize, getStatusCodeClass } from '../../utils/tools';
|
||||
import { extractHost, formatTime, formatSpeed, formatSize, getStatusCodeClass, withQuery } from '../../utils/tools';
|
||||
import AdvancedOptions from '../components/AdvancedOptions.vue';
|
||||
|
||||
|
||||
const route = useRoute()
|
||||
@@ -48,6 +49,8 @@ const loading = ref(false)
|
||||
const result = ref<any[]>([])
|
||||
const error = ref('')
|
||||
const domain = ref('')
|
||||
// 高级选项(dns6 / resolve / resolve6):用户填了才拼进请求
|
||||
const adv = ref<InstanceType<typeof AdvancedOptions> | null>(null)
|
||||
|
||||
/** 服务器结果接口 */
|
||||
interface ServerResult {
|
||||
@@ -72,7 +75,7 @@ const serverResults = ref<ServerResult[]>([])
|
||||
|
||||
/** 双栈服务器:同时支持 IPv4/IPv6 的节点 */
|
||||
const dualStackFetches = config.APIBaseURL.DualStack.map((server) => {
|
||||
const url = computed(() => "/middleware/" + server.id + "/speed/v6/" + encodeURIComponent(domain.value));
|
||||
const url = computed(() => withQuery("/middleware/" + server.id + "/speed/v6/" + encodeURIComponent(domain.value), adv.value?.query() ?? {}));
|
||||
const { data, error: fetchError, execute } = useMiddlewareFetch(url, {
|
||||
immediate: false,
|
||||
watch: false,
|
||||
@@ -82,7 +85,7 @@ const dualStackFetches = config.APIBaseURL.DualStack.map((server) => {
|
||||
|
||||
/** IPv6 专用服务器:仅支持 IPv6 的节点 */
|
||||
const ipv6Fetches = config.APIBaseURL.IPv6.map((server) => {
|
||||
const url = computed(() => "/middleware/" + server.id + "/speed/v6/" + encodeURIComponent(domain.value));
|
||||
const url = computed(() => withQuery("/middleware/" + server.id + "/speed/v6/" + encodeURIComponent(domain.value), adv.value?.query() ?? {}));
|
||||
const { data, error: fetchError, execute } = useMiddlewareFetch(url, {
|
||||
immediate: false,
|
||||
watch: false,
|
||||
@@ -180,7 +183,8 @@ onMounted(() => {
|
||||
<div class="one-line">
|
||||
<el-input
|
||||
v-model="tmpDomain"
|
||||
placeholder="请输入域名(如:https://zakoflare.com)"
|
||||
placeholder="请输入域名(如:https://zakoflare.com)"
|
||||
clearable
|
||||
/>
|
||||
<el-button
|
||||
@click="SpeedTest()"
|
||||
@@ -191,6 +195,8 @@ onMounted(() => {
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<AdvancedOptions ref="adv" stack="ipv6" />
|
||||
|
||||
<div v-if="error" class="error-message">
|
||||
{{ error }}
|
||||
</div>
|
||||
@@ -272,10 +278,10 @@ onMounted(() => {
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
html.dark {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
.el-icon{
|
||||
font-size: 1.3em;
|
||||
|
||||
@@ -4,7 +4,8 @@ import { useRoute } from 'vue-router'
|
||||
import { config } from '../../config/index';
|
||||
import { useMiddlewareFetch } from '../../utils/middleware';
|
||||
import { isIPv6 } from 'is-ip';
|
||||
import { extractHost } from '../../utils/tools';
|
||||
import { extractHost, withQuery } from '../../utils/tools';
|
||||
import AdvancedOptions from '../components/AdvancedOptions.vue';
|
||||
const route = useRoute()
|
||||
|
||||
useHead({
|
||||
@@ -77,6 +78,8 @@ const port = ref('80')
|
||||
const userIP = ref('')
|
||||
const loading = ref(false)
|
||||
const serverResults = ref<ServerResult[]>([])
|
||||
// 高级选项(dns6 / resolve / resolve6):用户填了才拼进请求
|
||||
const adv = ref<InstanceType<typeof AdvancedOptions> | null>(null)
|
||||
// 查询序号:连续点击时旧查询的结果不允许写入新查询的结果表
|
||||
let queryId = 0
|
||||
|
||||
@@ -86,7 +89,7 @@ const allServers = [
|
||||
];
|
||||
|
||||
const tcpingFetches = allServers.map((server) => {
|
||||
const url = computed(() => "/middleware/" + server.id + "/tcping/" + encodeURIComponent(extractHost(tmpDomain.value)) + "?port=" + encodeURIComponent(port.value));
|
||||
const url = computed(() => withQuery("/middleware/" + server.id + "/tcping/" + encodeURIComponent(extractHost(tmpDomain.value)) + "?port=" + encodeURIComponent(port.value) + "&version=ipv6", adv.value?.query() ?? {}));
|
||||
const { data, error: fetchError, execute } = useMiddlewareFetch<TCPingResponse>(url, {
|
||||
immediate: false,
|
||||
watch: false,
|
||||
@@ -195,11 +198,13 @@ onMounted(() => {
|
||||
<div class="one-line">
|
||||
<el-input
|
||||
v-model="tmpDomain"
|
||||
placeholder="请输入域名(如:example.com)"
|
||||
placeholder="请输入域名(如:example.com)"
|
||||
clearable
|
||||
/>
|
||||
<el-input
|
||||
v-model="port"
|
||||
placeholder="端口号(默认 80)"
|
||||
placeholder="端口号(默认 80)"
|
||||
clearable
|
||||
style="width: 200px;"
|
||||
/>
|
||||
<el-button
|
||||
@@ -211,6 +216,8 @@ onMounted(() => {
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<AdvancedOptions ref="adv" stack="ipv6" />
|
||||
|
||||
<div class="result-section">
|
||||
<table class="result-table">
|
||||
<thead>
|
||||
@@ -280,6 +287,20 @@ onMounted(() => {
|
||||
@import "../style.css";
|
||||
@import "../../assets/css/tool-common.css";
|
||||
|
||||
/* 本页行是双输入框(420×2 + 按钮 165 + 间距 ≈ 1035px),换行点远高于通用阈值的
|
||||
615px:容器低于 1050px(≈自然换行点)时换行元素铺满整行,消除中间的夹缝区。 */
|
||||
@container (max-width: 1050px) {
|
||||
.el-input,
|
||||
.el-button {
|
||||
width: 100% !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
|
||||
.el-input {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.el-menu--horizontal > .el-menu-item:nth-child(1) {
|
||||
margin-right: auto;
|
||||
}
|
||||
@@ -287,11 +308,11 @@ onMounted(() => {
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
|
||||
html.dark {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
|
||||
.el-icon {
|
||||
|
||||
@@ -4,7 +4,8 @@ import { useRoute } from 'vue-router'
|
||||
import { config } from '../../config/index';
|
||||
import { useMiddlewareFetch } from '../../utils/middleware';
|
||||
import { CircleCheckFilled, CircleCloseFilled,InfoFilled,Position } from '@element-plus/icons-vue';
|
||||
import { extractHost, getStatusCodeClass, formatTime, formatSize, formatSpeed } from '../../utils/tools';
|
||||
import { extractHost, getStatusCodeClass, formatTime, formatSize, formatSpeed, withQuery } from '../../utils/tools';
|
||||
import AdvancedOptions from '../components/AdvancedOptions.vue';
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
@@ -63,7 +64,9 @@ interface PerformanceCheckItem {
|
||||
download_speed: number
|
||||
is_reachable: boolean
|
||||
}
|
||||
const apiList = config.APIBaseURL.DualStack
|
||||
const apiList = [
|
||||
...config.APIBaseURL.DualStack,
|
||||
]
|
||||
const currentApiIndex = ref(0)
|
||||
const backendID = computed(() => apiList[currentApiIndex.value]?.id || '')
|
||||
const tmpDomain = ref('https://www.zakoflare.com')
|
||||
@@ -71,7 +74,9 @@ const testDomain = ref('')
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
const result = ref<PerformanceCheckResponse | null>(null)
|
||||
const checkUrl = computed(() => "/middleware/" + backendID.value + "/detail/" + testDomain.value);
|
||||
// 高级选项(dns4/dns6 + resolve/resolve4/resolve6):本页一次探测两栈
|
||||
const adv = ref<InstanceType<typeof AdvancedOptions> | null>(null)
|
||||
const checkUrl = computed(() => withQuery("/middleware/" + backendID.value + "/detail/" + testDomain.value, adv.value?.query() ?? {}));
|
||||
// testDomain 是完整 URL(含 https:// 与路径斜杠),服务端 [...slug].get.ts 依赖
|
||||
// 分段重组协议部分,这里刻意不做 encodeURIComponent
|
||||
|
||||
@@ -136,7 +141,8 @@ onMounted(() => {
|
||||
<div class="one-line">
|
||||
<el-input
|
||||
v-model="tmpDomain"
|
||||
placeholder="请输入域名(如:https://zakoflare.com)"
|
||||
placeholder="请输入域名(如:https://zakoflare.com)"
|
||||
clearable
|
||||
/>
|
||||
<el-button
|
||||
@click="checkWeb()"
|
||||
@@ -147,6 +153,8 @@ onMounted(() => {
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<AdvancedOptions ref="adv" />
|
||||
|
||||
<div v-if="error" class="error-message">
|
||||
{{ error }}
|
||||
</div>
|
||||
@@ -305,10 +313,10 @@ onMounted(() => {
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
html.dark {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
.el-icon{
|
||||
font-size: 1.3em;
|
||||
|
||||
@@ -5,8 +5,8 @@ import {config} from '../../config/index';
|
||||
import { useMiddlewareFetch } from '../../utils/middleware';
|
||||
import { CircleCheckFilled, CircleCloseFilled } from '@element-plus/icons-vue';
|
||||
import { useRoute } from 'vue-router'
|
||||
import { highlightCode } from '../../utils/shiki'
|
||||
import { isIPv4 } from '../../utils/tools';
|
||||
import { wgs84ToGcj02 } from '../../utils/gcj02';
|
||||
const route = useRoute();
|
||||
const loading = ref(false);
|
||||
|
||||
@@ -48,6 +48,8 @@ interface IPLocationType {
|
||||
bilibili?: any;
|
||||
ip?: string;
|
||||
geocn?: any;
|
||||
lemondb?: any;
|
||||
lemondb_asn?: any;
|
||||
ip2region?: any;
|
||||
ip2location?: any;
|
||||
ip2location_asn?: any;
|
||||
@@ -68,7 +70,22 @@ curl ${config.v6OnlyAPI}
|
||||
# (访问 IPv4/IPv6 双栈站点,如果返回 IPv6 地址,则 IPv6 访问优先)
|
||||
curl ${config.DualStackAPI}
|
||||
`.trim();
|
||||
const html = ref('');
|
||||
|
||||
// 代码高亮放 SSR 期算(与首页同款做法):HTML 里直接是带 <span> 的高亮结果,
|
||||
// 客户端不必再下载/执行 shiki(引擎 + 语言 + 主题 ≈ 164KB),也不会出现
|
||||
// "先渲染纯文本、稍后换成高亮"的块高变化。代码是构建期常量,结果可随 HTML 一起缓存。
|
||||
// import 写在 handler 内部(动态 import 单独成 chunk),首屏不会预载它。
|
||||
const { data: html } = await useAsyncData(
|
||||
'location-curl-code',
|
||||
async () => {
|
||||
const { highlightCode } = await import('../../utils/shiki');
|
||||
return await highlightCode(code, 'bash');
|
||||
},
|
||||
// 默认值给 code(不是空串):这里模板只有单个 v-html,没有 fallback 分支,
|
||||
// 高亮失败时正好退回原始代码文本,别让代码块空着。
|
||||
// (首页那处模板有 v-else 分支,所以那边默认值必须留空,两处不可照抄。)
|
||||
{ default: () => code },
|
||||
);
|
||||
const apiList = config.IPLocationAPI
|
||||
const currentApiIndex = ref(0)
|
||||
const backendID = computed(() => apiList[currentApiIndex.value]?.id || '')
|
||||
@@ -76,6 +93,88 @@ const ipAddress = ref('');
|
||||
const IPLocation = ref<IPLocationType>({});
|
||||
const UserIP = ref('');
|
||||
const error = ref('')
|
||||
|
||||
// —— 归属地地图:高德瓦片(GCJ-02)+ Leaflet,免 key ——
|
||||
// 每个有坐标的来源各画一个点(bilibili / geocn 坐标已是 GCJ-02 直接用;
|
||||
// maxmind / ip2location / dbip / lemondb 为 WGS84 → 转 GCJ-02 与底图对齐),
|
||||
// 多点同时展示可直观看出各库定位的差异与离散度。
|
||||
const mapContainer = ref<HTMLElement | null>(null)
|
||||
let mapInstance: any = null
|
||||
let markerGroup: any = null
|
||||
|
||||
const SOURCE_DEFS = [
|
||||
{ key: 'lemondb', lat: 'latitude', lng: 'longitude', gcj: false, label: 'LemonDB', color: '#ffab00' },
|
||||
{ key: 'bilibili', lat: 'latitude', lng: 'longitude', gcj: true, label: 'bilibili Live', color: '#299764' },
|
||||
{ key: 'maxmind_city', lat: 'latitude', lng: 'longitude', gcj: false, label: 'MaxMind', color: '#1d4ed8' },
|
||||
{ key: 'ip2location', lat: 'latitude', lng: 'longitude', gcj: false, label: 'IP2Location', color: '#f97316' },
|
||||
{ key: 'dbip_city', lat: 'latitude', lng: 'longitude', gcj: false, label: 'DB-IP', color: '#8b5cf6' },
|
||||
{ key: 'geocn', lat: 'latitude', lng: 'longitude', gcj: true, label: 'GeoCN', color: '#0ea5e9' },
|
||||
]
|
||||
|
||||
const mapPoints = computed(() => {
|
||||
const r = IPLocation.value
|
||||
if (!r) return []
|
||||
const pts: Array<{ lat: number; lng: number; label: string; color: string }> = []
|
||||
for (const s of SOURCE_DEFS) {
|
||||
const lat = parseFloat(r[s.key]?.[s.lat])
|
||||
const lng = parseFloat(r[s.key]?.[s.lng])
|
||||
if (Number.isFinite(lat) && Number.isFinite(lng) && !(lat === 0 && lng === 0)) {
|
||||
// LemonDB 全库统一 WGS-84(coord_system 恒为 wgs84,这里留个动态判断作前向兼容,
|
||||
// 若哪天源库换坐标系标注会自动跟随);其余源维持静态标记
|
||||
const gcj = s.gcj || r[s.key]?.coord_system === 'gcj02'
|
||||
const p = gcj ? { lat, lng } : wgs84ToGcj02(lat, lng)
|
||||
pts.push({ ...p, label: s.label, color: s.color })
|
||||
}
|
||||
}
|
||||
return pts
|
||||
})
|
||||
|
||||
let leafletModule: any = null
|
||||
async function renderLocationMap() {
|
||||
if (!import.meta.client || !mapPoints.value.length || !mapContainer.value) return
|
||||
const pts = mapPoints.value
|
||||
leafletModule = leafletModule || (await import('leaflet'))
|
||||
const L = leafletModule.default ?? leafletModule
|
||||
if (!mapInstance) {
|
||||
mapInstance = L.map(mapContainer.value, { attributionControl: true })
|
||||
L.tileLayer('https://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}', {
|
||||
subdomains: ['1', '2', '3', '4'],
|
||||
maxZoom: 18,
|
||||
// 高德栅格瓦片原生层级上限约 17:部分区域(尤其县乡)z=18 会返回纯米色
|
||||
// "无数据"空瓦片。声明 maxNativeZoom 后,Leaflet 对更高缩放自动放大
|
||||
// 17 级瓦片(轻度模糊但绝不变空白)。
|
||||
maxNativeZoom: 17,
|
||||
attribution: '© <a href="https://www.amap.com/" target="_blank" rel="noreferrer">高德地图</a>',
|
||||
}).addTo(mapInstance)
|
||||
}
|
||||
if (markerGroup) markerGroup.remove()
|
||||
markerGroup = L.featureGroup()
|
||||
for (const p of pts) {
|
||||
L.circleMarker([p.lat, p.lng], {
|
||||
radius: 8,
|
||||
color: p.color,
|
||||
fillColor: p.color,
|
||||
fillOpacity: 0.85,
|
||||
weight: 2,
|
||||
})
|
||||
.bindPopup(`<b>${p.label}</b><br>${ipAddress.value || UserIP.value}<br>${p.lat.toFixed(5)}, ${p.lng.toFixed(5)}`)
|
||||
.addTo(markerGroup)
|
||||
}
|
||||
markerGroup.addTo(mapInstance)
|
||||
// 多点:视野自适应包住全部点;单点:定位到 10 级
|
||||
if (pts.length > 1) {
|
||||
mapInstance.fitBounds(markerGroup.getBounds().pad(0.3))
|
||||
} else {
|
||||
mapInstance.setView([pts[0].lat, pts[0].lng], 10)
|
||||
}
|
||||
}
|
||||
|
||||
watch(IPLocation, async () => {
|
||||
if (mapPoints.value.length) {
|
||||
await nextTick()
|
||||
await renderLocationMap()
|
||||
}
|
||||
})
|
||||
const locationUrl = computed(() => "/middleware/" + backendID.value + "/location/" + encodeURIComponent(ipAddress.value));
|
||||
|
||||
const { data: locationData, error: locationError, execute: executeLocation } = useMiddlewareFetch<IPLocationType>(locationUrl, {
|
||||
@@ -118,7 +217,8 @@ function locateIP(IP: string){
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
html.value = await highlightCode(code, 'bash')
|
||||
// (代码高亮已移到 setup 顶部的 useAsyncData,随 SSR 一起产出,这里只剩定位查询。)
|
||||
|
||||
const urlParam = route.query.ip;
|
||||
if (urlParam) {
|
||||
ipAddress.value = urlParam as string;
|
||||
@@ -150,7 +250,8 @@ onMounted(async () => {
|
||||
<div class="one-line">
|
||||
<el-input
|
||||
v-model="ipAddress"
|
||||
placeholder="请输入IP地址"
|
||||
placeholder="请输入IP地址"
|
||||
clearable
|
||||
/>
|
||||
<el-button
|
||||
@click="locateIP(ipAddress)"
|
||||
@@ -171,6 +272,17 @@ onMounted(async () => {
|
||||
<div v-if="IPLocation" class="result-section">
|
||||
<table class="result-table">
|
||||
<tbody>
|
||||
<tr v-if="IPLocation.lemondb && (IPLocation.lemondb.country || IPLocation.lemondb.administrative_area || IPLocation.lemondb.city)">
|
||||
<td class="table-label">LemonDB</td>
|
||||
<td class="table-value">
|
||||
{{ IPLocation.lemondb?.country }} {{ IPLocation.lemondb?.administrative_area }} {{ IPLocation.lemondb?.city }} {{ IPLocation.lemondb?.district }}
|
||||
</td>
|
||||
<td class="table-value">
|
||||
<span>
|
||||
{{ IPLocation.lemondb?.isp }} {{ IPLocation.lemondb?.type }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="IPLocation.bilibili && (IPLocation.bilibili.administrative_area || IPLocation.bilibili.city)">
|
||||
<td class="table-label">bilibili Live接口</td>
|
||||
<td class="table-value">
|
||||
@@ -217,6 +329,8 @@ onMounted(async () => {
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- 归属地地图:高德瓦片(GCJ-02)+ Leaflet,每个有坐标的来源各画一点 -->
|
||||
<div v-if="mapPoints.length" ref="mapContainer" class="location-map"></div>
|
||||
</div>
|
||||
<div style="font-size: 1.5em;">
|
||||
<h3 v-if="isIPv6(UserIP)"><el-icon><CircleCheckFilled style="color: lightgreen;"/></el-icon>您的网络IPv6优先</h3>
|
||||
@@ -242,11 +356,22 @@ onMounted(async () => {
|
||||
<style scoped>
|
||||
@import "../style.css";
|
||||
@import "../../assets/css/tool-common.css";
|
||||
/* leaflet 基础样式必须非 scoped 引入(动态创建的窗格拿不到 data-v 属性) */
|
||||
</style>
|
||||
<style>
|
||||
@import "leaflet/dist/leaflet.css";
|
||||
.location-map {
|
||||
height: 320px;
|
||||
margin-top: 16px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--el-border-color-lighter, #ebeef5);
|
||||
z-index: 0; /* 压住 leaflet 内部窗格的层级,避免盖过下拉/弹窗 */
|
||||
}
|
||||
</style>
|
||||
<style>
|
||||
@import "../style.css";
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
.el-icon{
|
||||
font-size: 1.3em;
|
||||
@@ -429,7 +554,7 @@ html.dark pre code {
|
||||
|
||||
.badge-item h4 {
|
||||
margin: 0 0 15px 0;
|
||||
color: #3EAF7C;
|
||||
color: #299764;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, nextTick } from 'vue'
|
||||
import { ref, onMounted, onBeforeUnmount, nextTick } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { config } from '../../config/index'
|
||||
import { Loading } from '@element-plus/icons-vue'
|
||||
@@ -10,14 +10,40 @@ const route = useRoute()
|
||||
const url = ref('')
|
||||
|
||||
useHead({
|
||||
title: '网站截图工具 - '+(route.query.site || config.siteName),
|
||||
// 原标题「网站截图工具 - 站名」默认态过短;描述不足 50 字被审计判过短,一并加长。
|
||||
title: route.query.site
|
||||
? `网站截图工具 - ${route.query.site} 的网页快照 | ${config.siteName}`
|
||||
: `网站截图工具 - 在线网页快照生成 | ${config.siteName}`,
|
||||
meta: [
|
||||
{ name: 'description', content: '在线网站截图工具,输入网址即可获取网页快照,支持所有公开网站的实时截图,方便查看网站布局和设计效果' },
|
||||
{ name: 'keywords', content: '网站截图,网页快照,在线截图,网页预览,网站布局查看,截图工具' },
|
||||
{ property: 'og:title', content: '网站截图工具 - 在线网页快照' },
|
||||
{ property: 'og:description', content: '输入网址即可获取网页快照,查看网站布局和设计效果' },
|
||||
{ name: 'description', content: '在线网站截图工具:输入网址即可获取网页实时快照,支持任意公开网站的整页截图与预览,查看网页布局、设计效果与渲染状态,可用于页面监控、设计走查与内容存档比对,免费无需注册' },
|
||||
{ name: 'keywords', content: '网站截图,网页快照,在线截图,网页预览,网站布局查看,截图工具,整页截图,网页快照生成' },
|
||||
{ property: 'og:title', content: '网站截图工具 - 在线网页快照生成' },
|
||||
{ property: 'og:description', content: '输入网址即可获取网页实时快照,查看网页布局与设计效果,支持任意公开网站,免费无需注册' },
|
||||
{ property: 'og:image', content: config.siteUrl + 'favicon.svg' },
|
||||
{ property: 'og:type', content: 'website' },
|
||||
],
|
||||
script: [
|
||||
{
|
||||
type: 'application/ld+json',
|
||||
innerHTML: JSON.stringify({
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'WebApplication',
|
||||
name: '网站截图工具',
|
||||
description: '在线网站截图工具,输入网址即可获取网页实时快照,支持任意公开网站的整页截图与预览。',
|
||||
url: new URL('/screenshot', config.siteUrl).href,
|
||||
applicationCategory: 'UtilitiesApplication',
|
||||
operatingSystem: 'Web',
|
||||
offers: {
|
||||
'@type': 'Offer',
|
||||
price: '0',
|
||||
priceCurrency: 'CNY'
|
||||
},
|
||||
provider: {
|
||||
'@type': 'Organization',
|
||||
name: config.siteName
|
||||
}
|
||||
})
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
@@ -26,6 +52,8 @@ const loading = ref(false)
|
||||
const error = ref('')
|
||||
const screenshotUrl = ref('')
|
||||
const imgLoaded = ref(false)
|
||||
// 主通道(thum.io)经 fetch 下载后以 blob URL 喂给 <img>;换新截图前要 revoke 旧的
|
||||
const blobUrl = ref('')
|
||||
|
||||
|
||||
let detectionImg: HTMLImageElement | null = null
|
||||
@@ -38,6 +66,45 @@ const DEFAULT_MSHOTS_WIDTH = 1200
|
||||
const DEFAULT_MSHOTS_HEIGHT = 900
|
||||
const LOADING_TIMEOUT = 15000 // 15 seconds
|
||||
|
||||
// —— 主通道:thum.io(同步出图、CORS 全开)——
|
||||
// content-type 即结果信号:image/png|jpeg = 成品;image/gif = thum.io 的
|
||||
// 「生成中/目标不可达」动画(对没缓存且生成慢的站首访可能出现)→ 等片刻重试一次,
|
||||
// 仍 GIF 就放弃。网络层失败(被墙/CSP/超时)→ 立即回退 mshots。
|
||||
const THUM_TIMEOUT = 10_000
|
||||
const THUM_RETRY_DELAY = 4_000
|
||||
|
||||
async function takeThumio(target: string, requestId: number): Promise<string | null> {
|
||||
for (let attempt = 0; attempt < 2; attempt++) {
|
||||
if (requestId !== currentRequestId) return null
|
||||
try {
|
||||
const ctrl = new AbortController()
|
||||
const timer = setTimeout(() => ctrl.abort(), THUM_TIMEOUT)
|
||||
const res = await fetch(`${config.screenshotAPI}/get/width/1280/${target}`, { signal: ctrl.signal })
|
||||
clearTimeout(timer)
|
||||
if (requestId !== currentRequestId) return null
|
||||
const type = res.headers.get('content-type') || ''
|
||||
if (res.ok && /^image\/(png|jpe?g)\b/.test(type)) {
|
||||
return URL.createObjectURL(await res.blob())
|
||||
}
|
||||
if (attempt === 0) {
|
||||
await new Promise(r => setTimeout(r, THUM_RETRY_DELAY))
|
||||
continue
|
||||
}
|
||||
return null
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
function releaseBlob() {
|
||||
if (blobUrl.value) {
|
||||
URL.revokeObjectURL(blobUrl.value)
|
||||
blobUrl.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
async function getUserIP(){
|
||||
try {
|
||||
userIP.value = await $fetch<string>(config.DualStackAPI)
|
||||
@@ -82,14 +149,31 @@ function takeScreenshot() {
|
||||
imgLoaded.value = false
|
||||
loading.value = true
|
||||
screenshotUrl.value = ''
|
||||
releaseBlob()
|
||||
|
||||
const requestId = ++currentRequestId
|
||||
|
||||
// Set the screenshot URL on next tick so Vue can update the displayed <img>
|
||||
nextTick(() => {
|
||||
nextTick(async () => {
|
||||
// Check if this request was superseded
|
||||
if (requestId !== currentRequestId) return
|
||||
|
||||
// —— 主通道 thum.io:fetch 下载成 blob 直接展示(同步出图,无「请稍后」体验)——
|
||||
const blob = await takeThumio(url.value, requestId)
|
||||
if (requestId !== currentRequestId) {
|
||||
if (blob) URL.revokeObjectURL(blob)
|
||||
return
|
||||
}
|
||||
if (blob) {
|
||||
blobUrl.value = blob
|
||||
screenshotUrl.value = blob
|
||||
// blob 已完整在手,无需等 <img> 的 load 事件再揭开
|
||||
imgLoaded.value = true
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
// —— 回退 mshots:异步生成,先重定向到占位图,需要隐藏 <img> 探测真伪 ——
|
||||
screenshotUrl.value = `https://s0.wp.com/mshots/v1/${encodeURIComponent(url.value)}`
|
||||
|
||||
// Create a hidden detection image to check for default WordPress error image
|
||||
@@ -153,6 +237,11 @@ function onImageError() {
|
||||
showError('截图加载失败,请检查网址是否正确')
|
||||
}
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
cleanupDetection()
|
||||
releaseBlob()
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
const urlParam = route.query.site as string
|
||||
if (urlParam) {
|
||||
@@ -180,6 +269,7 @@ const doc = page.value
|
||||
<el-input
|
||||
v-model="tmpDomain"
|
||||
placeholder="请输入网址(如:https://example.com)"
|
||||
clearable
|
||||
@keyup.enter="takeScreenshot"
|
||||
/>
|
||||
<el-button
|
||||
@@ -286,7 +376,7 @@ html.dark .loading-overlay p {
|
||||
}
|
||||
|
||||
.markdown :deep(a) {
|
||||
color: #3EAF7C !important;
|
||||
color: #299764 !important;
|
||||
font-size: 1.3em;
|
||||
text-decoration: none
|
||||
}
|
||||
|
||||
@@ -3,7 +3,8 @@ import { ref, onMounted, computed, nextTick } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { config } from '../../config/index';
|
||||
import { useMiddlewareFetch } from '../../utils/middleware';
|
||||
import { extractHost, formatTime, formatSpeed, formatSize, getStatusCodeClass } from '../../utils/tools';
|
||||
import { extractHost, formatTime, formatSpeed, formatSize, getStatusCodeClass, withQuery } from '../../utils/tools';
|
||||
import AdvancedOptions from '../components/AdvancedOptions.vue';
|
||||
|
||||
|
||||
const route = useRoute()
|
||||
@@ -48,6 +49,8 @@ const loading = ref(false)
|
||||
const result = ref<any[]>([])
|
||||
const error = ref('')
|
||||
const domain = ref('')
|
||||
// 高级选项(dns4 / resolve / resolve4):用户填了才拼进请求
|
||||
const adv = ref<InstanceType<typeof AdvancedOptions> | null>(null)
|
||||
|
||||
/** 服务器结果接口 */
|
||||
interface ServerResult {
|
||||
@@ -72,7 +75,7 @@ const serverResults = ref<ServerResult[]>([])
|
||||
|
||||
/** 双栈服务器:同时支持 IPv4/IPv6 的节点 */
|
||||
const dualStackFetches = config.APIBaseURL.DualStack.map((server) => {
|
||||
const url = computed(() => "/middleware/" + server.id + "/speed/v4/" + encodeURIComponent(domain.value));
|
||||
const url = computed(() => withQuery("/middleware/" + server.id + "/speed/v4/" + encodeURIComponent(domain.value), adv.value?.query() ?? {}));
|
||||
const { data, error: fetchError, execute } = useMiddlewareFetch(url, {
|
||||
immediate: false,
|
||||
watch: false,
|
||||
@@ -82,7 +85,7 @@ const dualStackFetches = config.APIBaseURL.DualStack.map((server) => {
|
||||
|
||||
/** IPv4 专用服务器:仅支持 IPv4 的节点 */
|
||||
const ipv4Fetches = config.APIBaseURL.IPv4.map((server) => {
|
||||
const url = computed(() => "/middleware/" + server.id + "/speed/v4/" + encodeURIComponent(domain.value));
|
||||
const url = computed(() => withQuery("/middleware/" + server.id + "/speed/v4/" + encodeURIComponent(domain.value), adv.value?.query() ?? {}));
|
||||
const { data, error: fetchError, execute } = useMiddlewareFetch(url, {
|
||||
immediate: false,
|
||||
watch: false,
|
||||
@@ -180,7 +183,8 @@ onMounted(() => {
|
||||
<div class="one-line">
|
||||
<el-input
|
||||
v-model="tmpDomain"
|
||||
placeholder="请输入域名(如:https://zakoflare.com)"
|
||||
placeholder="请输入域名(如:https://zakoflare.com)"
|
||||
clearable
|
||||
/>
|
||||
<el-button
|
||||
@click="SpeedTest()"
|
||||
@@ -191,6 +195,8 @@ onMounted(() => {
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<AdvancedOptions ref="adv" stack="ipv4" />
|
||||
|
||||
<div v-if="error" class="error-message">
|
||||
{{ error }}
|
||||
</div>
|
||||
@@ -272,10 +278,10 @@ onMounted(() => {
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
html.dark {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
.el-icon{
|
||||
font-size: 1.3em;
|
||||
|
||||
@@ -4,7 +4,8 @@ import { useRoute } from 'vue-router'
|
||||
import { CircleCheckFilled, CircleCloseFilled,InfoFilled } from '@element-plus/icons-vue';
|
||||
import { config } from '../../config/index';
|
||||
import { useMiddlewareFetch } from '../../utils/middleware';
|
||||
import { extractHost, getStatusCodeClass, formatTime, formatSpeed } from '../../utils/tools';
|
||||
import { extractHost, getStatusCodeClass, formatTime, formatSpeed, withQuery } from '../../utils/tools';
|
||||
import AdvancedOptions from '../components/AdvancedOptions.vue';
|
||||
const route = useRoute()
|
||||
|
||||
const siteUrlWithSlash = computed(() => config.siteUrl.replace(/\/$/, '') + '/')
|
||||
@@ -62,10 +63,13 @@ interface SSLCheckItem {
|
||||
issuer_organization: string[] | null
|
||||
issuer_common_name: string
|
||||
subject_common_name: string
|
||||
san: string[] | null
|
||||
is_expired: boolean
|
||||
is_reachable: boolean
|
||||
}
|
||||
const apiList = config.APIBaseURL.DualStack
|
||||
const apiList = [
|
||||
...config.APIBaseURL.DualStack,
|
||||
]
|
||||
const currentApiIndex = ref(0)
|
||||
const backendID = computed(() => apiList[currentApiIndex.value]?.id || '')
|
||||
const tmpDomain = ref('https://www.zakoflare.com')
|
||||
@@ -73,7 +77,16 @@ const testDomain = ref('')
|
||||
const loading = ref(false)
|
||||
const error = ref('')
|
||||
const result = ref<SSLCheckResponse | null>(null)
|
||||
const sslUrl = computed(() => "/middleware/" + backendID.value + "/ssl/" + encodeURIComponent(testDomain.value));
|
||||
// SAN 行只在「至少一个栈拿到非空 SAN」时渲染:两栈都空(节点未升级返回无 san 字段、
|
||||
// 或证书本就没有 SAN)时整行隐藏,而不是渲染一行「- -」
|
||||
const showSanRow = computed(() => {
|
||||
const r = result.value
|
||||
if (!r) return false
|
||||
return !!((r.ipv4?.is_reachable && r.ipv4.san?.length) || (r.ipv6?.is_reachable && r.ipv6.san?.length))
|
||||
})
|
||||
// 高级选项(dns4/dns6 + resolve/resolve4/resolve6):本页一次探测两栈
|
||||
const adv = ref<InstanceType<typeof AdvancedOptions> | null>(null)
|
||||
const sslUrl = computed(() => withQuery("/middleware/" + backendID.value + "/ssl/" + encodeURIComponent(testDomain.value), adv.value?.query() ?? {}));
|
||||
|
||||
const { data: sslData, error: sslError, execute: executeSSL } = useMiddlewareFetch<SSLCheckResponse>(sslUrl, {
|
||||
immediate: false,
|
||||
@@ -146,7 +159,8 @@ onMounted(() => {
|
||||
<div class="one-line">
|
||||
<el-input
|
||||
v-model="tmpDomain"
|
||||
placeholder="请输入域名(如:https://zakoflare.com)"
|
||||
placeholder="请输入域名(如:https://zakoflare.com)"
|
||||
clearable
|
||||
/>
|
||||
<el-button
|
||||
@click="checkSSL()"
|
||||
@@ -157,6 +171,8 @@ onMounted(() => {
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<AdvancedOptions ref="adv" />
|
||||
|
||||
<div v-if="error" class="error-message">
|
||||
{{ error }}
|
||||
</div>
|
||||
@@ -201,6 +217,17 @@ onMounted(() => {
|
||||
<span v-else>-</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="showSanRow">
|
||||
<td class="table-label">SAN(备用域名)</td>
|
||||
<td class="table-value">
|
||||
<template v-if="result.ipv4!.is_reachable && result.ipv4!.san?.length">{{ result.ipv4!.san.join(', ') }}</template>
|
||||
<span v-else>-</span>
|
||||
</td>
|
||||
<td class="table-value">
|
||||
<template v-if="result.ipv6 && result.ipv6.is_reachable && result.ipv6.san?.length">{{ result.ipv6.san.join(', ') }}</template>
|
||||
<span v-else>-</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="table-label">签发者</td>
|
||||
<td class="table-value">
|
||||
@@ -389,7 +416,7 @@ onMounted(() => {
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
.el-icon{
|
||||
font-size: 1.3em;
|
||||
|
||||
@@ -3,7 +3,8 @@ import { ref, onMounted, computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { config } from '../../config/index';
|
||||
import { useMiddlewareFetch } from '../../utils/middleware';
|
||||
import { extractHost } from '../../utils/tools';
|
||||
import { extractHost, withQuery } from '../../utils/tools';
|
||||
import AdvancedOptions from '../components/AdvancedOptions.vue';
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
@@ -76,6 +77,8 @@ const tmpDomain = ref('www.zakoflare.com')
|
||||
const port = ref('80')
|
||||
const loading = ref(false)
|
||||
const serverResults = ref<ServerResult[]>([])
|
||||
// 高级选项(dns4 / resolve / resolve4):用户填了才拼进请求
|
||||
const adv = ref<InstanceType<typeof AdvancedOptions> | null>(null)
|
||||
// 查询序号:连续点击时旧查询的结果不允许写入新查询的结果表
|
||||
let queryId = 0
|
||||
|
||||
@@ -85,7 +88,7 @@ const allServers = [
|
||||
];
|
||||
|
||||
const tcpingFetches = allServers.map((server) => {
|
||||
const url = computed(() => "/middleware/" + server.id + "/tcping/" + encodeURIComponent(extractHost(tmpDomain.value)) + "?port=" + encodeURIComponent(port.value));
|
||||
const url = computed(() => withQuery("/middleware/" + server.id + "/tcping/" + encodeURIComponent(extractHost(tmpDomain.value)) + "?port=" + encodeURIComponent(port.value) + "&version=ipv4", adv.value?.query() ?? {}));
|
||||
const { data, error: fetchError, execute } = useMiddlewareFetch<TCPingResponse>(url, {
|
||||
immediate: false,
|
||||
watch: false,
|
||||
@@ -95,7 +98,8 @@ const tcpingFetches = allServers.map((server) => {
|
||||
|
||||
function initServerResults() {
|
||||
const results: ServerResult[] = []
|
||||
|
||||
|
||||
// 与 allServers 顺序保持一致:DualStack → IPv4
|
||||
config.APIBaseURL.DualStack.forEach((server: ServerConfig) => {
|
||||
results.push({
|
||||
label: server.label,
|
||||
@@ -186,11 +190,13 @@ onMounted(() => {
|
||||
<div class="one-line">
|
||||
<el-input
|
||||
v-model="tmpDomain"
|
||||
placeholder="请输入域名(如:example.com)"
|
||||
placeholder="请输入域名(如:example.com)"
|
||||
clearable
|
||||
/>
|
||||
<el-input
|
||||
v-model="port"
|
||||
placeholder="端口号(默认 80)"
|
||||
placeholder="端口号(默认 80)"
|
||||
clearable
|
||||
style="width: 200px;"
|
||||
/>
|
||||
<el-button
|
||||
@@ -202,6 +208,8 @@ onMounted(() => {
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<AdvancedOptions ref="adv" stack="ipv4" />
|
||||
|
||||
<div class="result-section">
|
||||
<table class="result-table">
|
||||
<thead>
|
||||
@@ -256,6 +264,20 @@ onMounted(() => {
|
||||
@import "../style.css";
|
||||
@import "../../assets/css/tool-common.css";
|
||||
|
||||
/* 本页行是双输入框(420×2 + 按钮 165 + 间距 ≈ 1035px),换行点远高于通用阈值的
|
||||
615px:容器低于 1050px(≈自然换行点)时换行元素铺满整行,消除中间的夹缝区。 */
|
||||
@container (max-width: 1050px) {
|
||||
.el-input,
|
||||
.el-button {
|
||||
width: 100% !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
|
||||
.el-input {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.el-menu--horizontal > .el-menu-item:nth-child(1) {
|
||||
margin-right: auto;
|
||||
}
|
||||
@@ -271,11 +293,11 @@ onMounted(() => {
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
|
||||
html.dark {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
|
||||
.el-icon {
|
||||
|
||||
@@ -3,25 +3,26 @@ import { useMiddlewareFetch } from '../../utils/middleware';
|
||||
import { ref, onMounted, computed, watch, nextTick } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { config } from '../../config/index'
|
||||
import { withQuery } from '../../utils/tools'
|
||||
import AdvancedOptions from '../components/AdvancedOptions.vue'
|
||||
import { isIPv6 } from 'is-ip'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
useHead({
|
||||
title: 'Whois查询 | ' + (route.query.site || config.siteName),
|
||||
// 原标题「Whois查询 | 站名」只有十几个字符,被 SEO 审计判为过短;
|
||||
// 带查询参数时展示的是具体域名,单独给一个含关键词的标题。
|
||||
title: route.query.site
|
||||
? `Whois查询结果 - ${route.query.site} 的域名注册信息 | ${config.siteName}`
|
||||
: `Whois域名查询工具 | 域名注册信息与到期时间查询 | ${config.siteName}`,
|
||||
titleTemplate: '%s',
|
||||
link: [
|
||||
{ rel: 'canonical', href: computed(() => new URL(route.path, config.siteUrl).toString()).value }
|
||||
],
|
||||
meta: [
|
||||
{ name: 'description', content: '专业的Whois域名查询工具,支持.com、.net等国内外域名WHOIS信息查询,提供域名注册商、注册时间、到期时间、DNS服务器等详细信息,助力域名管理和交易决策' },
|
||||
{ name: 'description', content: '专业的Whois域名查询工具,支持.com、.net、.cn等国内外域名WHOIS信息在线查询,提供域名注册商、注册时间、到期时间、DNS服务器、域名状态等详细信息,支持IPv4/IPv6多节点检测,助力域名管理与交易决策' },
|
||||
{ name: 'keywords', content: 'whois查询,域名whois,whois信息查询,域名注册信息,域名到期时间,域名注册商,dns服务器查询,域名whois工具' },
|
||||
{ property: 'og:title', content: 'Whois域名查询工具 - 域名注册信息在线查询' },
|
||||
{ property: 'og:description', content: '专业的Whois域名查询工具,支持国内外域名WHOIS信息查询,提供域名注册商、注册时间、到期时间等详细信息' },
|
||||
{ property: 'og:image', content: `${config.siteUrl}favicon.svg` },
|
||||
{ property: 'og:type', content: 'website' },
|
||||
{ property: 'og:url', content: computed(() => new URL(route.path, config.siteUrl).toString()).value },
|
||||
{ name: 'twitter:card', content: 'summary_large_image' },
|
||||
],
|
||||
script: [
|
||||
{
|
||||
@@ -64,10 +65,14 @@ const result = ref<any>(null)
|
||||
const error = ref('')
|
||||
const userIP = ref('')
|
||||
|
||||
const apiList = config.APIBaseURL.DualStack
|
||||
const apiList = [
|
||||
...config.APIBaseURL.DualStack,
|
||||
]
|
||||
const currentApiIndex = ref(0)
|
||||
const backendID = computed(() => apiList[currentApiIndex.value]?.id || '')
|
||||
const whoisUrl = computed(() => '/middleware/' + backendID.value + '/whois/' + encodeURIComponent(domain.value))
|
||||
// 高级选项:whois 只取 DNS 服务器(dns4/dns6),不支持强制解析
|
||||
const adv = ref<InstanceType<typeof AdvancedOptions> | null>(null)
|
||||
const whoisUrl = computed(() => withQuery('/middleware/' + backendID.value + '/whois/' + encodeURIComponent(domain.value), adv.value?.query() ?? {}))
|
||||
|
||||
const { data: whoisData, error: whoisError, execute: executeWhois } = useMiddlewareFetch<any>(whoisUrl, {
|
||||
immediate: false,
|
||||
@@ -168,6 +173,7 @@ function getStatusClass(status: string): string {
|
||||
<el-input
|
||||
v-model="tmpdomain"
|
||||
placeholder="请输入域名(如:example.com)"
|
||||
clearable
|
||||
/>
|
||||
<el-button
|
||||
@click="queryWhois()"
|
||||
@@ -178,6 +184,8 @@ function getStatusClass(status: string): string {
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<AdvancedOptions ref="adv" :show-resolve="false" />
|
||||
|
||||
<div v-if="error" class="error-message">
|
||||
{{ error }}
|
||||
</div>
|
||||
@@ -281,10 +289,15 @@ function getStatusClass(status: string): string {
|
||||
@import "../style.css";
|
||||
@import "../../assets/css/tool-common.css";
|
||||
.markdown :deep(a) {
|
||||
color: #3EAF7C !important;
|
||||
color: #299764 !important;
|
||||
font-size: 1.3em;
|
||||
text-decoration: none
|
||||
}
|
||||
/* 1240px 宽的生命周期图需缩进内容列,桌面端也要约束 */
|
||||
.markdown :deep(img) {
|
||||
height: auto;
|
||||
max-width: 100%;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.markdown :deep(a) {
|
||||
font-size: 1.1em;
|
||||
@@ -319,10 +332,10 @@ function getStatusClass(status: string): string {
|
||||
|
||||
<style>
|
||||
:root {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
html.dark {
|
||||
--el-color-primary: #3EAF7C;
|
||||
--el-color-primary: #299764;
|
||||
}
|
||||
.el-icon{
|
||||
font-size: 1.3em;
|
||||
|
||||
@@ -31,7 +31,10 @@ h3{
|
||||
}
|
||||
.title p{
|
||||
font-size: 25.6px;
|
||||
color: #6A8BAD;
|
||||
/* 首页副标题。原来 #6A8BAD 在白底只有 3.55:1(axe color-contrast,
|
||||
是移动端 12 条里唯一不是链接/代码的那条);加深到 #4D7396 = 4.99:1,
|
||||
色相不变、只是明度降一档。 */
|
||||
color: #4D7396;
|
||||
margin-right: 20px;
|
||||
margin-left: 20px;
|
||||
text-align: center;
|
||||
@@ -106,13 +109,14 @@ blockquote p {
|
||||
margin: 0.5em;
|
||||
}
|
||||
blockquote a{
|
||||
color: #3EAF7C;
|
||||
color: var(--link-color);
|
||||
font-size: 1em;
|
||||
text-decoration: none
|
||||
|
||||
/* 正文里的链接仅靠颜色区分不够(绿 #299764 与周围正文的对比度远低于 3:1),
|
||||
补下划线提供「非颜色」的视觉区分(link-in-text-block) */
|
||||
text-decoration: underline
|
||||
}
|
||||
a {
|
||||
color: #3EAF7C;
|
||||
color: var(--link-color);
|
||||
font-size: 1.3em;
|
||||
text-decoration: none
|
||||
|
||||
@@ -128,7 +132,7 @@ footer .one-line {
|
||||
footer .one-line a {
|
||||
font-size: 1em;
|
||||
text-align: center;
|
||||
color: #3EAF7C;
|
||||
color: var(--link-color);
|
||||
text-decoration: none
|
||||
}
|
||||
footer {
|
||||
@@ -203,17 +207,17 @@ footer {
|
||||
}
|
||||
blockquote a{
|
||||
|
||||
color: #3EAF7C;
|
||||
color: var(--link-color);
|
||||
font-size: 1em;
|
||||
text-decoration: none
|
||||
/* 与上面的非窄屏规则保持一致:窄屏同样靠下划线做非颜色区分。
|
||||
此处若仍写 none,因其位置在后、特异性相同,会把桌面的 underline 盖掉。 */
|
||||
text-decoration: underline
|
||||
}
|
||||
}
|
||||
html.dark {
|
||||
/* 在暗色模式下,覆盖根元素的文字颜色和背景色 */
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
background-color: #242424;
|
||||
--el-color-primary: #3EAF7C;
|
||||
}
|
||||
/* 注:暗色模式的「根元素」规则(html.dark 的文字色 / 背景色 / 主色变量)已上移到
|
||||
app.vue 的【非 scoped】<style> 块。本文件是被 <style scoped> @import 进来的,
|
||||
凡是作用于 <html> 自身的规则都会被加上 scope 属性而永不匹配。
|
||||
这里只保留作用于「html 后代元素」的规则(后代元素带 scope 属性,能正常命中)。 */
|
||||
html.dark blockquote {
|
||||
/* 在暗色模式下,覆盖根元素的文字颜色和背景色 */
|
||||
color: rgba(255, 255, 255, 0.87);
|
||||
@@ -268,7 +272,7 @@ h4>.header-anchor,
|
||||
h5>.header-anchor,
|
||||
h6>.header-anchor {
|
||||
opacity: 1;
|
||||
color: #3EAF7C;
|
||||
color: var(--link-color);
|
||||
}
|
||||
|
||||
h1:hover>.header-anchor,
|
||||
@@ -281,5 +285,5 @@ h6:hover>.header-anchor {
|
||||
}
|
||||
.header-anchor::before {
|
||||
content: "#";
|
||||
color: #3EAF7C;
|
||||
color: var(--link-color);
|
||||
}
|
||||
@@ -226,7 +226,7 @@ html.dark pre code {
|
||||
|
||||
.badge-item h4 {
|
||||
margin: 0 0 15px 0;
|
||||
color: #3EAF7C;
|
||||
color: #299764;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
@@ -236,6 +236,30 @@ html.dark pre code {
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
/* —— 行内换行自适应(容器查询)——
|
||||
.one-line 里的输入框/按钮是固定宽度,容器放不下时 flex 只换行不改宽,
|
||||
出现「换行了却不铺满」的夹缝态:换行点 ~605px(input 420 + 按钮 165 + 间距)、
|
||||
铺满点 768px(下方媒体查询断点),手机视口直接落在断点内看不出来,
|
||||
桌面缩窗在 768~换行点之间全是夹缝。容器查询补齐:容器低于行内容的
|
||||
自然换行点 ⇒ 换行的元素铺满整行。阈值略高于换行点保证无缝衔接;
|
||||
行内容更宽的页面(tcping 双输入框 1035px、dns 带 select 765px)
|
||||
在各自 scoped 样式里用同名容器再写一条更高阈值的规则。 */
|
||||
.one-line {
|
||||
container-type: inline-size;
|
||||
}
|
||||
|
||||
@container (max-width: 615px) {
|
||||
.el-input,
|
||||
.el-button {
|
||||
width: 100% !important;
|
||||
margin-right: 0 !important;
|
||||
}
|
||||
|
||||
.el-input {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 窄屏响应式:所有组件缩小 */
|
||||
@media (max-width: 768px) {
|
||||
.el-input,
|
||||
|
||||
@@ -1,104 +1,206 @@
|
||||
export interface DocMeta {
|
||||
title: string
|
||||
description: string
|
||||
// —— SEO 专用字段(可选)——
|
||||
// 审计(Bing 站长工具)判定 10 个页面标题过短、13 个页面 meta description 过短,
|
||||
// 全是文档页:上面的 title/description 同时用于侧栏菜单与卡片展示,不适合拉长,
|
||||
// 因此文档页的 <title> 与 meta 优先取这里的加长版(见 doc 两个页面的 useHead)。
|
||||
seoTitle?: string
|
||||
seoDescription?: string
|
||||
}
|
||||
|
||||
export const docConfig: Record<string, DocMeta> = {
|
||||
'/doc': {
|
||||
title: 'IPv6 工具箱使用文档',
|
||||
description: 'IPv6 工具箱使用文档'
|
||||
description: '致力于普及 IPv6,推进 IPv6 规模部署和应用,以全面推进 IPv6 技术创新与融合应用为主线,以提升应用广度深度为主攻方向。支持 IPv6 本地网络(宽带)开启验证、IPv6 网站开启检测、IPv6 Ping 延迟测试、IPv6 网站测速、IPv6 地址查询、IPv6 DNS 解析。',
|
||||
seoTitle: 'IPv6 工具箱使用文档:宽带开启、网站检测、测速与 DNS 解析教程',
|
||||
seoDescription: 'IPv6 工具箱完整使用文档:涵盖家庭宽带开启 IPv6、网站 IPv6 支持检测、IPv6 Ping 延迟测试、IPv6 网站测速、IP 归属地查询与 IPv6 DNS 解析等教程,致力于普及 IPv6、推进 IPv6 规模部署和应用。'
|
||||
},
|
||||
'/doc/user/enable_ipv6': {
|
||||
title: '个人宽带如何开启IPv6网络访问',
|
||||
description: '介绍个人宽带如何开启IPv6网络访问'
|
||||
description: 'IPv6 是大势所趋,就在前段时间湖南联通发布公告,对家庭宽带提供 IPv6 地址,不再提供 IPv4 地址,那本文就介绍个人宽带如何开启 IPv6 网络访问。',
|
||||
seoTitle: '个人宽带如何开启 IPv6 网络访问:光猫与路由器设置教程',
|
||||
seoDescription: '手把手教你为家庭宽带开启 IPv6 网络访问:从光猫与路由器的设置,到向运营商申请(湖南联通等已对家庭宽带提供 IPv6 地址、不再提供 IPv4),附开启后的 IPv6 地址验证方法与常见问题排查。'
|
||||
},
|
||||
'/doc/user/cmd_bash_disable_ipv6': {
|
||||
title: '命令行禁用/启用IPv6本地网络',
|
||||
description: 'macOS和Window10命令行禁用/启用IPv6本地网络'
|
||||
description: '图形化禁用 IPv6 网络比较繁琐,以下是 macOS 和 Window 10 命令行下禁用/启用 IPv6 本地网络的方法。',
|
||||
seoTitle: 'macOS / Windows 命令行禁用或启用 IPv6 本地网络',
|
||||
seoDescription: '图形化开关 IPv6 网络比较繁琐,本文整理 macOS(networksetup)与 Windows 10/11(netsh、PowerShell)命令行下禁用/启用 IPv6 本地网络的完整命令,可直接复制执行,便于脚本化批量管理多台机器。'
|
||||
},
|
||||
'/doc/user/cmd_getip': {
|
||||
title: '命令行(curl)获取 IPv4 和 IPv6 地址',
|
||||
description: '使用命令行curl获取IPv4和IPv6地址'
|
||||
description: '通过 curl 命令获取公网 IPv4 和 IPv6 地址,还可以返回是 IPv4 还是 IPv6 访问优先。',
|
||||
seoTitle: 'curl 命令获取公网 IPv4 / IPv6 地址及访问优先级',
|
||||
seoDescription: '通过 curl 命令查询本机公网 IPv4 和 IPv6 地址:分别指定 -4 / -6 强制协议栈,还可一键返回当前网络是 IPv4 还是 IPv6 访问优先。适用于 Linux、macOS、Windows 终端以及监控脚本与 CI 环境调用。'
|
||||
},
|
||||
'/doc/user/view_ipv6_adress_url': {
|
||||
title: '浏览器访问 IPv6 地址',
|
||||
description: '如何在浏览器中访问IPv6地址'
|
||||
description: '在 IPv6 地址两边加上中括号,就可以通过浏览器访问了,比如 http://[2402:4e00:1013:e500:0:9671:f018:4947]/',
|
||||
seoTitle: '浏览器访问 IPv6 地址:中括号写法与端口注意事项',
|
||||
seoDescription: '在 IPv6 地址两边加上中括号即可用浏览器访问,例如 http://[2402:4e00:1013:e500:0:9671:f018:4947]/。本文介绍浏览器访问 IPv6 地址的正确写法、端口号的书写位置,以及无法访问时的排查思路。'
|
||||
},
|
||||
'/doc/user/ipv4_ipv6_prefix_precedence': {
|
||||
title: 'Windows 10/11 设置 IPv4/IPv6 访问优先级',
|
||||
description: 'Windows 10/11 设置 IPv4/IPv6 访问优先级'
|
||||
description: 'Windows 10/11 开启 IPv6 后默认 IPv6 访问优先(以访问 IPv4/IPv6 双栈站点为例,操作系统会优先访问 IPv6),如果期望 IPv4 访问优先,可以通过 netsh 命令调整。',
|
||||
seoTitle: 'Windows 10/11 设置 IPv4/IPv6 访问优先级(netsh 前缀策略)',
|
||||
seoDescription: 'Windows 10/11 开启 IPv6 后默认 IPv6 访问优先(访问 IPv4/IPv6 双栈站点时操作系统会优先走 IPv6)。如果期望 IPv4 访问优先,可通过 netsh interface ipv6 修改前缀策略调整,本文提供可直接复制的命令与恢复默认的方法。'
|
||||
},
|
||||
'/doc/user/ipv6_daohang': {
|
||||
title: '国内 IPv6 资源导航',
|
||||
description: '国内IPv6资源导航列表'
|
||||
description: 'IPv6 网络开启成功后,可以访问一些 IPv6 网站资源,来体验下 IPv6 的魅力。不过目前纯 IPv6 网站比较少,目前网站支持 IPv6 的主流方式为 IPv4/IPv6 双栈访问,毕竟要兼顾 IPv4 网络用户的访问需求。',
|
||||
seoTitle: '国内 IPv6 资源导航:支持 IPv6 访问的网站大全',
|
||||
seoDescription: 'IPv6 网络开启成功后,可以访问这些国内 IPv6 网站资源体验下一代互联网。目前纯 IPv6 网站还比较少,主流网站支持 IPv6 的方式为 IPv4/IPv6 双栈访问,以兼顾 IPv4 网络用户的访问需求。'
|
||||
},
|
||||
'/doc/user/pure_ipv6_website': {
|
||||
title: '国内纯 IPv6 网站导航',
|
||||
description: '国内纯IPv6网站导航列表'
|
||||
description: 'IPv6 网络开启成功后,可以访问一些纯 IPv6 网站资源,来体验下 IPv6 的魅力。',
|
||||
seoTitle: '国内纯 IPv6 网站导航:仅支持 IPv6 访问的站点合集',
|
||||
seoDescription: '收录一批仅提供 IPv6 访问的国内纯 IPv6 网站:家庭宽带开启 IPv6 网络后即可直接访问,用来验证本机 IPv6 连通性,或体验真正的 IPv6-only 互联网服务,列表持续更新。'
|
||||
},
|
||||
'/doc/user/dns': {
|
||||
title: '全国各省 DNS 服务器列表',
|
||||
description: '全国各省DNS服务器列表'
|
||||
description: '全国各省电信、联通、移动的首选 IPv4 DNS 服务器和备用 DNS 服务器,以及公共 DNS 服务器列表,最近更新为 2021-07-25。',
|
||||
seoTitle: '全国各省电信/联通/移动 DNS 服务器地址列表(IPv4)',
|
||||
seoDescription: '全国各省电信、联通、移动的首选与备用 IPv4 DNS 服务器地址汇总,外加 114DNS、阿里 DNS、DNSPod 等公共 DNS 列表,按省份与运营商分类整理,方便网络排障时就近选用延迟最低的 DNS 服务器。'
|
||||
},
|
||||
'/doc/user/ipv6_dns': {
|
||||
title: 'IPv6 DNS 地址列表',
|
||||
description: 'IPv6 DNS地址列表'
|
||||
description: 'IPv6 DNS 地址列表,请求 IPv6 网络需要设置 IPv6 DNS。',
|
||||
seoTitle: 'IPv6 DNS 服务器地址列表:公共 IPv6 DNS 推荐',
|
||||
seoDescription: 'IPv6 网络需要设置 IPv6 DNS 才能正常解析域名。本文汇总国内外常用 IPv6 DNS 服务器地址:包括阿里、DNSPod、Google、Cloudflare 等公共 IPv6 DNS,可直接复制到光猫、路由器或网卡设置中。'
|
||||
},
|
||||
'/doc/user/AliyunAuthorizeSecurityGroup': {
|
||||
title: '阿里云自动化添加安全组',
|
||||
description: '阿里云自动化添加安全组'
|
||||
description: 'Golang 代码实操阿里云自动化添加安全组',
|
||||
seoTitle: 'Golang 实现阿里云 ECS 安全组规则自动化添加',
|
||||
seoDescription: '使用 Golang 调用阿里云 ECS OpenAPI 实现安全组放行规则的自动化添加:包含 SDK 初始化、AccessKey 鉴权、AuthorizeSecurityGroup 接口的参数说明与完整示例代码,适合批量管理多台 ECS 实例的场景。'
|
||||
},
|
||||
'/doc/user/TencentCloudAddSecurityGroup': {
|
||||
title: '腾讯云自动化添加安全组',
|
||||
description: '腾讯云自动化添加安全组'
|
||||
description: 'Golang 代码实操腾讯云自动化添加安全组',
|
||||
seoTitle: 'Golang 实现腾讯云 CVM 安全组规则自动化添加',
|
||||
seoDescription: '使用 Golang 调用腾讯云 CVM OpenAPI 实现安全组规则的自动化添加:涵盖 SDK 安装、密钥配置、安全组策略接口的调用示例与完整源码,便于在脚本中批量放行端口、管理大量云主机实例。'
|
||||
},
|
||||
'/doc/server/website_enable_ipv6': {
|
||||
title: '网站开启 IPv6 的三种方式',
|
||||
description: '从传统二进制部署的Nginx,到云原生部署的K8S、Istio,分别介绍网站开启IPv6的三种方式'
|
||||
description: '从传统二进制部署的 Nginx,到云原生部署的 K8S、Istio,分别介绍网站开启 IPv6 的三种方式。',
|
||||
seoTitle: '网站开启 IPv6 的三种方式:Nginx、K8s 与 Istio',
|
||||
seoDescription: '从传统二进制部署的 Nginx 监听 IPv6 地址,到云原生部署的 K8s Service 双栈与 Istio 网关,一文讲清网站开启 IPv6 的三种方式及各自适用场景,附关键配置片段与开启后的验证方法。'
|
||||
},
|
||||
'/doc/server/tencent_cloud_cvm_ipv6': {
|
||||
title: '腾讯云 cvm 开启 IPv6',
|
||||
description: '一文看懂在腾讯云CVM上开启IPv6,只需7步'
|
||||
description: '一文看懂在腾讯云 CVM 上开启 IPv6,只需 7 步。',
|
||||
seoTitle: '腾讯云 CVM 开启 IPv6 完整教程(只需 7 步)',
|
||||
seoDescription: '一文看懂在腾讯云 CVM 上开启 IPv6:从 VPC 与子网启用 IPv6、给实例分配 IPv6 地址、安全组放行,到系统内网卡配置与连通性验证,共 7 步完成,附每步操作说明与常见报错的处理办法。'
|
||||
},
|
||||
'/doc/server/nginx_ipv6': {
|
||||
title: 'Nginx 开启 IPv6',
|
||||
description: '一文看懂Nginx中开启IPv6,包含设置IPv6 SSL证书'
|
||||
description: '一文看懂 Nginx 中开启 IPv6,包含设置 IPv6 SSL 证书。',
|
||||
seoTitle: 'Nginx 开启 IPv6:listen 监听与 IPv6 SSL 证书配置',
|
||||
seoDescription: '一文看懂 Nginx 中开启 IPv6:listen [::] 监听写法、与 IPv4 共存的配置示例、IPv6 SSL 证书的设置,以及防火墙放行 IPv6 流量,配置完成后可用 IPv6 网站检测工具一键验证。'
|
||||
},
|
||||
'/doc/server/ipv6webcheck': {
|
||||
title: '如何确认一个网站是否开启 IPv6',
|
||||
description: '如何确认一个网站是否开启IPv6'
|
||||
description: '通过 IPv6 网站检测工具,一键检查网站是否开启 IPv6 访问。',
|
||||
seoTitle: '如何确认一个网站是否开启 IPv6:一键检测方法',
|
||||
seoDescription: '使用本站的 IPv6 网站检测工具,输入域名即可一键检查网站是否开启 IPv6 访问:返回 IPv4 与 IPv6 双栈的 HTTP/HTTPS 状态码、DNS 解析与连接耗时对比数据,并可申请 IPv6 徽标认证。'
|
||||
},
|
||||
'/doc/server/ipv6_sign': {
|
||||
title: '网站增加支持IPv6访问标识',
|
||||
description: 'HTML+CSS代码,可以提醒访客本网站支持IPv6访问'
|
||||
description: 'HTML+CSS 代码,可以提醒访客本网站支持 IPv6 访问,同时可以跳转到 IPv6 网站检测页面。',
|
||||
seoTitle: '网站添加「支持 IPv6 访问」标识(HTML+CSS 代码)',
|
||||
seoDescription: '提供一段现成的 HTML+CSS 代码,在网站页脚展示「本网站支持 IPv6 访问」标识,点击即可跳转到 IPv6 网站检测页面实时验证,让访客直观感知网站的 IPv6 支持状态。'
|
||||
},
|
||||
'/doc/server/ipv6_domain_record': {
|
||||
title: '如何为域名添加 IPv6 解析记录',
|
||||
description: '如何为域名添加IPv6解析记录'
|
||||
description: 'IPv6 网站准备好了后,接下来可以为网站域名添加 IPv6 解析记录(AAAA)。',
|
||||
seoTitle: '如何为域名添加 IPv6 解析记录(AAAA 记录)',
|
||||
seoDescription: '网站支持 IPv6 后,还需为域名添加 IPv6 解析记录(AAAA)。本文演示在常见 DNS 服务商控制台添加 AAAA 记录的操作步骤、TTL 建议值,以及添加后用 dig / nslookup 验证解析是否生效。'
|
||||
},
|
||||
'/doc/server/http2': {
|
||||
title: '原创网站如何开启 HTTP/2',
|
||||
description: '介绍网站如何开启HTTP/2协议'
|
||||
title: '网站如何开启 HTTP/2',
|
||||
description: 'HTTP/2 通过引入字段压缩和允许在同一连接上进行多个并发交换,使网络资源得到更有效的利用,并减少了延迟。',
|
||||
seoTitle: '网站如何开启 HTTP/2:Nginx 配置与抓包验证',
|
||||
seoDescription: 'HTTP/2 通过引入字段压缩和允许在同一连接上进行多个并发交换,使网络资源得到更有效的利用并减少延迟。本文介绍网站在 Nginx 中开启 HTTP/2 的配置方法,并用浏览器与 Wireshark 抓包验证协商结果。'
|
||||
},
|
||||
'/doc/rfc/rfc8200': {
|
||||
title: 'IPv6 RFC8200 解读',
|
||||
description: 'RFC8200(Internet Protocol, Version 6 (IPv6) Specification) 是IPv6的权威定义'
|
||||
description: 'RFC8200(Internet Protocol, Version 6 (IPv6) Specification)是 IPv6 的权威定义,接下来在解读 RFC8200 文档中的过程中,加深对 IPv6 的理解。',
|
||||
seoTitle: 'IPv6 RFC 8200 解读:IPv6 协议规范逐节精读',
|
||||
seoDescription: 'RFC 8200(Internet Protocol, Version 6 (IPv6) Specification)是 IPv6 协议的权威定义。本文逐节解读其报文格式、扩展报头、地址语义等核心内容,在精读文档的过程中建立对 IPv6 的完整理解。'
|
||||
},
|
||||
'/doc/rfc/ipv6_address_format': {
|
||||
title: 'IPv6 地址标识方法',
|
||||
description: '首选格式、压缩格式、内嵌IPv4地址的IPv6地址格式'
|
||||
description: '首选格式、压缩格式、内嵌 IPv4 地址的 IPv6 地址格式。',
|
||||
seoTitle: 'IPv6 地址表示方法:首选格式、压缩格式与内嵌 IPv4',
|
||||
seoDescription: 'IPv6 地址共 128 位,本文讲解三种标准表示方法:首选格式(8 组 4 位十六进制数)、零压缩格式(:: 缩写规则)以及内嵌 IPv4 地址的混合表示法,并给出每组示例与常见的书写误区。'
|
||||
},
|
||||
'/doc/user/tcpdump_ipv6': {
|
||||
title: 'tcpdump 分析IPv6包',
|
||||
description: '使用tcpdump分析IPv6包'
|
||||
title: 'tcpdump 分析 IPv6 包',
|
||||
description: 'tcpdump 分析 IPv6 包',
|
||||
seoTitle: 'tcpdump 抓包分析 IPv6 数据包与常用过滤命令',
|
||||
seoDescription: '使用 tcpdump 抓取并分析 IPv6 数据包:整理 ip6、icmp6、TCP/UDP 端口等常用过滤表达式,配合 -nn -vv 等参数看清 IPv6 报文结构,适用于排查 IPv6 连通性与邻居发现(NDP)协议问题。'
|
||||
},
|
||||
'/doc/user/wireshark_ipv6': {
|
||||
title: 'WireShark 分析IPv6包头',
|
||||
description: '使用WireShark分析IPv6包头'
|
||||
description: '使用 WireShark 分析 IPv6 包头',
|
||||
seoTitle: 'WireShark 分析 IPv6 包头:各字段逐项讲解',
|
||||
seoDescription: '使用 WireShark 逐字段分析 IPv6 包头:版本号、流量类别(Traffic Class)、流标签(Flow Label)、有效载荷长度、下一报头、跳数限制与源/目的地址,配合显示过滤器快速定位 IPv6 通信问题。'
|
||||
},
|
||||
'/doc/user/ipv6_ping': {
|
||||
title: 'IPv6 Ping 检测原理',
|
||||
description: 'IPv6 Ping检测原理'
|
||||
description: '协议标准:Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification',
|
||||
seoTitle: 'IPv6 Ping 检测原理:ICMPv6 回显请求与应答',
|
||||
seoDescription: 'IPv6 Ping 基于 ICMPv6 协议(Internet Control Message Protocol for IPv6)的回显请求(Echo Request)与应答(Echo Reply)实现。本文讲解 ICMPv6 报文结构与类型字段,以及 IPv6 为何用多播取代广播探测。'
|
||||
},
|
||||
'/doc/api/ip/locate': {
|
||||
title: '获取客户端公网 IP 及位置',
|
||||
description: '调用本项目的 /v1/location 接口,一次取回访问者自己的公网 IP 与 10 套 IP 库的归属地结果。',
|
||||
seoTitle: 'API 文档:获取客户端公网 IP 与多库归属地结果',
|
||||
seoDescription: '调用本项目的 /v1/location 接口,一次取回访问者自己的公网 IPv4/IPv6 地址与 10 套 IP 库(MaxMind、IP2Region、GeoCN 等)的归属地结果,返回 JSON、支持跨域,附请求示例与响应字段说明。'
|
||||
},
|
||||
'/doc/api/ip/myip': {
|
||||
title: '获取客户端公网 IP 地址',
|
||||
description: '用自带边缘函数获取客户端公网 IP,纯文本返回、支持跨域,可按 IPv4 / IPv6 / 双栈分别部署。',
|
||||
seoTitle: 'API 文档:边缘函数获取客户端公网 IP(纯文本跨域)',
|
||||
seoDescription: '使用本项目自带的边缘函数获取客户端公网 IP:纯文本直接返回、支持 CORS 跨域,可按 IPv4-only / IPv6-only / 双栈三种方式分别部署,适合脚本、服务器监控与 CI 环境快速取公网 IP。'
|
||||
},
|
||||
'/doc/api/ip/query': {
|
||||
title: '查询指定 IP 地址的位置信息',
|
||||
description: '调用本项目的 /v1/location/<ip> 接口查询任意 IPv4 / IPv6 地址的归属地,返回多源聚合结果。',
|
||||
seoTitle: 'API 文档:查询指定 IPv4/IPv6 地址的归属地信息',
|
||||
seoDescription: '调用本项目的 /v1/location/<ip> 接口查询任意 IPv4 / IPv6 地址的归属地:返回多套 IP 数据库聚合的地理位置、运营商、ASN 等结果,支持节点直连与中间件转发两种调用方式,附完整响应示例。'
|
||||
},
|
||||
'/doc/api/whois/query': {
|
||||
title: '查询域名的 WHOIS 信息',
|
||||
description: '调用本项目的 /v1/whois/<domain> 接口查询域名注册信息:IANA → 注册局 → 注册商转介三跳,返回状态、注册商、关键日期与 NS。',
|
||||
seoTitle: 'API 文档:查询域名 WHOIS 注册信息(三跳转介)',
|
||||
seoDescription: '调用本项目的 /v1/whois/<domain> 接口查询域名注册信息:按 IANA → 注册局 → 注册商三跳转介获取完整 WHOIS 数据,返回查询状态、注册商、注册/到期等关键日期与 NS 服务器字段。'
|
||||
},
|
||||
'/doc/server/check_userip_ipv4_ipv6': {
|
||||
title: 'JS 检查网络是 IPv4 还是 IPv6',
|
||||
description: '通过 JS 代码检查客户端是 IPv4 还是 IPv6 访问优先。',
|
||||
seoTitle: 'JS 检查客户端网络是 IPv4 还是 IPv6 访问优先',
|
||||
seoDescription: '通过一段前端 JS 代码检查客户端当前是 IPv4 还是 IPv6 访问、以及双栈网络下的访问优先级:分别向 IPv4/IPv6 探测端点发起请求并按可达性判定,可嵌入任意网页实时展示访客的网络栈状态。'
|
||||
},
|
||||
'/doc/server/tls': {
|
||||
title: '网站如何开启 TLS',
|
||||
description: '用 Wireshark 抓包分析 TLS 1.3 的 TCP 三次握手与 TLS 协商全过程。',
|
||||
seoTitle: '网站如何开启 TLS:TLS 1.3 握手过程抓包分析',
|
||||
seoDescription: '用 Wireshark 抓包分析 TLS 1.3 的 TCP 三次握手与 TLS 协商全过程:ClientHello、密钥共享(Key Share)、证书验证与 Finished 报文逐个拆解,理解网站开启 TLS 加密后的完整建连链路。'
|
||||
},
|
||||
'/doc/user/code_getip': {
|
||||
title: 'Python/Go 获取 IPv4 和 IPv6 地址',
|
||||
description: '通过 Python/Golang 获取公网 IPv4 和 IPv6 地址,还可以返回是 IPv4 还是 IPv6 访问优先。',
|
||||
seoTitle: 'Python / Golang 代码获取公网 IPv4 与 IPv6 地址',
|
||||
seoDescription: '用 Python 和 Golang 获取本机公网 IPv4 和 IPv6 地址:分别请求 IPv4、IPv6 探测端点并判定当前网络的访问优先栈,附可直接运行的完整示例代码,适合嵌入监控脚本或后端服务使用。'
|
||||
},
|
||||
'/doc/user/dns_dig': {
|
||||
title: 'DNS 解析流程',
|
||||
description: '剖析 DNS 解析流程',
|
||||
seoTitle: 'DNS 解析流程详解:递归查询与迭代查询全过程',
|
||||
seoDescription: '剖析一次完整的 DNS 解析流程:浏览器缓存 → 操作系统缓存 → 本地 DNS 服务器的递归查询 → 根域名 / 顶级域 / 权威服务器的迭代过程,配合 dig 命令逐步演示,理解域名解析为何时快时慢。'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
/*
|
||||
前端的一系列配置
|
||||
*/
|
||||
|
||||
const config = {
|
||||
siteUrl: "https://nipw.cn/",
|
||||
// 站点名称:用于页面标题 / 描述 / 页脚品牌展示
|
||||
@@ -18,8 +19,9 @@ const config = {
|
||||
// 前端自带中间件始终放在候选列表最后一位兜底。
|
||||
// 未配置或为空数组时,直接使用前端自带中间件。
|
||||
Middleware: <string[]>[
|
||||
"https://middleware-1.api-ipw.wsmdn.top/"
|
||||
// "http://127.0.0.1:8092/",
|
||||
"https://middleware-1.api-ipw.wsmdn.top/",
|
||||
"https://boce-api.api-ipw.wsmdn.top/"
|
||||
|
||||
// "https://middleware-2.wsmdn.top/",
|
||||
],
|
||||
// Umami 统计
|
||||
@@ -35,24 +37,31 @@ const config = {
|
||||
v4OnlyAPI: "https://4.wsmdn.top",
|
||||
v6OnlyAPI: "https://6.wsmdn.top",
|
||||
DualStackAPI: "https://test.wsmdn.top",
|
||||
// 网站截图服务(screenshot 页主通道):thum.io 同步出图、CORS 全开,
|
||||
// 响应 content-type 即结果信号(PNG/JPEG=成品,GIF=生成中或目标不可达),
|
||||
// 失败自动回退 WordPress mshots(s0.wp.com,见 screenshot.vue)。
|
||||
// 写进 config 的另一个作用:nuxt.config 的 extractDomains 会把它收进
|
||||
// CSP connect-src 白名单,页面里的 fetch 才能通过安全头。
|
||||
screenshotAPI: "https://image.thum.io",
|
||||
// ---- 节点池结构 ----
|
||||
// IPLocationAPI:IP 归属查询(location / asn)上游节点池(纯数组,无栈区分)
|
||||
IPLocationAPI: [
|
||||
{
|
||||
label: "中国 江苏 移动",
|
||||
id: "cn-jiangsu",
|
||||
url: "https://cn-jiangsu.api-ipw.wsmdn.top/"
|
||||
},
|
||||
{
|
||||
label: "中国 湖北 武汉 电信",
|
||||
id: "cn-wuhan-chinatelecom",
|
||||
url: ""
|
||||
},
|
||||
{
|
||||
label: "中国 四川 沙渠 电信[ZFC]",
|
||||
id: "cn2-sichuan",
|
||||
url: "https://cn2-sichuan.api-ipw.wsmdn.top/"
|
||||
},
|
||||
{
|
||||
label: "中国 江苏 移动",
|
||||
id: "cn-jiangsu",
|
||||
url: "https://cn-jiangsu.api-ipw.wsmdn.top/"
|
||||
}
|
||||
// {
|
||||
// label: "中国 湖北 武汉 电信",
|
||||
// id: "cn-wuhan-chinatelecom",
|
||||
// url: ""
|
||||
// },
|
||||
|
||||
],
|
||||
// APIBaseURL:其余拨测(whois / ssl / detail / dns / dnssec / tcping / speed)上游节点池,含 { IPv6, IPv4, DualStack } 三栈
|
||||
APIBaseURL: {
|
||||
@@ -94,26 +103,32 @@ const config = {
|
||||
id: "us-la",
|
||||
url: "https://america-california-losangeles.ipwapi.zfap.wsmdn.top/"
|
||||
},
|
||||
// IP 直连新节点:URL 留空,仅经独立中间件转发
|
||||
{
|
||||
label: "山东 枣庄 双线",
|
||||
id: "zaozhuang",
|
||||
url: ""
|
||||
// 与 IPLocationAPI 池共享的节点:ASN 页取两池交集,
|
||||
// 只有同时出现在两个池里的节点才会显示(cn-xian 仅双栈池故不显示)
|
||||
label: "中国 四川 沙渠 电信[ZFC]",
|
||||
id: "cn2-sichuan",
|
||||
url: "https://cn2-sichuan.api-ipw.wsmdn.top/"
|
||||
},
|
||||
{
|
||||
label: "中国 江苏 移动",
|
||||
id: "cn-jiangsu",
|
||||
url: "https://cn-jiangsu.api-ipw.wsmdn.top/"
|
||||
},
|
||||
// IP 直连新节点:URL 留空,仅经独立中间件转发
|
||||
{
|
||||
label: "香港 Cogent",
|
||||
id: "hongkong",
|
||||
url: ""
|
||||
},
|
||||
// WS 通道节点:URL 留空,拨测经中间件 WS 转发
|
||||
{
|
||||
label: "呼和浩特移动",
|
||||
id: "2faa15e6-18a7-4355-b422-ca53277d8d77",
|
||||
url: ""
|
||||
}
|
||||
// // WS 通道节点:URL 留空,拨测经中间件 WS 转发
|
||||
// {
|
||||
// label: "呼和浩特移动",
|
||||
// id: "2faa15e6-18a7-4355-b422-ca53277d8d77",
|
||||
// url: ""
|
||||
// }
|
||||
],
|
||||
DualStack: [
|
||||
|
||||
{
|
||||
label: "中国 江苏 移动",
|
||||
id: "cn-jiangsu",
|
||||
@@ -124,11 +139,31 @@ const config = {
|
||||
id: "cn-shenzhen",
|
||||
url: "https://cn-shenzhen.api-ipw.wsmdn.top/"
|
||||
},
|
||||
// {
|
||||
// label: "河南 安阳 联通",
|
||||
// "id": "anyang-cu"
|
||||
// },
|
||||
// 仅经独立中间件转发:URL 留空,内置中间件会直接报 502 "Backend URL not configured"
|
||||
{
|
||||
label: "中国 湖北 武汉 电信",
|
||||
id: "cn-wuhan-chinatelecom",
|
||||
label: "上海市 上海市 奉贤区 移动",
|
||||
id: "70dc5411-0cb6-425d-838f-a9bc81984ed4",
|
||||
url: ""
|
||||
},
|
||||
{
|
||||
label: "江西 南昌 移动",
|
||||
id: "97d8873f-f0bb-4e3a-bf41-0b78878b8f34",
|
||||
url: ""
|
||||
},
|
||||
{
|
||||
label: "中国 广东 梅州 电信",
|
||||
id: "b3e06025-d9bd-458d-b1c4-cbba27f2a537",
|
||||
url: ""
|
||||
}
|
||||
// {
|
||||
// label: "中国 湖北 武汉 电信",
|
||||
// id: "cn-wuhan-chinatelecom",
|
||||
// url: ""
|
||||
// },
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {config} from "./config/index";
|
||||
import { docConfig } from "./config/doc";
|
||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
const extractDomains = (obj: any): string[] => {
|
||||
// 将对象转为 JSON 字符串,用正则匹配所有 https:// 开头的域名部分
|
||||
@@ -10,9 +9,42 @@ const extractDomains = (obj: any): string[] => {
|
||||
};
|
||||
|
||||
const allowedDomains = extractDomains(config);
|
||||
|
||||
// 首屏「IPv4 / IPv6 / 优先级」三行的数据源(见 app/pages/index.vue 的 onMounted):
|
||||
// 三个接口分属三个独立源站,且都要等水合完成后才发起 —— 那时才做 DNS+TCP+TLS 太晚。
|
||||
// 把它们抽出来做 preconnect,让握手在 HTML 解析期就开始。
|
||||
const ipProbeOrigins = [
|
||||
config.DualStackAPI,
|
||||
config.v4OnlyAPI,
|
||||
config.v6OnlyAPI,
|
||||
].map((url) => new URL(url).origin);
|
||||
// 中间件(工具页 /middleware/* 的上游):只在部分页面用到,DNS 预解析即可,不占连接。
|
||||
const middlewareOrigin = config.Middleware?.[0]
|
||||
? new URL(config.Middleware[0]).origin
|
||||
: null;
|
||||
|
||||
export default defineNuxtConfig({
|
||||
compatibilityDate: '2025-07-15',
|
||||
devtools: { enabled: true },
|
||||
experimental: {
|
||||
// 关闭 app manifest 版本检查:水合后 Nuxt 会在 requestIdleCallback 里请求
|
||||
// /_nuxt/builds/meta/<buildId>.json,buildId 对不上(本地「服务旧、磁盘新」、
|
||||
// 或线上发版切换瞬间)就抛 NUXT_E5002 污染 console,还拖累 Best Practices 分。
|
||||
// 本项目没依赖 appManifest 的客户端能力(无客户端 routeRules、无 prerender
|
||||
// 判定),关掉少一个请求,console 永远干净。
|
||||
appManifest: false,
|
||||
// 注:inlineStyles: true 实测是负优化——它只内联 page 组件样式(+12KB HTML),
|
||||
// entry/EP 等共享样式仍是 render-blocking 外链,关键请求一个没省。勿开。
|
||||
defaults: {
|
||||
nuxtLink: {
|
||||
// NuxtLink 默认「链接进入视口就预取目标页 JS」——顶栏 15 个菜单项会让
|
||||
// 首屏把其它工具页的 chunk(含 87KB 的校验库等重依赖)全拉下来,
|
||||
// 白吃带宽还挤占首屏关键请求。改为「悬停/聚焦才预取」:真正要去
|
||||
// 哪个页面时再拉那一页,首屏只加载当前页需要的代码。
|
||||
prefetchOn: { interaction: true, visibility: false },
|
||||
},
|
||||
},
|
||||
},
|
||||
modules: [
|
||||
"nitro-cloudflare-dev",
|
||||
'@element-plus/nuxt',
|
||||
@@ -26,22 +58,49 @@ export default defineNuxtConfig({
|
||||
include: [
|
||||
'is-ip',
|
||||
'shiki',
|
||||
'dayjs',
|
||||
'lodash-unified'
|
||||
]
|
||||
},
|
||||
},
|
||||
hooks: {
|
||||
// 掐掉「当前路由的动态 import 预取」。
|
||||
// Nuxt 的 vue-bundle-renderer 会把 manifest 里带 prefetch 标记的动态 chunk
|
||||
// 渲染成 `<link rel="prefetch" as="script">`,于是首页一边解析 HTML 一边就把
|
||||
// shiki 高亮器那一整块(实测 165 KB,占首页字节 25%)下下来了 —— 而高亮已经在
|
||||
// SSR 期算完写进 HTML,客户端根本不会执行它,纯属白下。
|
||||
// 把 manifest 上的标记抹掉即可:动态 chunk 回到「真正 import 时才加载」。
|
||||
// 静态闭包走的是 preload 分支(modulepreload),不受影响。
|
||||
// —— 2026-10-04 曾试把 preload 也置 false:FCP 确实 2333→1404(少了 22 个请求的
|
||||
// 下载竞争),但 LCP 2387→2933、TBT 86→280(权重 25%/30% 远大于 FCP 的 10%),
|
||||
// 总分 94→89 净亏。原因:这 22 个 modulepreload 是 entry 的静态依赖闭包,全掐掉后
|
||||
// hydration 推迟、长任务落进 LCP/TBT 窗口。故只掐 prefetch,preload 必须留。
|
||||
'build:manifest': (manifest) => {
|
||||
for (const chunk of Object.values(manifest) as unknown as Array<Record<string, unknown>>) {
|
||||
if (chunk.prefetch) chunk.prefetch = false
|
||||
}
|
||||
},
|
||||
},
|
||||
site: {
|
||||
url: config.siteUrl,
|
||||
name: 'Lemon IPW'
|
||||
},
|
||||
// Element Plus 样式走按需引入:@element-plus/nuxt 默认 importStyle: 'css',
|
||||
// 模板里用到的每个组件都会各自带上 `element-plus/es/components/<组件>/style/css`
|
||||
// (其内部再链到 theme-chalk/base.css,`:root` 的 --el-* 变量就在那里定义)。
|
||||
// 所以这里**不要**再引 element-plus/dist/index.css —— 那是整库样式(原始 360KB),
|
||||
// 而首页实测 98% 的规则用不到,却全压在关键路径上。
|
||||
css: [
|
||||
// 1. 引入 Element Plus 基础样式 (如果你还没有引入的话)
|
||||
'element-plus/dist/index.css',
|
||||
|
||||
// 2. 🌟 关键:引入 Element Plus 官方的暗黑模式 CSS 变量文件
|
||||
// 暗黑模式的 CSS 变量覆盖(html.dark 下的 --el-* 值),按需引入不含它,必须显式引
|
||||
'element-plus/theme-chalk/dark/css-vars.css',
|
||||
],
|
||||
app:{
|
||||
head: {
|
||||
// 站点内容为简体中文。不写时 Nuxt 输出的就是裸 <html>,
|
||||
// 屏幕阅读器会按系统语言瞎猜发音,Lighthouse 的 html-has-lang 也会失败。
|
||||
htmlAttrs: {
|
||||
lang: 'zh-CN',
|
||||
},
|
||||
script: [
|
||||
{
|
||||
// 必须 innerHTML,不能 src(否则异步加载)
|
||||
@@ -57,24 +116,44 @@ export default defineNuxtConfig({
|
||||
}
|
||||
],
|
||||
link: [
|
||||
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.svg' }
|
||||
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.svg' },
|
||||
// preconnect 三个 IP 探测源站。crossorigin 不能省:$fetch 走 fetch() 的跨域
|
||||
// (CORS)模式,不带它预热出来的是 no-cors 连接,真正的 fetch 用不上、还得重连。
|
||||
...ipProbeOrigins.map((href) => ({
|
||||
rel: 'preconnect',
|
||||
href,
|
||||
crossorigin: 'anonymous',
|
||||
} as const)),
|
||||
...(middlewareOrigin
|
||||
? [{ rel: 'dns-prefetch', href: middlewareOrigin } as const]
|
||||
: []),
|
||||
]
|
||||
}
|
||||
},
|
||||
runtimeConfig: {
|
||||
indexnowKey: '',
|
||||
// IndexNow 所有权凭证:与 public/<同名>.txt 一致(IndexNow 靠抓取该文件验证),
|
||||
// key 本身是公开凭证不是机密;环境变量 NUXT_INDEXNOW_KEY 可覆盖。
|
||||
// 消费方:server/api/indexnow.*.ts(运行时提交端点)。
|
||||
indexnowKey: 'd49c90fb2fb160cdd2cd4b09532bc380',
|
||||
apiKeys: '',
|
||||
public: {
|
||||
siteUrl: config.siteUrl,
|
||||
docConfig: docConfig,
|
||||
|
||||
// 这里**不要**再放 docConfig:runtimeConfig.public 会被整份序列化进
|
||||
// 每个页面 HTML 的 `window.__NUXT__.config`,而这份文档树(32 条 title+description)
|
||||
// 实测占 4571 字节 —— 也就是每一页的 HTML 都白白多背 4.5KB(首页 HTML 的 10%)。
|
||||
// 它全站只有一个消费方,且是服务端路由(server/api/__sitemap__/urls.ts),
|
||||
// 那里改成直接 import 构建期常量即可;文档页本来就用 `getDocMeta` 直接 import。
|
||||
},
|
||||
},
|
||||
routeRules: {
|
||||
// /doc 文档站改为 SSG:构建时预渲染为静态 HTML,由边缘静态资源直接响应
|
||||
'/doc/**': { prerender: true },
|
||||
// 缓存头一律不在这里设,交由 CDN(EdgeOne)侧控制。
|
||||
// /doc/** 曾经是 SSG(prerender),已撤回改为 SSR,原因见下方 nitro.prerender 处的注释。
|
||||
},
|
||||
nitro: {
|
||||
// 构建期给 public/ 静态资源生成 .gz/.br 预压缩副本,按 Accept-Encoding 直接回;
|
||||
// SSR HTML 的压缩在 server/plugins/compress-html.ts。两者合起来让本地直连的
|
||||
// 传输体积与线上(EdgeOne 会压)一致,Lighthouse 的 Lantern 模拟才不会虚高。
|
||||
compressPublicAssets: true,
|
||||
publicAssets: [
|
||||
{
|
||||
dir: 'public',
|
||||
@@ -86,17 +165,21 @@ export default defineNuxtConfig({
|
||||
target: 'es2022' // 明确告诉 Nitro 使用 es2022 进行打包
|
||||
}
|
||||
},
|
||||
prerender: {
|
||||
// 显式列出所有 doc 路由(来自 config/doc.ts 的 docConfig 键),
|
||||
// 让动态 [...slug] 页面在构建时全部预渲染为静态 HTML
|
||||
routes: ['/doc', ...Object.keys(docConfig).filter((p) => p !== '/doc')],
|
||||
},
|
||||
// 这里曾用 prerender.routes 把整份 docConfig 的文档页在构建期预渲染成静态 HTML。
|
||||
// 已撤回,改回 SSR —— 因为预渲染与「按请求头决定渲染形态」根本冲突:
|
||||
// 构建期没有请求头,窄屏判定恒为宽屏,于是预渲染产物里永远躺着
|
||||
// 「15 条桌面顶栏菜单 + 被 CSS 隐藏的 40 项文档侧栏」;真手机打开时客户端判定为窄屏,
|
||||
// 首帧 vdom 与 HTML 对不上,Vue 水合直接抛
|
||||
// `Cannot read properties of null (reading 'nodeType')`,整页变成 500。
|
||||
// 顺带收益:/doc 现在也走运行时安全头(预渲染页拿不到 CSP,见下方 security.ssg)。
|
||||
// 代价只是源站多跑一层 SSR,前面有 EdgeOne 缓存兜着。
|
||||
},
|
||||
security: {
|
||||
ssg: {
|
||||
// /doc 预渲染页的 CSP 会因 SRI modulepreload 哈希全量拼入而单行超 2000 字符,
|
||||
// 触发 Cloudflare _headers 限制;关闭静态页安全头写入 _headers。
|
||||
// SSR 页面仍由运行时中间件下发完整安全头,不受影响。
|
||||
// 预渲染页的 CSP 会因 SRI modulepreload 哈希全量拼入而单行超 2000 字符,
|
||||
// 触发 Cloudflare _headers 限制,故关掉静态页的安全头写入。
|
||||
// 当前没有预渲染路由(/doc/** 已改回 SSR),这条是留给将来再开 prerender 时的开关:
|
||||
// 一旦重新启用 prerender,那些页就会退回「无 CSP」状态。
|
||||
nitroHeaders: false,
|
||||
},
|
||||
headers: {
|
||||
@@ -116,7 +199,7 @@ export default defineNuxtConfig({
|
||||
],
|
||||
|
||||
'style-src': ["'self'", 'https:', "'unsafe-inline'"],
|
||||
'img-src': ["'self'", 'https://s0.wp.com', 'data:', 'https:'],
|
||||
'img-src': ["'self'", 'https://s0.wp.com', 'data:', 'blob:', 'https:'],
|
||||
'font-src': ["'self'", 'https:', 'data:'],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,14 @@
|
||||
"@shikijs/engine-javascript": "^4.4.1",
|
||||
"@sindresorhus/slugify": "^3.0.0",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"@types/leaflet": "^1.9.22",
|
||||
"@vueuse/core": "^14.4.0",
|
||||
"@vueuse/nuxt": "^14.4.0",
|
||||
"better-sqlite3": "^12.11.1",
|
||||
"element-plus": "^2.14.3",
|
||||
"github-markdown-css": "^5.9.0",
|
||||
"github-slugger": "^2.0.0",
|
||||
"is-ip": "^5.0.1",
|
||||
"leaflet": "1.9.4",
|
||||
"markdown-it": "^14.3.0",
|
||||
"markdown-it-anchor": "^9.2.1",
|
||||
"nuxt": "^4.5.1",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
d49c90fb2fb160cdd2cd4b09532bc380
|
||||
@@ -0,0 +1,154 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1240 640" width="1240" height="640" data-generator="fireworks-tech-graph" data-schema-version="1" data-text-metrics="heuristic-v1" data-style-id="7" data-visual-theme="OpenAI" data-diagram-type="architecture" data-motion-scene="" data-semantic-profile="generic" data-semantic-valid="true" data-quality-profile="standard" data-max-bends-per-edge="12" data-max-total-bends="100" data-max-route-stretch="5.0" data-max-bridged-crossings="8" data-min-node-gap="0.0" data-min-container-gutter="0.0" data-min-label-clearance="2.0" data-min-segment-length="0.0">
|
||||
<defs>
|
||||
<marker id="arrowA" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#10a37f"/>
|
||||
</marker>
|
||||
<marker id="arrowB" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#0f766e"/>
|
||||
</marker>
|
||||
<marker id="arrowC" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#0891b2"/>
|
||||
</marker>
|
||||
<marker id="arrowE" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#f59e0b"/>
|
||||
</marker>
|
||||
<marker id="arrowF" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#64748b"/>
|
||||
</marker>
|
||||
<marker id="arrowG" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#475569"/>
|
||||
</marker>
|
||||
<marker id="arrowH" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#94a3b8"/>
|
||||
</marker>
|
||||
<style>
|
||||
text { font-family: 'Helvetica Neue', Helvetica, Arial, 'PingFang SC', 'Noto Sans CJK SC', 'Microsoft YaHei', 'Microsoft JhengHei', 'SimHei', sans-serif; }
|
||||
.title { font-size: 24px; font-weight: 700; fill: #0f172a; }
|
||||
.subtitle { font-size: 13px; font-weight: 500; fill: #64748b; }
|
||||
.section { font-size: 13px; font-weight: 700; fill: #087f5b; letter-spacing: 1.4px; }
|
||||
.section-sub { font-size: 12px; font-weight: 500; fill: #64748b; }
|
||||
.node-title { font-weight: 700; fill: #0f172a; }
|
||||
.node-sub { font-weight: 500; fill: #475569; }
|
||||
.node-type { font-size: 11px; font-weight: 700; fill: #64748b; letter-spacing: 0.08em; }
|
||||
.arrow-label { font-size: 12px; font-weight: 600; fill: #475569; }
|
||||
.legend { font-size: 12px; font-weight: 500; fill: #475569; }
|
||||
.footnote { font-size: 12px; font-weight: 500; fill: #64748b; }
|
||||
.metric-label { font-size: 8.5px; font-weight: 700; fill: #64748b; text-transform: uppercase; }
|
||||
.metric-value { font-size: 9.5px; font-weight: 700; fill: #0f172a; }
|
||||
</style>
|
||||
</defs>
|
||||
<rect data-graph-role="background" width="1240.0" height="640.0" fill="#ffffff"/>
|
||||
<text x="48.0" y="48" text-anchor="start" class="title">DNSSEC 验证链与本地验签</text>
|
||||
<text x="48.0" y="72" text-anchor="start" class="subtitle">DS 信任链自根向下逐级建立,递归侧以 DNSKEY 验证 RRset 签名</text>
|
||||
<line x1="48" y1="100" x2="1192.0" y2="100" stroke="#e2e8f0" stroke-width="1"/>
|
||||
<g id="trust" data-graph-role="container" data-container-id="trust" data-semantic-role="boundary" data-graph-bounds="40,110,1200,260">
|
||||
<rect data-graph-role="container" x="40.0" y="110.0" width="1160.0" height="150.0" rx="16.0" fill="none" stroke="#e2e8f0" stroke-width="1.4" stroke-dasharray="5 4"/>
|
||||
<text x="58.0" y="134.0" class="section">信任链 · 由根向下逐级签发</text>
|
||||
<rect id="trust-header" data-graph-role="reserved" data-reserved-kind="container-header" x="48" y="116" width="189.9" height="30" fill="none" stroke="none"/>
|
||||
</g>
|
||||
<g id="verify" data-graph-role="container" data-container-id="verify" data-semantic-role="boundary" data-graph-bounds="40,310,1200,560">
|
||||
<rect data-graph-role="container" x="40.0" y="310.0" width="1160.0" height="250.0" rx="16.0" fill="none" stroke="#e2e8f0" stroke-width="1.4" stroke-dasharray="5 4"/>
|
||||
<text x="58.0" y="334.0" class="section">递归解析侧 · 本地验签</text>
|
||||
<rect id="verify-header" data-graph-role="reserved" data-reserved-kind="container-header" x="48" y="316" width="163.9" height="30" fill="none" stroke="none"/>
|
||||
</g>
|
||||
<path id="ds-tld" data-graph-role="edge" data-edge-id="ds-tld" data-source="root" data-target="tld" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="0" data-route-stretch="1.0" data-bridges="" d="M 330,195 L 495,195" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="ds-auth" data-graph-role="edge" data-edge-id="ds-auth" data-source="tld" data-target="auth" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="0" data-route-stretch="1.0" data-bridges="" d="M 745,195 L 905,195" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="pub-key" data-graph-role="edge" data-edge-id="pub-key" data-source="auth" data-target="dnskey" data-edge-kind="flow" data-topic-id="" data-flow="write" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="2" data-route-stretch="1.0" data-bridges="" d="M 1023.5,225 L 1023.5,346 L 205,346 L 205,370" fill="none" stroke="#0f766e" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowB)"/>
|
||||
<path id="sign" data-graph-role="edge" data-edge-id="sign" data-source="auth" data-target="rrset" data-edge-kind="flow" data-topic-id="" data-flow="write" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="6" data-route-stretch="1.872" data-bridges="" d="M 1041.5,225 L 1041.5,245.4 L 1184,245.4 L 1184,454 L 745,454 L 745,349.6 L 620,349.6 L 620,370" fill="none" stroke="#0f766e" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowB)"/>
|
||||
<path id="fetch-key-bridge-mask" data-graph-role="bridge-mask" data-owner="fetch-key" d="M 330,400 L 350.4,400 L 350.4,461 L 884.6,461 L 884.6,391 L 905,391" fill="none" stroke="#ffffff" stroke-width="6.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path id="fetch-key" data-graph-role="edge" data-edge-id="fetch-key" data-source="dnskey" data-target="resolver" data-edge-kind="flow" data-topic-id="" data-flow="read" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="4" data-route-stretch="1.209" data-bridges="884.6,454" d="M 330,400 L 350.4,400 L 350.4,461 L 884.6,461 L 884.6,391 L 905,391" fill="none" stroke="#0891b2" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowC)"/>
|
||||
<path id="fetch-rr-bridge-mask" data-graph-role="bridge-mask" data-owner="fetch-rr" d="M 745,400 L 748.28,400 L 748.28,409 L 879.6,409 A 5 5 0 0 0 889.6,409 L 905,409" fill="none" stroke="#ffffff" stroke-width="6.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path id="fetch-rr" data-graph-role="edge" data-edge-id="fetch-rr" data-source="rrset" data-target="resolver" data-edge-kind="flow" data-topic-id="" data-flow="read" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="2" data-route-stretch="1.0" data-bridges="745,400;884.6,409" d="M 745,400 L 748.28,400 L 748.28,409 L 879.6,409 A 5 5 0 0 0 889.6,409 L 905,409" fill="none" stroke="#0891b2" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowC)"/>
|
||||
<path id="a-check-bridge-mask" data-graph-role="bridge-mask" data-owner="a-check" d="M 1032.5,430 L 1032.5,450.4 L 1044,450.4 L 1044,565 L 590,565 L 590,485 L 445,485 L 445,485" fill="none" stroke="#ffffff" stroke-width="6.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path id="a-check" data-graph-role="edge" data-edge-id="a-check" data-source="resolver" data-target="check" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="5" data-route-stretch="1.285" data-bridges="1044,454" d="M 1032.5,430 L 1032.5,450.4 L 1044,450.4 L 1044,565 L 590,565 L 590,485 L 445,485 L 445,485" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="a-pass-bridge-mask" data-graph-role="bridge-mask" data-owner="a-pass" d="M 590,513 L 730,513" fill="none" stroke="#ffffff" stroke-width="6.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path id="a-pass" data-graph-role="edge" data-edge-id="a-pass" data-source="check" data-target="pass" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="0" data-route-stretch="1.0" data-bridges="590,513" d="M 590,513 L 730,513" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<g id="node-root" data-graph-role="node" data-node-id="root" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="80,165,330,225">
|
||||
<rect x="80.0" y="165.0" width="250.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="205.0" y="183.0" text-anchor="middle" class="node-type">ROOT · 信任锚</text>
|
||||
<text data-text-role="title" data-full-text="根 DNS(内置信任锚)" data-text-max-width="226.0" x="205.0" y="201.0" text-anchor="middle" class="node-title" font-size="18">根 DNS(内置信任锚)</text>
|
||||
</g>
|
||||
<g id="node-tld" data-graph-role="node" data-node-id="tld" data-semantic-role="double_rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="495,165,745,225">
|
||||
<rect x="495.0" y="165.0" width="250.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#10a37f" stroke-width="2.0"/>
|
||||
<rect x="501.0" y="171.0" width="238.0" height="48.0" rx="11.0" fill="none" stroke="#10a37f" stroke-width="1.2" opacity="0.65"/>
|
||||
<text x="620.0" y="183.0" text-anchor="middle" class="node-type">TLD · .top</text>
|
||||
<text data-text-role="title" data-full-text="顶级 DNS(发布 DS)" data-text-max-width="218.0" x="620.0" y="201.0" text-anchor="middle" class="node-title" font-size="18">顶级 DNS(发布 DS)</text>
|
||||
</g>
|
||||
<g id="node-auth" data-graph-role="node" data-node-id="auth" data-semantic-role="double_rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="905,165,1160,225">
|
||||
<rect x="905.0" y="165.0" width="255.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#10a37f" stroke-width="2.0"/>
|
||||
<rect x="911.0" y="171.0" width="243.0" height="48.0" rx="11.0" fill="none" stroke="#10a37f" stroke-width="1.2" opacity="0.65"/>
|
||||
<text x="1032.5" y="183.0" text-anchor="middle" class="node-type">AUTHORITATIVE</text>
|
||||
<text data-text-role="title" data-full-text="权威 DNS(发布 DNSKEY)" data-text-max-width="223.0" x="1032.5" y="201.0" text-anchor="middle" class="node-title" font-size="17.29">权威 DNS(发布 DNSKEY)</text>
|
||||
</g>
|
||||
<g id="node-dnskey" data-graph-role="node" data-node-id="dnskey" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="80,370,330,430">
|
||||
<rect x="80.0" y="370.0" width="250.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="205.0" y="388.0" text-anchor="middle" class="node-type">DNSKEY</text>
|
||||
<text data-text-role="title" data-full-text="KSK / ZSK 密钥" data-text-max-width="226.0" x="205.0" y="406.0" text-anchor="middle" class="node-title" font-size="18">KSK / ZSK 密钥</text>
|
||||
</g>
|
||||
<g id="node-rrset" data-graph-role="node" data-node-id="rrset" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="495,370,745,430">
|
||||
<rect x="495.0" y="370.0" width="250.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="620.0" y="388.0" text-anchor="middle" class="node-type">RRSET + RRSIG</text>
|
||||
<text data-text-role="title" data-full-text="记录数据与签名" data-text-max-width="226.0" x="620.0" y="406.0" text-anchor="middle" class="node-title" font-size="18">记录数据与签名</text>
|
||||
</g>
|
||||
<g id="node-resolver" data-graph-role="node" data-node-id="resolver" data-semantic-role="double_rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="905,370,1160,430">
|
||||
<rect x="905.0" y="370.0" width="255.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#1d4ed8" stroke-width="2.0"/>
|
||||
<rect x="911.0" y="376.0" width="243.0" height="48.0" rx="11.0" fill="none" stroke="#1d4ed8" stroke-width="1.2" opacity="0.65"/>
|
||||
<text x="1032.5" y="388.0" text-anchor="middle" class="node-type">RECURSIVE · DO=1</text>
|
||||
<text data-text-role="title" data-full-text="递归解析器(带 DO 查询)" data-text-max-width="223.0" x="1032.5" y="406.0" text-anchor="middle" class="node-title" font-size="17.38">递归解析器(带 DO 查询)</text>
|
||||
</g>
|
||||
<g id="node-check" data-graph-role="node" data-node-id="check" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="300,485,590,541">
|
||||
<rect x="300.0" y="485.0" width="290.0" height="56.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="445.0" y="503.0" text-anchor="middle" class="node-type">VERIFY</text>
|
||||
<text data-text-role="title" data-full-text="RRSIG.Verify 本地验签" data-text-max-width="266.0" x="445.0" y="519.0" text-anchor="middle" class="node-title" font-size="18">RRSIG.Verify 本地验签</text>
|
||||
</g>
|
||||
<g id="node-pass" data-graph-role="node" data-node-id="pass" data-semantic-role="double_rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="730,485,1020,541">
|
||||
<rect x="730.0" y="485.0" width="290.0" height="56.0" rx="14.0" fill="#ffffff" stroke="#10a37f" stroke-width="2.0"/>
|
||||
<rect x="736.0" y="491.0" width="278.0" height="44.0" rx="11.0" fill="none" stroke="#10a37f" stroke-width="1.2" opacity="0.65"/>
|
||||
<text x="875.0" y="503.0" text-anchor="middle" class="node-type">RESULT</text>
|
||||
<text data-text-role="title" data-full-text="验证通过 · 数据完整可信" data-text-max-width="258.0" x="875.0" y="519.0" text-anchor="middle" class="node-title" font-size="18">验证通过 · 数据完整可信</text>
|
||||
</g>
|
||||
<g id="ds-tld-label" data-graph-role="label" data-owner="ds-tld" data-graph-bounds="384.38,164,440.62,184">
|
||||
<rect x="384.38" y="164.0" width="56.24" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="412.5" y="178.0" text-anchor="middle" class="arrow-label">DS 签发</text>
|
||||
</g>
|
||||
<g id="ds-auth-label" data-graph-role="label" data-owner="ds-auth" data-graph-bounds="772.28,164,877.72,184">
|
||||
<rect x="772.28" y="164.0" width="105.44" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="825.0" y="178.0" text-anchor="middle" class="arrow-label">DS 指向下级 KEY</text>
|
||||
</g>
|
||||
<g id="pub-key-label" data-graph-role="label" data-owner="pub-key" data-graph-bounds="583.25,315,645.25,335">
|
||||
<rect x="583.25" y="315.0" width="62.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="614.25" y="329.0" text-anchor="middle" class="arrow-label">发布密钥</text>
|
||||
</g>
|
||||
<g id="sign-label" data-graph-role="label" data-owner="sign" data-graph-bounds="933.5,441,995.5,461">
|
||||
<rect x="933.5" y="441.0" width="62.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="964.5" y="455.0" text-anchor="middle" class="arrow-label">私钥签名</text>
|
||||
</g>
|
||||
<g id="fetch-key-label" data-graph-role="label" data-owner="fetch-key" data-graph-bounds="575.46,434,659.54,454">
|
||||
<rect x="575.46" y="434.0" width="84.08" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="617.5" y="448.0" text-anchor="middle" class="arrow-label">取回 DNSKEY</text>
|
||||
</g>
|
||||
<g id="fetch-rr-label" data-graph-role="label" data-owner="fetch-rr" data-graph-bounds="789.64,378,863.64,398">
|
||||
<rect x="789.64" y="378.0" width="74.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="826.64" y="392.0" text-anchor="middle" class="arrow-label">带签名应答</text>
|
||||
</g>
|
||||
<g id="a-check-label" data-graph-role="label" data-owner="a-check" data-graph-bounds="772.92,552,861.08,572">
|
||||
<rect x="772.92" y="552.0" width="88.16" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="817.0" y="566.0" text-anchor="middle" class="arrow-label">RRSIG.Verify</text>
|
||||
</g>
|
||||
<g id="a-pass-label" data-graph-role="label" data-owner="a-pass" data-graph-bounds="629,482,691,502">
|
||||
<rect x="629.0" y="482.0" width="62.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="660.0" y="496.0" text-anchor="middle" class="arrow-label">验签通过</text>
|
||||
</g>
|
||||
<g id="legend" data-graph-role="legend">
|
||||
<rect id="legend-zone" data-graph-role="reserved" data-reserved-kind="legend" x="32" y="516" width="183.6" height="90" rx="10" fill="none" stroke="none"/>
|
||||
<line data-graph-role="decoration" x1="42.0" y1="530.0" x2="72.0" y2="530.0" stroke="#10a37f" stroke-width="2.0" marker-end="url(#arrowA)"/>
|
||||
<text data-graph-role="decoration" x="82.0" y="534.0" class="legend">信任链 / 主验证路径</text>
|
||||
<line data-graph-role="decoration" x1="42.0" y1="552.0" x2="72.0" y2="552.0" stroke="#0891b2" stroke-width="2.0" marker-end="url(#arrowC)"/>
|
||||
<text data-graph-role="decoration" x="82.0" y="556.0" class="legend">数据获取</text>
|
||||
<line data-graph-role="decoration" x1="42.0" y1="574.0" x2="72.0" y2="574.0" stroke="#0f766e" stroke-width="2.0" marker-end="url(#arrowB)"/>
|
||||
<text data-graph-role="decoration" x="82.0" y="578.0" class="legend">权威侧写操作</text>
|
||||
</g>
|
||||
<g id="footer" data-graph-role="reserved" data-graph-bounds="48,613,391,629">
|
||||
<text x="48.0" y="625.0" class="footnote">Style 7 · OpenAI Official · DNSSEC chain of trust</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 718 KiB |
|
After Width: | Height: | Size: 652 KiB |
|
After Width: | Height: | Size: 675 KiB |
|
After Width: | Height: | Size: 635 KiB |
|
After Width: | Height: | Size: 642 KiB |
|
After Width: | Height: | Size: 636 KiB |
|
After Width: | Height: | Size: 622 KiB |
|
After Width: | Height: | Size: 49 KiB |
@@ -1,225 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 960 880" width="960" height="880" data-generator="fireworks-tech-graph" data-schema-version="1" data-text-metrics="heuristic-v1" data-style-id="10" data-visual-theme="Cloud Fabric" data-diagram-type="deployment" data-motion-scene="" data-semantic-profile="generic" data-semantic-valid="true" data-quality-profile="standard" data-max-bends-per-edge="12" data-max-total-bends="100" data-max-route-stretch="5.0" data-max-bridged-crossings="8" data-min-node-gap="0.0" data-min-container-gutter="0.0" data-min-label-clearance="2.0" data-min-segment-length="0.0">
|
||||
<defs>
|
||||
<marker id="arrowA" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#2563eb"/>
|
||||
</marker>
|
||||
<marker id="arrowB" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#ea580c"/>
|
||||
</marker>
|
||||
<marker id="arrowC" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#0891b2"/>
|
||||
</marker>
|
||||
<marker id="arrowE" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#059669"/>
|
||||
</marker>
|
||||
<marker id="arrowF" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#7c3aed"/>
|
||||
</marker>
|
||||
<marker id="arrowG" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#db2777"/>
|
||||
</marker>
|
||||
<marker id="arrowH" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#64748b"/>
|
||||
</marker>
|
||||
<filter id="shadowSoft" x="-20%" y="-20%" width="140%" height="160%">
|
||||
<feDropShadow dx="0" dy="3" stdDeviation="6" flood-color="#0f172a" flood-opacity="0.12"/>
|
||||
</filter>
|
||||
<filter id="shadowGlass" x="-20%" y="-20%" width="140%" height="160%">
|
||||
<feDropShadow dx="0" dy="10" stdDeviation="16" flood-color="#020617" flood-opacity="0.28"/>
|
||||
</filter>
|
||||
<linearGradient id="cloudGradient" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#f8fcff"/>
|
||||
<stop offset="100%" stop-color="#dfedf7"/>
|
||||
</linearGradient>
|
||||
<pattern id="cloudGrid" width="32" height="32" patternUnits="userSpaceOnUse">
|
||||
<path d="M 32 0 L 0 0 0 32" fill="none" stroke="#7fa3c2" stroke-opacity="0.10" stroke-width="1"/>
|
||||
</pattern>
|
||||
<style>
|
||||
text { font-family: Inter, 'Helvetica Neue', 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'SimHei', 'Noto Sans CJK SC', sans-serif; }
|
||||
.title { font-size: 27px; font-weight: 700; fill: #102a43; }
|
||||
.subtitle { font-size: 13px; font-weight: 500; fill: #52718d; }
|
||||
.section { font-size: 13px; font-weight: 700; fill: #315d7e; letter-spacing: 1.4px; }
|
||||
.section-sub { font-size: 12px; font-weight: 500; fill: #7892a8; }
|
||||
.node-title { font-weight: 700; fill: #102a43; }
|
||||
.node-sub { font-size: 12px; font-weight: 500; fill: #486581; }
|
||||
.node-type { font-size: 10px; font-weight: 700; fill: #6b879d; letter-spacing: 0.08em; }
|
||||
.arrow-label { font-size: 12px; font-weight: 600; fill: #334e68; }
|
||||
.legend { font-size: 12px; font-weight: 500; fill: #486581; }
|
||||
.footnote { font-size: 12px; font-weight: 500; fill: #829ab1; }
|
||||
.metric-label { font-size: 8.5px; font-weight: 700; fill: #829ab1; text-transform: uppercase; }
|
||||
.metric-value { font-size: 9.5px; font-weight: 700; fill: #102a43; }
|
||||
</style>
|
||||
</defs>
|
||||
<rect data-graph-role="background" width="960.0" height="880.0" fill="url(#cloudGradient)"/>
|
||||
<rect data-graph-role="decoration" width="960.0" height="880.0" fill="url(#cloudGrid)"/>
|
||||
<text x="28" y="24" font-size="11.0" font-weight="600" fill="#829ab1">WHOIS · REGISTRY · REGISTRAR</text>
|
||||
<text x="932.0" y="24" text-anchor="end" font-size="11.0" font-weight="600" fill="#829ab1">Cloud Fabric · Style 10</text>
|
||||
<text x="48.0" y="48" text-anchor="start" class="title">域名生命周期</text>
|
||||
<text x="48.0" y="72" text-anchor="start" class="subtitle">Domain Name Lifecycle · Cloud Fabric</text>
|
||||
<g id="style-signature" data-graph-role="decoration" data-style-signature="cloud-ownership-map">
|
||||
<rect x="736.0" y="22.0" width="176.0" height="34.0" rx="9" fill="#ffffff" fill-opacity="0.82" stroke="#7fa3c2" stroke-width="1.1"/>
|
||||
<rect x="747.0" y="31.0" width="14" height="14" rx="4" fill="#dbeafe" stroke="#2563eb" stroke-width="1"/>
|
||||
<rect x="756.0" y="35.0" width="14" height="14" rx="4" fill="#dcfce7" stroke="#059669" stroke-width="1"/>
|
||||
<text data-full-text="CLOUD · 1 REGIONS" x="779.0" y="36.0" font-size="8.5" font-weight="800" fill="#315d7e">CLOUD · 1 REGIONS</text>
|
||||
<text data-full-text="DEPLOYMENT MAP" x="779.0" y="49.0" font-size="8" font-weight="700" fill="#52718d">DEPLOYMENT MAP</text>
|
||||
</g>
|
||||
<g id="global" data-graph-role="container" data-container-id="global" data-semantic-role="global" data-graph-bounds="30,120,930,210">
|
||||
<rect data-graph-role="container" x="30.0" y="120.0" width="900.0" height="90.0" rx="16.0" fill="rgba(255,255,255,0.54)" stroke="#7fa3c2" stroke-width="1.4" stroke-dasharray="7 5"/>
|
||||
<rect data-graph-role="decoration" x="862.0" y="130.0" width="54.0" height="18" rx="9" fill="#dbeafe" stroke="#93c5fd" stroke-width="0.8"/>
|
||||
<text data-graph-role="decoration" x="889.0" y="142.5" text-anchor="middle" font-size="9" font-weight="700" fill="#315d7e">GLOBAL</text>
|
||||
<line data-graph-role="decoration" x1="38.0" y1="162.0" x2="38.0" y2="196.0" stroke="#2563eb" stroke-width="2.2" stroke-linecap="round" opacity="0.72"/>
|
||||
<text x="48.0" y="144.0" class="section">GLOBAL</text>
|
||||
<rect id="global-header" data-graph-role="reserved" data-reserved-kind="container-header" x="38" y="126" width="75.24" height="30" fill="none" stroke="none"/>
|
||||
</g>
|
||||
<g id="lifecycle" data-graph-role="container" data-container-id="lifecycle" data-semantic-role="region" data-graph-bounds="30,230,930,930">
|
||||
<rect data-graph-role="container" x="30.0" y="230.0" width="900.0" height="700.0" rx="16.0" fill="rgba(255,255,255,0.54)" stroke="#7fa3c2" stroke-width="1.4" stroke-dasharray="7 5"/>
|
||||
<rect data-graph-role="decoration" x="862.0" y="240.0" width="54.0" height="18" rx="9" fill="#dbeafe" stroke="#93c5fd" stroke-width="0.8"/>
|
||||
<text data-graph-role="decoration" x="889.0" y="252.5" text-anchor="middle" font-size="9" font-weight="700" fill="#315d7e">REGION</text>
|
||||
<line data-graph-role="decoration" x1="38.0" y1="272.0" x2="38.0" y2="916.0" stroke="#0891b2" stroke-width="2.2" stroke-linecap="round" opacity="0.72"/>
|
||||
<text x="48.0" y="254.0" class="section">LIFECYCLE</text>
|
||||
<rect id="lifecycle-header" data-graph-role="reserved" data-reserved-kind="container-header" x="38" y="236" width="94.48" height="30" fill="none" stroke="none"/>
|
||||
</g>
|
||||
<path id="pending-to-available" data-graph-role="edge" data-edge-id="pending-to-available" data-source="pending-delete" data-target="available" data-edge-kind="flow" data-topic-id="" data-flow="async" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="6" data-route-stretch="1.968" data-bridges="" d="M 380,770 L 380,742 L 160,742 L 160,210 L 160,130 L 170,130 L 170,220.4 L 451,220.4 L 451,200" fill="none" stroke="#7c3aed" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowF)"/>
|
||||
<path id="register" data-graph-role="edge" data-edge-id="register" data-source="available" data-target="add-period" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="2" data-route-stretch="1.0" data-bridges="" d="M 469,200 L 469,225 L 380,225 L 380,250" fill="none" stroke="#2563eb" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="configure-ns" data-graph-role="edge" data-edge-id="configure-ns" data-source="add-period" data-target="active" data-edge-kind="flow" data-topic-id="" data-flow="write" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="0" data-route-stretch="1.0" data-bridges="" d="M 380,322 L 380,350" fill="none" stroke="#ea580c" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowB)"/>
|
||||
<path id="renew" data-graph-role="edge" data-edge-id="renew" data-source="active" data-target="renew-period" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="0" data-route-stretch="1.0" data-bridges="" d="M 389,430 L 389,470" fill="none" stroke="#2563eb" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="manual-renew" data-graph-role="edge" data-edge-id="manual-renew" data-source="renew-period" data-target="active" data-edge-kind="flow" data-topic-id="" data-flow="write" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="4" data-route-stretch="1.75" data-bridges="" d="M 371,470 L 371,459.8 L 386,459.8 L 386,434.08 L 371,434.08 L 371,430" fill="none" stroke="#ea580c" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowB)"/>
|
||||
<path id="auto-renew" data-graph-role="edge" data-edge-id="auto-renew" data-source="active" data-target="auto-renew-period" data-edge-kind="flow" data-topic-id="" data-flow="async" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="4" data-route-stretch="1.924" data-bridges="" d="M 353,430 L 353,434.08 L 280,434.08 L 280,549.6 L 371,549.6 L 371,570" fill="none" stroke="#7c3aed" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowF)"/>
|
||||
<path id="renew-success" data-graph-role="edge" data-edge-id="renew-success" data-source="auto-renew-period" data-target="active" data-edge-kind="flow" data-topic-id="" data-flow="write" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="4" data-route-stretch="1.924" data-bridges="" d="M 389,570 L 389,549.6 L 480,549.6 L 480,450.4 L 407,450.4 L 407,430" fill="none" stroke="#ea580c" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowB)"/>
|
||||
<path id="to-redemption" data-graph-role="edge" data-edge-id="to-redemption" data-source="auto-renew-period" data-target="redemption-period" data-edge-kind="flow" data-topic-id="" data-flow="data" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="4" data-route-stretch="1.272" data-bridges="" d="M 480,606 L 500.4,606 L 500.4,642 L 259.6,642 L 259.6,706 L 280,706" fill="none" stroke="#059669" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowE)"/>
|
||||
<path id="to-transfer" data-graph-role="edge" data-edge-id="to-transfer" data-source="active" data-target="transfer" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="2" data-route-stretch="1.0" data-bridges="" d="M 480,381 L 504,381 L 504,326 L 680,326" fill="none" stroke="#2563eb" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="transfer-complete" data-graph-role="edge" data-edge-id="transfer-complete" data-source="transfer" data-target="transfer-period" data-edge-kind="flow" data-topic-id="" data-flow="write" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="0" data-route-stretch="1.0" data-bridges="" d="M 780,362 L 780,390" fill="none" stroke="#ea580c" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowB)"/>
|
||||
<path id="transfer-ok" data-graph-role="edge" data-edge-id="transfer-ok" data-source="transfer-period" data-target="active" data-edge-kind="flow" data-topic-id="" data-flow="write" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="1" data-route-stretch="1.0" data-bridges="" d="M 680,426 L 480,426 L 480,399 L 480,399" fill="none" stroke="#ea580c" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowB)"/>
|
||||
<g id="node-available" data-graph-role="node" data-node-id="available" data-semantic-role="cloud_service" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="global" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="360,130,560,200">
|
||||
<rect x="360.0" y="130.0" width="200.0" height="70.0" rx="12" fill="#ffffff" stroke="#9bb7cf" stroke-width="1.4" filter="url(#shadowSoft)"/>
|
||||
<rect x="372.0" y="144.0" width="42.0" height="42.0" rx="11" fill="#2563eb" opacity="0.12" stroke="#2563eb" stroke-width="1.2"/>
|
||||
<circle cx="393.0" cy="165.0" r="11" fill="none" stroke="#2563eb" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M 382.0 165.0 H 404.0 M 393.0 154.0 C 387.0 160.0 387.0 170.0 393.0 176.0 M 393.0 154.0 C 399.0 160.0 399.0 170.0 393.0 176.0" fill="none" stroke="#2563eb" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<text data-text-role="title" data-full-text="Available" x="426.0" y="161.0" text-anchor="start" class="node-title" font-size="13.5">Available</text>
|
||||
<text data-text-role="subtitle" data-full-text="域名可注册" x="426.0" y="180.0" text-anchor="start" class="node-sub" font-size="11.5">域名可注册</text>
|
||||
<text x="550.0" y="144.0" text-anchor="end" font-size="8.5" font-weight="800" fill="#6b879d">DNS</text>
|
||||
</g>
|
||||
<g id="node-add-period" data-graph-role="node" data-node-id="add-period" data-semantic-role="cloud_service" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="lifecycle" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="280,250,480,322">
|
||||
<rect x="280.0" y="250.0" width="200.0" height="72.0" rx="12" fill="#ffffff" stroke="#9bb7cf" stroke-width="1.4" filter="url(#shadowSoft)"/>
|
||||
<rect x="292.0" y="265.0" width="42.0" height="42.0" rx="11" fill="#0891b2" opacity="0.12" stroke="#0891b2" stroke-width="1.2"/>
|
||||
<path d="M 313.0 274.0 L 325.0 286.0 L 313.0 298.0 L 301.0 286.0 Z" fill="none" stroke="#0891b2" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M 307.0 286.0 H 319.0 M 316.0 283.0 L 319.0 286.0 L 316.0 289.0" fill="none" stroke="#0891b2" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<text data-text-role="title" data-full-text="AddPeriod" x="346.0" y="281.0" text-anchor="start" class="node-title" font-size="13.5">AddPeriod</text>
|
||||
<text data-text-role="subtitle" data-full-text="注册完成 · 5天" x="346.0" y="300.0" text-anchor="start" class="node-sub" font-size="11.5">注册完成 · 5天</text>
|
||||
<text x="470.0" y="264.0" text-anchor="end" font-size="8.5" font-weight="800" fill="#6b879d">REGISTRAR</text>
|
||||
</g>
|
||||
<g id="node-active" data-graph-role="node" data-node-id="active" data-semantic-role="cloud_service" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="lifecycle" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="280,350,480,430">
|
||||
<rect x="280.0" y="350.0" width="200.0" height="80.0" rx="12" fill="#ffffff" stroke="#9bb7cf" stroke-width="1.4" filter="url(#shadowSoft)"/>
|
||||
<rect x="292.0" y="369.0" width="42.0" height="42.0" rx="11" fill="#059669" opacity="0.12" stroke="#059669" stroke-width="1.2"/>
|
||||
<rect x="302.0" y="381.0" width="22" height="18" rx="4" fill="none" stroke="#059669" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M 307.0 387.0 H 319.0 M 307.0 393.0 H 316.0" fill="none" stroke="#059669" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<text data-text-role="title" data-full-text="Active (ok)" x="346.0" y="381.0" text-anchor="start" class="node-title" font-size="13.5">Active (ok)</text>
|
||||
<text data-text-role="subtitle" data-full-text="正常解析 · 配置NS" x="346.0" y="400.0" text-anchor="start" class="node-sub" font-size="11.5">正常解析 · 配置NS</text>
|
||||
<text x="470.0" y="364.0" text-anchor="end" font-size="8.5" font-weight="800" fill="#6b879d">REGISTRY</text>
|
||||
</g>
|
||||
<g id="node-renew-period" data-graph-role="node" data-node-id="renew-period" data-semantic-role="cloud_service" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="lifecycle" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="280,470,480,542">
|
||||
<rect x="280.0" y="470.0" width="200.0" height="72.0" rx="12" fill="#ffffff" stroke="#9bb7cf" stroke-width="1.4" filter="url(#shadowSoft)"/>
|
||||
<rect x="292.0" y="485.0" width="42.0" height="42.0" rx="11" fill="#7c3aed" opacity="0.12" stroke="#7c3aed" stroke-width="1.2"/>
|
||||
<path d="M 301.0 499.0 H 318.0 M 308.0 506.0 H 325.0 M 301.0 513.0 H 318.0" fill="none" stroke="#7c3aed" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<circle cx="321.0" cy="499.0" r="2.4" fill="#7c3aed"/><circle cx="305.0" cy="506.0" r="2.4" fill="#7c3aed"/><circle cx="321.0" cy="513.0" r="2.4" fill="#7c3aed"/>
|
||||
<text data-text-role="title" data-full-text="RenewPeriod" x="346.0" y="501.0" text-anchor="start" class="node-title" font-size="13.5">RenewPeriod</text>
|
||||
<text data-text-role="subtitle" data-full-text="手动续费 · 5天" x="346.0" y="520.0" text-anchor="start" class="node-sub" font-size="11.5">手动续费 · 5天</text>
|
||||
<text x="470.0" y="484.0" text-anchor="end" font-size="8.5" font-weight="800" fill="#6b879d">REGISTRAR</text>
|
||||
</g>
|
||||
<g id="node-auto-renew-period" data-graph-role="node" data-node-id="auto-renew-period" data-semantic-role="cloud_service" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="lifecycle" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="280,570,480,642">
|
||||
<rect x="280.0" y="570.0" width="200.0" height="72.0" rx="12" fill="#ffffff" stroke="#9bb7cf" stroke-width="1.4" filter="url(#shadowSoft)"/>
|
||||
<rect x="292.0" y="585.0" width="42.0" height="42.0" rx="11" fill="#ea580c" opacity="0.12" stroke="#ea580c" stroke-width="1.2"/>
|
||||
<path d="M 301.0 599.0 H 318.0 M 308.0 606.0 H 325.0 M 301.0 613.0 H 318.0" fill="none" stroke="#ea580c" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<circle cx="321.0" cy="599.0" r="2.4" fill="#ea580c"/><circle cx="305.0" cy="606.0" r="2.4" fill="#ea580c"/><circle cx="321.0" cy="613.0" r="2.4" fill="#ea580c"/>
|
||||
<text data-text-role="title" data-full-text="AutoRenewPeriod" x="346.0" y="601.0" text-anchor="start" class="node-title" font-size="13.38">AutoRenewPeriod</text>
|
||||
<text data-text-role="subtitle" data-full-text="自动续费 · 等待扣费" x="346.0" y="620.0" text-anchor="start" class="node-sub" font-size="11.5">自动续费 · 等待扣费</text>
|
||||
<text x="470.0" y="584.0" text-anchor="end" font-size="8.5" font-weight="800" fill="#6b879d">REGISTRY</text>
|
||||
</g>
|
||||
<g id="node-redemption-period" data-graph-role="node" data-node-id="redemption-period" data-semantic-role="cloud_service" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="lifecycle" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="280,670,480,742">
|
||||
<rect x="280.0" y="670.0" width="200.0" height="72.0" rx="12" fill="#ffffff" stroke="#9bb7cf" stroke-width="1.4" filter="url(#shadowSoft)"/>
|
||||
<rect x="292.0" y="685.0" width="42.0" height="42.0" rx="11" fill="#dc2626" opacity="0.12" stroke="#dc2626" stroke-width="1.2"/>
|
||||
<ellipse cx="313.0" cy="698.0" rx="11" ry="4" fill="none" stroke="#dc2626" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M 302.0 698.0 V 714.0 C 302.0 719.0 324.0 719.0 324.0 714.0 V 698.0" fill="none" stroke="#dc2626" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M 302.0 706.0 C 302.0 711.0 324.0 711.0 324.0 706.0" fill="none" stroke="#dc2626" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<text data-text-role="title" data-full-text="RedemptionPeriod" x="346.0" y="701.0" text-anchor="start" class="node-title" font-size="12.89">RedemptionPeriod</text>
|
||||
<text data-text-role="subtitle" data-full-text="赎回期 · 30天" x="346.0" y="720.0" text-anchor="start" class="node-sub" font-size="11.5">赎回期 · 30天</text>
|
||||
<text x="470.0" y="684.0" text-anchor="end" font-size="8.5" font-weight="800" fill="#6b879d">REGISTRY</text>
|
||||
</g>
|
||||
<g id="node-pending-delete" data-graph-role="node" data-node-id="pending-delete" data-semantic-role="cloud_service" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="lifecycle" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="280,770,480,842">
|
||||
<rect x="280.0" y="770.0" width="200.0" height="72.0" rx="12" fill="#ffffff" stroke="#9bb7cf" stroke-width="1.4" filter="url(#shadowSoft)"/>
|
||||
<rect x="292.0" y="785.0" width="42.0" height="42.0" rx="11" fill="#64748b" opacity="0.12" stroke="#64748b" stroke-width="1.2"/>
|
||||
<path d="M 300.0 806.0 Q 313.0 794.0 326.0 806.0 Q 313.0 818.0 300.0 806.0 Z" fill="none" stroke="#64748b" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M 307.0 806.0 H 311.0 L 314.0 801.0 L 317.0 811.0 L 320.0 806.0" fill="none" stroke="#64748b" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<text data-text-role="title" data-full-text="PendingDelete" x="346.0" y="801.0" text-anchor="start" class="node-title" font-size="13.5">PendingDelete</text>
|
||||
<text data-text-role="subtitle" data-full-text="删除倒计时 · 5天" x="346.0" y="820.0" text-anchor="start" class="node-sub" font-size="11.5">删除倒计时 · 5天</text>
|
||||
<text x="470.0" y="784.0" text-anchor="end" font-size="8.5" font-weight="800" fill="#6b879d">REGISTRY</text>
|
||||
</g>
|
||||
<g id="node-transfer" data-graph-role="node" data-node-id="transfer" data-semantic-role="cloud_service" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="lifecycle" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="680,290,880,362">
|
||||
<rect x="680.0" y="290.0" width="200.0" height="72.0" rx="12" fill="#ffffff" stroke="#9bb7cf" stroke-width="1.4" filter="url(#shadowSoft)"/>
|
||||
<rect x="692.0" y="305.0" width="42.0" height="42.0" rx="11" fill="#2563eb" opacity="0.12" stroke="#2563eb" stroke-width="1.2"/>
|
||||
<path d="M 713.0 314.0 L 725.0 326.0 L 713.0 338.0 L 701.0 326.0 Z" fill="none" stroke="#2563eb" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M 707.0 326.0 H 719.0 M 716.0 323.0 L 719.0 326.0 L 716.0 329.0" fill="none" stroke="#2563eb" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<text data-text-role="title" data-full-text="PendingTransfer" x="746.0" y="321.0" text-anchor="start" class="node-title" font-size="13.38">PendingTransfer</text>
|
||||
<text data-text-role="subtitle" data-full-text="转移中 · 注册商切换" x="746.0" y="340.0" text-anchor="start" class="node-sub" font-size="11.5">转移中 · 注册商切换</text>
|
||||
<text x="870.0" y="304.0" text-anchor="end" font-size="8.5" font-weight="800" fill="#6b879d">REGISTRAR</text>
|
||||
</g>
|
||||
<g id="node-transfer-period" data-graph-role="node" data-node-id="transfer-period" data-semantic-role="cloud_service" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="lifecycle" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="680,390,880,462">
|
||||
<rect x="680.0" y="390.0" width="200.0" height="72.0" rx="12" fill="#ffffff" stroke="#9bb7cf" stroke-width="1.4" filter="url(#shadowSoft)"/>
|
||||
<rect x="692.0" y="405.0" width="42.0" height="42.0" rx="11" fill="#0891b2" opacity="0.12" stroke="#0891b2" stroke-width="1.2"/>
|
||||
<path d="M 701.0 419.0 H 718.0 M 708.0 426.0 H 725.0 M 701.0 433.0 H 718.0" fill="none" stroke="#0891b2" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<circle cx="721.0" cy="419.0" r="2.4" fill="#0891b2"/><circle cx="705.0" cy="426.0" r="2.4" fill="#0891b2"/><circle cx="721.0" cy="433.0" r="2.4" fill="#0891b2"/>
|
||||
<text data-text-role="title" data-full-text="TransferPeriod" x="746.0" y="421.0" text-anchor="start" class="node-title" font-size="13.5">TransferPeriod</text>
|
||||
<text data-text-role="subtitle" data-full-text="转移完成 · 5天" x="746.0" y="440.0" text-anchor="start" class="node-sub" font-size="11.5">转移完成 · 5天</text>
|
||||
<text x="870.0" y="404.0" text-anchor="end" font-size="8.5" font-weight="800" fill="#6b879d">REGISTRAR</text>
|
||||
</g>
|
||||
<g id="node-client-hold" data-graph-role="node" data-node-id="client-hold" data-semantic-role="cloud_service" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="lifecycle" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="680,490,880,562">
|
||||
<rect x="680.0" y="490.0" width="200.0" height="72.0" rx="12" fill="#ffffff" stroke="#9bb7cf" stroke-width="1.4" filter="url(#shadowSoft)"/>
|
||||
<rect x="692.0" y="505.0" width="42.0" height="42.0" rx="11" fill="#f59e0b" opacity="0.12" stroke="#f59e0b" stroke-width="1.2"/>
|
||||
<path d="M 700.0 526.0 Q 713.0 514.0 726.0 526.0 Q 713.0 538.0 700.0 526.0 Z" fill="none" stroke="#f59e0b" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M 707.0 526.0 H 711.0 L 714.0 521.0 L 717.0 531.0 L 720.0 526.0" fill="none" stroke="#f59e0b" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<text data-text-role="title" data-full-text="ClientHold" x="746.0" y="521.0" text-anchor="start" class="node-title" font-size="13.5">ClientHold</text>
|
||||
<text data-text-role="subtitle" data-full-text="客户暂停 · DNS停止" x="746.0" y="540.0" text-anchor="start" class="node-sub" font-size="11.5">客户暂停 · DNS停止</text>
|
||||
<text x="870.0" y="504.0" text-anchor="end" font-size="8.5" font-weight="800" fill="#6b879d">REGISTRAR</text>
|
||||
</g>
|
||||
<g id="node-server-hold" data-graph-role="node" data-node-id="server-hold" data-semantic-role="cloud_service" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="lifecycle" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="680,590,880,662">
|
||||
<rect x="680.0" y="590.0" width="200.0" height="72.0" rx="12" fill="#ffffff" stroke="#9bb7cf" stroke-width="1.4" filter="url(#shadowSoft)"/>
|
||||
<rect x="692.0" y="605.0" width="42.0" height="42.0" rx="11" fill="#ef4444" opacity="0.12" stroke="#ef4444" stroke-width="1.2"/>
|
||||
<path d="M 700.0 626.0 Q 713.0 614.0 726.0 626.0 Q 713.0 638.0 700.0 626.0 Z" fill="none" stroke="#ef4444" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M 707.0 626.0 H 711.0 L 714.0 621.0 L 717.0 631.0 L 720.0 626.0" fill="none" stroke="#ef4444" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<text data-text-role="title" data-full-text="ServerHold" x="746.0" y="621.0" text-anchor="start" class="node-title" font-size="13.5">ServerHold</text>
|
||||
<text data-text-role="subtitle" data-full-text="注册局暂停 · 违规" x="746.0" y="640.0" text-anchor="start" class="node-sub" font-size="11.5">注册局暂停 · 违规</text>
|
||||
<text x="870.0" y="604.0" text-anchor="end" font-size="8.5" font-weight="800" fill="#6b879d">REGISTRY</text>
|
||||
</g>
|
||||
<g id="register-label" data-graph-role="label" data-owner="register" data-graph-bounds="455.3,215,493.3,235">
|
||||
<rect x="455.3" y="215.0" width="38.0" height="20" rx="6" fill="#f7fbfe" opacity="0.96"/>
|
||||
<text x="474.3" y="229.0" text-anchor="middle" class="arrow-label">注册</text>
|
||||
</g>
|
||||
<g id="renew-label" data-graph-role="label" data-owner="renew" data-graph-bounds="348,436,386,456">
|
||||
<rect x="348.0" y="436.0" width="38.0" height="20" rx="6" fill="#f7fbfe" opacity="0.96"/>
|
||||
<text x="367.0" y="450.0" text-anchor="middle" class="arrow-label">续费</text>
|
||||
</g>
|
||||
<g id="auto-renew-label" data-graph-role="label" data-owner="auto-renew" data-graph-bounds="221,477.84,259,497.84">
|
||||
<rect x="221.0" y="477.84" width="38.0" height="20" rx="6" fill="#f7fbfe" opacity="0.96"/>
|
||||
<text x="240.0" y="491.84" text-anchor="middle" class="arrow-label">到期</text>
|
||||
</g>
|
||||
<g id="to-redemption-label" data-graph-role="label" data-owner="to-redemption" data-graph-bounds="355,646,405,666">
|
||||
<rect x="355.0" y="646.0" width="50.0" height="20" rx="6" fill="#f7fbfe" opacity="0.96"/>
|
||||
<text x="380.0" y="660.0" text-anchor="middle" class="arrow-label">未支付</text>
|
||||
</g>
|
||||
<g id="to-transfer-label" data-graph-role="label" data-owner="to-transfer" data-graph-bounds="573,295,611,315">
|
||||
<rect x="573.0" y="295.0" width="38.0" height="20" rx="6" fill="#f7fbfe" opacity="0.96"/>
|
||||
<text x="592.0" y="309.0" text-anchor="middle" class="arrow-label">转移</text>
|
||||
</g>
|
||||
<g id="transfer-complete-label" data-graph-role="label" data-owner="transfer-complete" data-graph-bounds="749,366,811,386">
|
||||
<rect x="749.0" y="366.0" width="62.0" height="20" rx="6" fill="#f7fbfe" opacity="0.96"/>
|
||||
<text x="780.0" y="380.0" text-anchor="middle" class="arrow-label">转移完成</text>
|
||||
</g>
|
||||
<g id="transfer-ok-label" data-graph-role="label" data-owner="transfer-ok" data-graph-bounds="537,395,623,415">
|
||||
<rect x="537.0" y="395.0" width="86.0" height="20" rx="6" fill="#f7fbfe" opacity="0.96"/>
|
||||
<text x="580.0" y="409.0" text-anchor="middle" class="arrow-label">期满回到正常</text>
|
||||
</g>
|
||||
<g id="pending-to-available-label" data-graph-role="label" data-owner="pending-to-available" data-graph-bounds="119,462,157,482">
|
||||
<rect x="119.0" y="462.0" width="38.0" height="20" rx="6" fill="#f7fbfe" opacity="0.96"/>
|
||||
<text x="138.0" y="476.0" text-anchor="middle" class="arrow-label">释放</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 31 KiB |
@@ -0,0 +1,198 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1240 880" width="1240" height="880" data-generator="fireworks-tech-graph" data-schema-version="1" data-text-metrics="heuristic-v1" data-style-id="7" data-visual-theme="OpenAI" data-diagram-type="architecture" data-motion-scene="" data-semantic-profile="generic" data-semantic-valid="true" data-quality-profile="standard" data-max-bends-per-edge="4" data-max-total-bends="30" data-max-route-stretch="5.0" data-max-bridged-crossings="14" data-min-node-gap="0.0" data-min-container-gutter="0.0" data-min-label-clearance="2.0" data-min-segment-length="0.0">
|
||||
<defs>
|
||||
<marker id="arrowA" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#10a37f"/>
|
||||
</marker>
|
||||
<marker id="arrowB" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#0f766e"/>
|
||||
</marker>
|
||||
<marker id="arrowC" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#0891b2"/>
|
||||
</marker>
|
||||
<marker id="arrowE" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#f59e0b"/>
|
||||
</marker>
|
||||
<marker id="arrowF" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#64748b"/>
|
||||
</marker>
|
||||
<marker id="arrowG" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#475569"/>
|
||||
</marker>
|
||||
<marker id="arrowH" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
|
||||
<polygon points="0 0, 10 3.5, 0 7" fill="#94a3b8"/>
|
||||
</marker>
|
||||
<style>
|
||||
text { font-family: 'Helvetica Neue', Helvetica, Arial, 'PingFang SC', 'Noto Sans CJK SC', 'Microsoft YaHei', 'Microsoft JhengHei', 'SimHei', sans-serif; }
|
||||
.title { font-size: 24px; font-weight: 700; fill: #0f172a; }
|
||||
.subtitle { font-size: 13px; font-weight: 500; fill: #64748b; }
|
||||
.section { font-size: 13px; font-weight: 700; fill: #087f5b; letter-spacing: 1.4px; }
|
||||
.section-sub { font-size: 12px; font-weight: 500; fill: #64748b; }
|
||||
.node-title { font-weight: 700; fill: #0f172a; }
|
||||
.node-sub { font-weight: 500; fill: #475569; }
|
||||
.node-type { font-size: 11px; font-weight: 700; fill: #64748b; letter-spacing: 0.08em; }
|
||||
.arrow-label { font-size: 12px; font-weight: 600; fill: #475569; }
|
||||
.legend { font-size: 12px; font-weight: 500; fill: #475569; }
|
||||
.footnote { font-size: 12px; font-weight: 500; fill: #64748b; }
|
||||
.metric-label { font-size: 8.5px; font-weight: 700; fill: #64748b; text-transform: uppercase; }
|
||||
.metric-value { font-size: 9.5px; font-weight: 700; fill: #0f172a; }
|
||||
</style>
|
||||
</defs>
|
||||
<rect data-graph-role="background" width="1240.0" height="880.0" fill="#ffffff"/>
|
||||
<text x="48.0" y="48" text-anchor="start" class="title">域名生命周期状态机</text>
|
||||
<text x="48.0" y="72" text-anchor="start" class="subtitle">从可注册到释放的完整 EPP 状态流转(REGISTRY / REGISTRAR 管理方标注)</text>
|
||||
<line x1="48" y1="100" x2="1192.0" y2="100" stroke="#e2e8f0" stroke-width="1"/>
|
||||
<g id="reg" data-graph-role="container" data-container-id="reg" data-semantic-role="boundary" data-graph-bounds="40,70,1200,290">
|
||||
<rect data-graph-role="container" x="40.0" y="70.0" width="1160.0" height="220.0" rx="16.0" fill="none" stroke="#e2e8f0" stroke-width="1.4" stroke-dasharray="5 4"/>
|
||||
<text x="58.0" y="94.0" class="section">注册与活跃</text>
|
||||
<rect id="reg-header" data-graph-role="reserved" data-reserved-kind="container-header" x="48" y="76" width="95" height="30" fill="none" stroke="none"/>
|
||||
</g>
|
||||
<g id="grace" data-graph-role="container" data-container-id="grace" data-semantic-role="boundary" data-graph-bounds="40,330,1200,470">
|
||||
<rect data-graph-role="container" x="40.0" y="330.0" width="1160.0" height="140.0" rx="16.0" fill="none" stroke="#e2e8f0" stroke-width="1.4" stroke-dasharray="5 4"/>
|
||||
<text x="58.0" y="354.0" class="section">续费 · 到期 · 转移中</text>
|
||||
<rect id="grace-header" data-graph-role="reserved" data-reserved-kind="container-header" x="48" y="336" width="154.8" height="30" fill="none" stroke="none"/>
|
||||
</g>
|
||||
<g id="end" data-graph-role="container" data-container-id="end" data-semantic-role="boundary" data-graph-bounds="40,510,1200,810">
|
||||
<rect data-graph-role="container" x="40.0" y="510.0" width="1160.0" height="300.0" rx="16.0" fill="none" stroke="#e2e8f0" stroke-width="1.4" stroke-dasharray="5 4"/>
|
||||
<text x="58.0" y="534.0" class="section">赎回 · 释放 · 转移完成</text>
|
||||
<rect id="end-header" data-graph-role="reserved" data-reserved-kind="container-header" x="48" y="516" width="167.8" height="30" fill="none" stroke="none"/>
|
||||
</g>
|
||||
<path id="a-reg" data-graph-role="edge" data-edge-id="a-reg" data-source="available" data-target="addperiod" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="0" data-route-stretch="1.0" data-bridges="" d="M 270,170 L 380,170" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="a-ok" data-graph-role="edge" data-edge-id="a-ok" data-source="addperiod" data-target="active" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="2" data-route-stretch="1.0" data-bridges="" d="M 600,170 L 620.4,170 L 620.4,179 L 700,179" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="a-hold-c" data-graph-role="edge" data-edge-id="a-hold-c" data-source="active" data-target="clienthold" data-edge-kind="flow" data-topic-id="" data-flow="feedback" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="2" data-route-stretch="1.0" data-bridges="" d="M 910,152 L 930.4,152 L 930.4,137 L 990,137" fill="none" stroke="#475569" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowG)"/>
|
||||
<path id="a-hold-s" data-graph-role="edge" data-edge-id="a-hold-s" data-source="active" data-target="serverhold" data-edge-kind="flow" data-topic-id="" data-flow="feedback" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="2" data-route-stretch="1.0" data-bridges="" d="M 910,170 L 930.4,170 L 930.4,232 L 990,232" fill="none" stroke="#475569" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowG)"/>
|
||||
<path id="a-renew" data-graph-role="edge" data-edge-id="a-renew" data-source="active" data-target="renewperiod" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="2" data-route-stretch="1.0" data-bridges="" d="M 787,200 L 787,220.4 L 796,220.4 L 796,380" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="a-renew-back" data-graph-role="edge" data-edge-id="a-renew-back" data-source="renewperiod" data-target="active" data-edge-kind="flow" data-topic-id="" data-flow="feedback" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="4" data-route-stretch="1.032" data-bridges="" d="M 814,380 L 814,359.6 L 817,359.6 L 817,220.4 L 805,220.4 L 805,200" fill="none" stroke="#475569" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowG)"/>
|
||||
<path id="a-expire-bridge-mask" data-graph-role="bridge-mask" data-owner="a-expire" d="M 700,161 L 692.86,161 L 692.86,174 A 5 5 0 0 1 692.86,184 L 692.86,224 L 510,224 L 510,380" fill="none" stroke="#ffffff" stroke-width="6.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path id="a-expire" data-graph-role="edge" data-edge-id="a-expire" data-source="active" data-target="autorenew" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="3" data-route-stretch="1.0" data-bridges="692.86,179" d="M 700,161 L 692.86,161 L 692.86,174 A 5 5 0 0 1 692.86,184 L 692.86,224 L 510,224 L 510,380" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="a-no-pay" data-graph-role="edge" data-edge-id="a-no-pay" data-source="autorenew" data-target="redemption" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="0" data-route-stretch="1.0" data-bridges="" d="M 510,440 L 510,560" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="a-redemption-end" data-graph-role="edge" data-edge-id="a-redemption-end" data-source="redemption" data-target="pendingdelete" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="0" data-route-stretch="1.0" data-bridges="" d="M 380,590 L 310,590" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="a-release" data-graph-role="edge" data-edge-id="a-release" data-source="pendingdelete" data-target="released" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="4" data-route-stretch="2.625" data-bridges="" d="M 190,620 L 190,640.4 L 305.6,640.4 L 305.6,732.86 L 200,732.86 L 200,740" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="a-transfer" data-graph-role="edge" data-edge-id="a-transfer" data-source="active" data-target="pendingtransfer" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="4" data-route-stretch="1.0" data-bridges="" d="M 910,188 L 930,188 L 930,356 L 959.6,356 L 959.6,410 L 980,410" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="a-transfer-done" data-graph-role="edge" data-edge-id="a-transfer-done" data-source="pendingtransfer" data-target="transferperiod" data-edge-kind="flow" data-topic-id="" data-flow="control" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="3" data-route-stretch="1.078" data-bridges="" d="M 1080,440 L 1080,464 L 679.6,464 L 679.6,581 L 700,581" fill="none" stroke="#10a37f" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowA)"/>
|
||||
<path id="a-transfer-ok-bridge-mask" data-graph-role="bridge-mask" data-owner="a-transfer-ok" d="M 700,599 L 676,599 L 676,230.4 L 700,230.4 L 700,200 L 782,200 A 5 5 0 0 0 792,200 L 800,200 A 5 5 0 0 0 810,200 L 823,200 L 823,200" fill="none" stroke="#ffffff" stroke-width="6.5" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path id="a-transfer-ok" data-graph-role="edge" data-edge-id="a-transfer-ok" data-source="transferperiod" data-target="active" data-edge-kind="flow" data-topic-id="" data-flow="feedback" data-motion-role="" data-motion-stage="" data-motion-order="" data-protocol="" data-via="" data-critical-path-id="" data-critical-hop="" data-critical-hops="" data-critical="false" data-bends="4" data-route-stretch="1.092" data-bridges="787,200;805,200" d="M 700,599 L 676,599 L 676,230.4 L 700,230.4 L 700,200 L 782,200 A 5 5 0 0 0 792,200 L 800,200 A 5 5 0 0 0 810,200 L 823,200 L 823,200" fill="none" stroke="#475569" stroke-width="2.0" stroke-linecap="round" stroke-linejoin="round" marker-end="url(#arrowG)"/>
|
||||
<g id="node-available" data-graph-role="node" data-node-id="available" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="70,140,270,200">
|
||||
<rect x="70.0" y="140.0" width="200.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="170.0" y="158.0" text-anchor="middle" class="node-type">REGISTRY</text>
|
||||
<text data-text-role="title" data-full-text="Available · 域名可注册" data-text-max-width="176.0" x="170.0" y="176.0" text-anchor="middle" class="node-title" font-size="15.17">Available · 域名可注册</text>
|
||||
</g>
|
||||
<g id="node-addperiod" data-graph-role="node" data-node-id="addperiod" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="380,140,600,200">
|
||||
<rect x="380.0" y="140.0" width="220.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="490.0" y="158.0" text-anchor="middle" class="node-type">REGISTRY</text>
|
||||
<text data-text-role="title" data-full-text="AddPeriod · 注册完成 5天" data-text-max-width="196.0" x="490.0" y="176.0" text-anchor="middle" class="node-title" font-size="14.87">AddPeriod · 注册完成 5天</text>
|
||||
</g>
|
||||
<g id="node-active" data-graph-role="node" data-node-id="active" data-semantic-role="double_rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="700,140,910,200">
|
||||
<rect x="700.0" y="140.0" width="210.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#10a37f" stroke-width="2.0"/>
|
||||
<rect x="706.0" y="146.0" width="198.0" height="48.0" rx="11.0" fill="none" stroke="#10a37f" stroke-width="1.2" opacity="0.65"/>
|
||||
<text x="805.0" y="158.0" text-anchor="middle" class="node-type">REGISTRAR · Active</text>
|
||||
<text data-text-role="title" data-full-text="Active (ok) · 正常解析" data-text-max-width="178.0" x="805.0" y="176.0" text-anchor="middle" class="node-title" font-size="14.71">Active (ok) · 正常解析</text>
|
||||
</g>
|
||||
<g id="node-clienthold" data-graph-role="node" data-node-id="clienthold" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="990,110,1190,164">
|
||||
<rect x="990.0" y="110.0" width="200.0" height="54.0" rx="14.0" fill="#ffffff" stroke="#f97316" stroke-width="1.8"/>
|
||||
<text x="1090.0" y="128.0" text-anchor="middle" class="node-type">REGISTRAR</text>
|
||||
<text data-text-role="title" data-full-text="ClientHold · 客户暂停" data-text-max-width="176.0" x="1090.0" y="143.0" text-anchor="middle" class="node-title" font-size="15.79">ClientHold · 客户暂停</text>
|
||||
</g>
|
||||
<g id="node-serverhold" data-graph-role="node" data-node-id="serverhold" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="990,205,1190,259">
|
||||
<rect x="990.0" y="205.0" width="200.0" height="54.0" rx="14.0" fill="#ffffff" stroke="#f97316" stroke-width="1.8"/>
|
||||
<text x="1090.0" y="223.0" text-anchor="middle" class="node-type">REGISTRY</text>
|
||||
<text data-text-role="title" data-full-text="ServerHold · 注册局暂停" data-text-max-width="176.0" x="1090.0" y="238.0" text-anchor="middle" class="node-title" font-size="13.76">ServerHold · 注册局暂停</text>
|
||||
</g>
|
||||
<g id="node-renewperiod" data-graph-role="node" data-node-id="renewperiod" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="700,380,910,440">
|
||||
<rect x="700.0" y="380.0" width="210.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="805.0" y="398.0" text-anchor="middle" class="node-type">REGISTRY</text>
|
||||
<text data-text-role="title" data-full-text="RenewPeriod · 手动续费 5天" data-text-max-width="186.0" x="805.0" y="416.0" text-anchor="middle" class="node-title" font-size="12.89">RenewPeriod · 手动续费 5天</text>
|
||||
</g>
|
||||
<g id="node-autorenew" data-graph-role="node" data-node-id="autorenew" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="380,380,640,440">
|
||||
<rect x="380.0" y="380.0" width="260.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="510.0" y="398.0" text-anchor="middle" class="node-type">REGISTRY</text>
|
||||
<text data-text-role="title" data-full-text="AutoRenewPeriod · 等待扣费" data-text-max-width="236.0" x="510.0" y="416.0" text-anchor="middle" class="node-title" font-size="15.9">AutoRenewPeriod · 等待扣费</text>
|
||||
</g>
|
||||
<g id="node-pendingtransfer" data-graph-role="node" data-node-id="pendingtransfer" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="980,380,1180,440">
|
||||
<rect x="980.0" y="380.0" width="200.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="1080.0" y="398.0" text-anchor="middle" class="node-type">REGISTRAR</text>
|
||||
<text data-text-role="title" data-full-text="PendingTransfer · 转移中" data-text-max-width="176.0" x="1080.0" y="416.0" text-anchor="middle" class="node-title" font-size="12.79">PendingTransfer · 转移中</text>
|
||||
</g>
|
||||
<g id="node-transferperiod" data-graph-role="node" data-node-id="transferperiod" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="700,560,910,620">
|
||||
<rect x="700.0" y="560.0" width="210.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="805.0" y="578.0" text-anchor="middle" class="node-type">REGISTRAR</text>
|
||||
<text data-text-role="title" data-full-text="TransferPeriod · 5天" data-text-max-width="186.0" x="805.0" y="596.0" text-anchor="middle" class="node-title" font-size="16.03">TransferPeriod · 5天</text>
|
||||
</g>
|
||||
<g id="node-redemption" data-graph-role="node" data-node-id="redemption" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="380,560,640,620">
|
||||
<rect x="380.0" y="560.0" width="260.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="510.0" y="578.0" text-anchor="middle" class="node-type">REGISTRY</text>
|
||||
<text data-text-role="title" data-full-text="RedemptionPeriod · 赎回 30天" data-text-max-width="236.0" x="510.0" y="596.0" text-anchor="middle" class="node-title" font-size="14.98">RedemptionPeriod · 赎回 30天</text>
|
||||
</g>
|
||||
<g id="node-pendingdelete" data-graph-role="node" data-node-id="pendingdelete" data-semantic-role="rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="70,560,310,620">
|
||||
<rect x="70.0" y="560.0" width="240.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#dce5e3" stroke-width="1.8"/>
|
||||
<text x="190.0" y="578.0" text-anchor="middle" class="node-type">REGISTRY</text>
|
||||
<text data-text-role="title" data-full-text="PendingDelete · 删除 5天" data-text-max-width="216.0" x="190.0" y="596.0" text-anchor="middle" class="node-title" font-size="16.31">PendingDelete · 删除 5天</text>
|
||||
</g>
|
||||
<g id="node-released" data-graph-role="node" data-node-id="released" data-semantic-role="double_rect" data-motion-role="" data-motion-stage="" data-motion-order="" data-parent="" data-deployment-id="" data-topic-id="" data-span-id="" data-station-order="" data-status="" data-start-ms="" data-duration-ms="" data-parent-span="" data-graph-bounds="70,740,330,800">
|
||||
<rect x="70.0" y="740.0" width="260.0" height="60.0" rx="14.0" fill="#ffffff" stroke="#1d4ed8" stroke-width="2.0"/>
|
||||
<rect x="76.0" y="746.0" width="248.0" height="48.0" rx="11.0" fill="none" stroke="#1d4ed8" stroke-width="1.2" opacity="0.65"/>
|
||||
<text x="200.0" y="758.0" text-anchor="middle" class="node-type">END</text>
|
||||
<text data-text-role="title" data-full-text="已释放 · 重新开放注册" data-text-max-width="228.0" x="200.0" y="776.0" text-anchor="middle" class="node-title" font-size="18">已释放 · 重新开放注册</text>
|
||||
</g>
|
||||
<g id="a-reg-label" data-graph-role="label" data-owner="a-reg" data-graph-bounds="306,139,344,159">
|
||||
<rect x="306.0" y="139.0" width="38.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="325.0" y="153.0" text-anchor="middle" class="arrow-label">注册</text>
|
||||
</g>
|
||||
<g id="a-ok-label" data-graph-role="label" data-owner="a-ok" data-graph-bounds="629.2,148,691.2,168">
|
||||
<rect x="629.2" y="148.0" width="62.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="660.2" y="162.0" text-anchor="middle" class="arrow-label">注册完成</text>
|
||||
</g>
|
||||
<g id="a-hold-c-label" data-graph-role="label" data-owner="a-hold-c" data-graph-bounds="911.2,106,973.2,126">
|
||||
<rect x="911.2" y="106.0" width="62.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="942.2" y="120.0" text-anchor="middle" class="arrow-label">暂停解析</text>
|
||||
</g>
|
||||
<g id="a-hold-s-label" data-graph-role="label" data-owner="a-hold-s" data-graph-bounds="865.4,205,927.4,225">
|
||||
<rect x="865.4" y="205.0" width="62.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="896.4" y="219.0" text-anchor="middle" class="arrow-label">违规暂停</text>
|
||||
</g>
|
||||
<g id="a-renew-label" data-graph-role="label" data-owner="a-renew" data-graph-bounds="755,286.2,793,306.2">
|
||||
<rect x="755.0" y="286.2" width="38.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="774.0" y="300.2" text-anchor="middle" class="arrow-label">续费</text>
|
||||
</g>
|
||||
<g id="a-renew-back-label" data-graph-role="label" data-owner="a-renew-back" data-graph-bounds="820,276,906,296">
|
||||
<rect x="820.0" y="276.0" width="86.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="863.0" y="290.0" text-anchor="middle" class="arrow-label">期满回到正常</text>
|
||||
</g>
|
||||
<g id="a-expire-label" data-graph-role="label" data-owner="a-expire" data-graph-bounds="582.43,211,620.43,231">
|
||||
<rect x="582.43" y="211.0" width="38.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="601.43" y="225.0" text-anchor="middle" class="arrow-label">到期</text>
|
||||
</g>
|
||||
<g id="a-no-pay-label" data-graph-role="label" data-owner="a-no-pay" data-graph-bounds="457,486,507,506">
|
||||
<rect x="457.0" y="486.0" width="50.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="482.0" y="500.0" text-anchor="middle" class="arrow-label">未支付</text>
|
||||
</g>
|
||||
<g id="a-redemption-end-label" data-graph-role="label" data-owner="a-redemption-end" data-graph-bounds="314,559,376,579">
|
||||
<rect x="314.0" y="559.0" width="62.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="345.0" y="573.0" text-anchor="middle" class="arrow-label">赎回期满</text>
|
||||
</g>
|
||||
<g id="a-release-label" data-graph-role="label" data-owner="a-release" data-graph-bounds="228.8,627.4,266.8,647.4">
|
||||
<rect x="228.8" y="627.4" width="38.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="247.8" y="641.4" text-anchor="middle" class="arrow-label">释放</text>
|
||||
</g>
|
||||
<g id="a-transfer-label" data-graph-role="label" data-owner="a-transfer" data-graph-bounds="889,248,927,268">
|
||||
<rect x="889.0" y="248.0" width="38.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="908.0" y="262.0" text-anchor="middle" class="arrow-label">转移</text>
|
||||
</g>
|
||||
<g id="a-transfer-done-label" data-graph-role="label" data-owner="a-transfer-done" data-graph-bounds="848.8,451,910.8,471">
|
||||
<rect x="848.8" y="451.0" width="62.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="879.8" y="465.0" text-anchor="middle" class="arrow-label">转移完成</text>
|
||||
</g>
|
||||
<g id="a-transfer-ok-label" data-graph-role="label" data-owner="a-transfer-ok" data-graph-bounds="611,474.42,673,494.42">
|
||||
<rect x="611.0" y="474.42" width="62.0" height="20" rx="6" fill="#ffffff" opacity="0.96"/>
|
||||
<text x="642.0" y="488.42" text-anchor="middle" class="arrow-label">转移生效</text>
|
||||
</g>
|
||||
<g id="legend" data-graph-role="legend">
|
||||
<rect id="legend-zone" data-graph-role="reserved" data-reserved-kind="legend" x="32" y="684" width="273.6" height="46" rx="10" fill="none" stroke="none"/>
|
||||
<line data-graph-role="decoration" x1="42.0" y1="698.0" x2="72.0" y2="698.0" stroke="#10a37f" stroke-width="2.0" marker-end="url(#arrowA)"/>
|
||||
<text data-graph-role="decoration" x="82.0" y="702.0" class="legend">状态流转</text>
|
||||
<line data-graph-role="decoration" x1="158.0" y1="698.0" x2="188.0" y2="698.0" stroke="#475569" stroke-width="2.0" marker-end="url(#arrowG)"/>
|
||||
<text data-graph-role="decoration" x="198.0" y="702.0" class="legend">回到活跃 / 暂停</text>
|
||||
</g>
|
||||
<g id="footer" data-graph-role="reserved" data-graph-bounds="48,833,433,849">
|
||||
<text x="48.0" y="845.0" class="footnote">Style 7 · OpenAI Official · EPP domain lifecycle states</text>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 27 KiB |
@@ -2,7 +2,7 @@
|
||||
<svg width="85px" height="36px" viewBox="0 0 85 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ssl-s1</title>
|
||||
<g id="ssl-s1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="ipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<g id="nipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<rect stroke="#07C160" x="0.5" y="0.5" width="74" height="27" rx="5"></rect>
|
||||
<g transform="translate(15.000000, 4.000000)" fill="#07C160">
|
||||
<text id="SSL" font-family="PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans SC, sans-serif" font-size="14" font-weight="500">
|
||||
|
||||
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
@@ -2,7 +2,7 @@
|
||||
<svg width="85px" height="36px" viewBox="0 0 85 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ssl-s2</title>
|
||||
<g id="ssl-s2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="ipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<g id="nipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<rect stroke="#61BD13" x="0.5" y="0.5" width="74" height="27" rx="5"></rect>
|
||||
<g transform="translate(15.000000, 4.000000)" fill="#61BD13">
|
||||
<text id="SSL" font-family="PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans SC, sans-serif" font-size="14" font-weight="500">
|
||||
|
||||
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
@@ -2,7 +2,7 @@
|
||||
<svg width="85px" height="36px" viewBox="0 0 85 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ssl-s3</title>
|
||||
<g id="ssl-s3" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="ipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<g id="nipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<rect id="矩形备份" stroke="#1A42A0" x="0.5" y="0.5" width="74" height="27" rx="5"></rect>
|
||||
<text id="SSL" font-family="PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans SC, sans-serif" font-size="14" font-weight="500" fill="#1A42A0">
|
||||
<tspan x="34" y="19">SSL</tspan>
|
||||
|
||||
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
@@ -2,7 +2,7 @@
|
||||
<svg width="85px" height="36px" viewBox="0 0 85 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ssl-s4</title>
|
||||
<g id="ssl-s4" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="ipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<g id="nipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<rect stroke="#3A84FF" x="0.5" y="0.5" width="74" height="27" rx="5"></rect>
|
||||
<g transform="translate(15.000000, 4.000000)" fill="#3A84FF">
|
||||
<text id="SSL" font-family="PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans SC, sans-serif" font-size="14" font-weight="500">
|
||||
|
||||
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
@@ -2,7 +2,7 @@
|
||||
<svg width="85px" height="36px" viewBox="0 0 85 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ssl-s5</title>
|
||||
<g id="ssl-s5" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="ipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<g id="nipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<rect stroke="#313238" x="0.5" y="0.5" width="74" height="27" rx="5"></rect>
|
||||
<text id="SSL" font-family="PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans SC, sans-serif" font-size="14" font-weight="500" fill="#313238">
|
||||
<tspan x="34" y="19">SSL</tspan>
|
||||
|
||||
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
@@ -2,7 +2,7 @@
|
||||
<svg width="85px" height="36px" viewBox="0 0 85 36" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<title>ssl-s6</title>
|
||||
<g id="ssl-s6" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
||||
<g id="ipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<g id="nipw.cn" transform="translate(5.000000, 4.000000)">
|
||||
<rect stroke="#757575" x="0.5" y="0.5" width="74" height="27" rx="5"></rect>
|
||||
<text id="SSL" font-family="PingFang SC, Microsoft YaHei, Source Han Sans SC, Noto Sans SC, sans-serif" font-size="14" font-weight="500" fill="#757575">
|
||||
<tspan x="34" y="19">SSL</tspan>
|
||||
|
||||
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env node
|
||||
// CI 部署完成后一次性提交 sitemap 全部 URL 到 IndexNow(Bing / Yandex / Seznam / Yep 共用端点)。
|
||||
// 用法:node scripts/indexnow-submit.mjs --site https://nipw.cn --key <key>
|
||||
//
|
||||
// key 必须与 frontend-ssr/public/<key>.txt 完全一致 —— IndexNow 的所有权校验就是抓取
|
||||
// 这个文件比对,所以 key 本身是公开凭证、写在 CI 里并不泄密。
|
||||
// 逻辑与 server/utils/indexnow.ts 保持一致(那边是运行时端点,这边是构建机直跑)。
|
||||
|
||||
const args = process.argv.slice(2)
|
||||
function argOf(name) {
|
||||
const i = args.indexOf(name)
|
||||
return i >= 0 ? args[i + 1] : undefined
|
||||
}
|
||||
|
||||
const site = (argOf('--site') || 'https://nipw.cn').replace(/\/$/, '')
|
||||
const key = argOf('--key')
|
||||
|
||||
if (!key) {
|
||||
console.error('usage: node scripts/indexnow-submit.mjs --site <url> --key <key>')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const INDEXNOW_ENDPOINT = 'https://api.indexnow.org/IndexNow'
|
||||
const sitemapUrl = `${site}/sitemap.xml`
|
||||
|
||||
const res = await fetch(sitemapUrl)
|
||||
if (!res.ok) {
|
||||
console.error(`sitemap fetch failed: ${res.status} ${sitemapUrl}`)
|
||||
process.exit(1)
|
||||
}
|
||||
const xml = await res.text()
|
||||
const urls = [...xml.matchAll(/<loc>([^<]+)<\/loc>/g)].map(m => m[1].trim())
|
||||
if (!urls.length) {
|
||||
console.error('sitemap has no <loc> entries, nothing to submit')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// IndexNow 单请求最多 1 万条,分片兜底
|
||||
const CHUNK = 10_000
|
||||
let ok = 0
|
||||
for (let i = 0; i < urls.length; i += CHUNK) {
|
||||
const urlList = urls.slice(i, i + CHUNK)
|
||||
const r = await fetch(INDEXNOW_ENDPOINT, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json; charset=utf-8' },
|
||||
body: JSON.stringify({
|
||||
host: new URL(site).host,
|
||||
key,
|
||||
keyLocation: `${site}/${key}.txt`,
|
||||
urlList,
|
||||
}),
|
||||
})
|
||||
const body = await r.text().catch(() => '')
|
||||
console.log(`IndexNow chunk ${i / CHUNK + 1}: HTTP ${r.status} (${urlList.length} urls) ${body.slice(0, 120)}`)
|
||||
if (r.ok || r.status === 202) ok += urlList.length
|
||||
}
|
||||
console.log(`submitted ${ok}/${urls.length} urls from ${sitemapUrl}`)
|
||||
// IndexNow 202 = 已受理;4xx 校验失败会让 CI 亮红,属预期失败信号
|
||||
if (!ok) process.exit(1)
|
||||
@@ -1,14 +1,36 @@
|
||||
import { defineSitemapEventHandler } from '#imports'
|
||||
// 直接 import 构建期常量,而不是走 runtimeConfig.public.docConfig:
|
||||
// 后者会被 Nuxt 序列化进每个页面的 HTML(4571 字节 / 页),而本路由是全站唯一消费方。
|
||||
// 相对路径与 server/routes/middleware/[...slug].get.ts 保持一致(`~` 在 Nuxt 4 里指向 app/,指不到根目录的 config/)。
|
||||
import { docConfig } from '../../../config/doc'
|
||||
|
||||
// 显式枚举全部工具页并标注权重:与 nuxt:pages 自动扫描并存(模块会按 loc 去重合并),
|
||||
// 好处是收录不依赖扫描行为、且带 priority/changefreq。
|
||||
// 注意 /ipv6 不在列表里:它已改为 server/routes/ipv6.get.ts 的服务端 301,不再是页面。
|
||||
const TOOL_PAGES: Array<{ loc: string; priority: number; changefreq: string }> = [
|
||||
{ loc: '/', priority: 1.0, changefreq: 'daily' },
|
||||
{ loc: '/location', priority: 0.9, changefreq: 'weekly' },
|
||||
{ loc: '/asn', priority: 0.9, changefreq: 'weekly' },
|
||||
{ loc: '/dns', priority: 0.9, changefreq: 'weekly' },
|
||||
{ loc: '/dnssec', priority: 0.9, changefreq: 'weekly' },
|
||||
{ loc: '/whois', priority: 0.9, changefreq: 'weekly' },
|
||||
{ loc: '/ssl', priority: 0.9, changefreq: 'weekly' },
|
||||
{ loc: '/tcping', priority: 0.9, changefreq: 'weekly' },
|
||||
{ loc: '/speedtest', priority: 0.9, changefreq: 'weekly' },
|
||||
{ loc: '/ipv6speedtest', priority: 0.9, changefreq: 'weekly' },
|
||||
{ loc: '/ipv6tcping', priority: 0.9, changefreq: 'weekly' },
|
||||
{ loc: '/ipv6webcheck', priority: 0.9, changefreq: 'weekly' },
|
||||
{ loc: '/screenshot', priority: 0.8, changefreq: 'weekly' },
|
||||
]
|
||||
|
||||
export default defineSitemapEventHandler(async () => {
|
||||
const config = useRuntimeConfig();
|
||||
console.log('Generating sitemap URLs from docConfig:', config.public.docConfig);
|
||||
|
||||
const urls = config.public.docConfig ? Object.keys(config.public.docConfig).map(path => ({ path })) : [];
|
||||
|
||||
return urls.map(url => ({
|
||||
loc: url.path,
|
||||
_encoded: true,
|
||||
const toolPages = TOOL_PAGES.map(({ loc, priority, changefreq }) => ({ loc, priority, changefreq }))
|
||||
// 文档页权重:索引页 /doc 高一档,正文页低一档
|
||||
const docPages = Object.keys(docConfig).map(path => ({
|
||||
loc: path,
|
||||
priority: path === '/doc' ? 0.8 : 0.7,
|
||||
changefreq: 'monthly',
|
||||
}))
|
||||
|
||||
return [...toolPages, ...docPages]
|
||||
})
|
||||
@@ -0,0 +1,15 @@
|
||||
// GET /api/indexnow?key=<key> —— 把 sitemap 里的全部 URL 提交到 IndexNow。
|
||||
// 给运维手动触发(curl)或外部监控调用;key 校验失败一律 403。
|
||||
export default defineEventHandler(async (event) => {
|
||||
const config = useRuntimeConfig(event)
|
||||
const key = getQuery(event).key
|
||||
if (!config.indexnowKey || key !== config.indexnowKey) {
|
||||
throw createError({ statusCode: 403, statusMessage: 'invalid key' })
|
||||
}
|
||||
const siteUrl = config.public.siteUrl
|
||||
const urls = await fetchSitemapUrls(siteUrl)
|
||||
if (!urls.length) {
|
||||
return { submitted: 0, status: 0, body: 'sitemap is empty' }
|
||||
}
|
||||
return await submitIndexNow(urls, siteUrl)
|
||||
})
|
||||
@@ -0,0 +1,16 @@
|
||||
// POST /api/indexnow?key=<key>(或请求头 x-indexnow-key),body: { urls: string[] }
|
||||
// —— 精确提交新增/变更的 URL(发布新文档、工具页上线等场景)。
|
||||
// URL 限本站域名(相对路径按 siteUrl 补全),跨域 URL 直接过滤。
|
||||
export default defineEventHandler(async (event) => {
|
||||
const config = useRuntimeConfig(event)
|
||||
const key = getQuery(event).key || getHeader(event, 'x-indexnow-key')
|
||||
if (!config.indexnowKey || key !== config.indexnowKey) {
|
||||
throw createError({ statusCode: 403, statusMessage: 'invalid key' })
|
||||
}
|
||||
const body = await readBody<{ urls?: unknown[] }>(event).catch(() => null)
|
||||
const urls = normalizeIndexNowUrls(body?.urls ?? [], config.public.siteUrl)
|
||||
if (!urls.length) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'no valid urls (same host only)' })
|
||||
}
|
||||
return await submitIndexNow(urls, config.public.siteUrl)
|
||||
})
|
||||
@@ -0,0 +1,501 @@
|
||||
{
|
||||
"canvas": {
|
||||
"height": 640.0,
|
||||
"width": 1240.0
|
||||
},
|
||||
"composition": {
|
||||
"limits": {
|
||||
"max_bends_per_edge": 12,
|
||||
"max_bridged_crossings": 8,
|
||||
"max_route_stretch": 5.0,
|
||||
"max_total_bends": 100,
|
||||
"min_container_gutter": 0.0,
|
||||
"min_label_clearance": 2.0,
|
||||
"min_node_gap": 0.0,
|
||||
"min_segment_length": 0.0,
|
||||
"profile": "standard"
|
||||
},
|
||||
"metrics": {
|
||||
"bridged_crossings": 5,
|
||||
"max_route_stretch": 1.872,
|
||||
"minimum_container_gutter": 19.0,
|
||||
"minimum_node_gap": 55.0,
|
||||
"shortest_segment": 3.28,
|
||||
"total_bends": 19
|
||||
},
|
||||
"ok": true,
|
||||
"profile": "standard",
|
||||
"score": 38,
|
||||
"violations": []
|
||||
},
|
||||
"edges": [
|
||||
{
|
||||
"bends": 0,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "ds-tld",
|
||||
"length": 165.0,
|
||||
"route": [
|
||||
[
|
||||
330.0,
|
||||
195.0
|
||||
],
|
||||
[
|
||||
495.0,
|
||||
195.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "root",
|
||||
"source_port": [
|
||||
330.0,
|
||||
195.0
|
||||
],
|
||||
"target": "tld",
|
||||
"target_port": [
|
||||
495.0,
|
||||
195.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 0,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "ds-auth",
|
||||
"length": 160.0,
|
||||
"route": [
|
||||
[
|
||||
745.0,
|
||||
195.0
|
||||
],
|
||||
[
|
||||
905.0,
|
||||
195.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "tld",
|
||||
"source_port": [
|
||||
745.0,
|
||||
195.0
|
||||
],
|
||||
"target": "auth",
|
||||
"target_port": [
|
||||
905.0,
|
||||
195.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 2,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "pub-key",
|
||||
"length": 963.5,
|
||||
"route": [
|
||||
[
|
||||
1023.5,
|
||||
225.0
|
||||
],
|
||||
[
|
||||
1023.5,
|
||||
346.0
|
||||
],
|
||||
[
|
||||
205.0,
|
||||
346.0
|
||||
],
|
||||
[
|
||||
205.0,
|
||||
370.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "auth",
|
||||
"source_port": [
|
||||
1023.5,
|
||||
225.0
|
||||
],
|
||||
"target": "dnskey",
|
||||
"target_port": [
|
||||
205.0,
|
||||
370.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 6,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "sign",
|
||||
"length": 1060.3,
|
||||
"route": [
|
||||
[
|
||||
1041.5,
|
||||
225.0
|
||||
],
|
||||
[
|
||||
1041.5,
|
||||
245.4
|
||||
],
|
||||
[
|
||||
1184.0,
|
||||
245.4
|
||||
],
|
||||
[
|
||||
1184.0,
|
||||
454.0
|
||||
],
|
||||
[
|
||||
745.0,
|
||||
454.0
|
||||
],
|
||||
[
|
||||
745.0,
|
||||
349.6
|
||||
],
|
||||
[
|
||||
620.0,
|
||||
349.6
|
||||
],
|
||||
[
|
||||
620.0,
|
||||
370.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.872,
|
||||
"source": "auth",
|
||||
"source_port": [
|
||||
1041.5,
|
||||
225.0
|
||||
],
|
||||
"target": "rrset",
|
||||
"target_port": [
|
||||
620.0,
|
||||
370.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 4,
|
||||
"bridges": [
|
||||
[
|
||||
884.6,
|
||||
454.0
|
||||
]
|
||||
],
|
||||
"crossings": [
|
||||
[
|
||||
884.6,
|
||||
454.0
|
||||
]
|
||||
],
|
||||
"id": "fetch-key",
|
||||
"length": 706.0,
|
||||
"route": [
|
||||
[
|
||||
330.0,
|
||||
400.0
|
||||
],
|
||||
[
|
||||
350.4,
|
||||
400.0
|
||||
],
|
||||
[
|
||||
350.4,
|
||||
461.0
|
||||
],
|
||||
[
|
||||
884.6,
|
||||
461.0
|
||||
],
|
||||
[
|
||||
884.6,
|
||||
391.0
|
||||
],
|
||||
[
|
||||
905.0,
|
||||
391.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.209,
|
||||
"source": "dnskey",
|
||||
"source_port": [
|
||||
330.0,
|
||||
400.0
|
||||
],
|
||||
"target": "resolver",
|
||||
"target_port": [
|
||||
905.0,
|
||||
391.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 2,
|
||||
"bridges": [
|
||||
[
|
||||
745.0,
|
||||
400.0
|
||||
],
|
||||
[
|
||||
884.6,
|
||||
409.0
|
||||
]
|
||||
],
|
||||
"crossings": [
|
||||
[
|
||||
745.0,
|
||||
400.0
|
||||
],
|
||||
[
|
||||
884.6,
|
||||
409.0
|
||||
]
|
||||
],
|
||||
"id": "fetch-rr",
|
||||
"length": 169.0,
|
||||
"route": [
|
||||
[
|
||||
745.0,
|
||||
400.0
|
||||
],
|
||||
[
|
||||
748.28,
|
||||
400.0
|
||||
],
|
||||
[
|
||||
748.28,
|
||||
409.0
|
||||
],
|
||||
[
|
||||
905.0,
|
||||
409.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "rrset",
|
||||
"source_port": [
|
||||
745.0,
|
||||
400.0
|
||||
],
|
||||
"target": "resolver",
|
||||
"target_port": [
|
||||
905.0,
|
||||
409.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 5,
|
||||
"bridges": [
|
||||
[
|
||||
1044.0,
|
||||
454.0
|
||||
]
|
||||
],
|
||||
"crossings": [
|
||||
[
|
||||
1044.0,
|
||||
454.0
|
||||
]
|
||||
],
|
||||
"id": "a-check",
|
||||
"length": 825.5,
|
||||
"route": [
|
||||
[
|
||||
1032.5,
|
||||
430.0
|
||||
],
|
||||
[
|
||||
1032.5,
|
||||
450.4
|
||||
],
|
||||
[
|
||||
1044.0,
|
||||
450.4
|
||||
],
|
||||
[
|
||||
1044.0,
|
||||
565.0
|
||||
],
|
||||
[
|
||||
590.0,
|
||||
565.0
|
||||
],
|
||||
[
|
||||
590.0,
|
||||
485.0
|
||||
],
|
||||
[
|
||||
445.0,
|
||||
485.0
|
||||
],
|
||||
[
|
||||
445.0,
|
||||
485.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.285,
|
||||
"source": "resolver",
|
||||
"source_port": [
|
||||
1032.5,
|
||||
430.0
|
||||
],
|
||||
"target": "check",
|
||||
"target_port": [
|
||||
445.0,
|
||||
485.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 0,
|
||||
"bridges": [
|
||||
[
|
||||
590.0,
|
||||
513.0
|
||||
]
|
||||
],
|
||||
"crossings": [
|
||||
[
|
||||
590.0,
|
||||
513.0
|
||||
]
|
||||
],
|
||||
"id": "a-pass",
|
||||
"length": 140.0,
|
||||
"route": [
|
||||
[
|
||||
590.0,
|
||||
513.0
|
||||
],
|
||||
[
|
||||
730.0,
|
||||
513.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "check",
|
||||
"source_port": [
|
||||
590.0,
|
||||
513.0
|
||||
],
|
||||
"target": "pass",
|
||||
"target_port": [
|
||||
730.0,
|
||||
513.0
|
||||
],
|
||||
"waypoints": []
|
||||
}
|
||||
],
|
||||
"input_schema": "v1",
|
||||
"issues": [
|
||||
{
|
||||
"code": "EDGE_CROSSING_BRIDGED",
|
||||
"coordinates": [
|
||||
[
|
||||
884.6,
|
||||
454.0
|
||||
]
|
||||
],
|
||||
"element": "fetch-key",
|
||||
"severity": "info"
|
||||
},
|
||||
{
|
||||
"code": "EDGE_CROSSING_BRIDGED",
|
||||
"coordinates": [
|
||||
[
|
||||
745.0,
|
||||
400.0
|
||||
],
|
||||
[
|
||||
884.6,
|
||||
409.0
|
||||
]
|
||||
],
|
||||
"element": "fetch-rr",
|
||||
"severity": "info"
|
||||
},
|
||||
{
|
||||
"code": "EDGE_CROSSING_BRIDGED",
|
||||
"coordinates": [
|
||||
[
|
||||
1044.0,
|
||||
454.0
|
||||
]
|
||||
],
|
||||
"element": "a-check",
|
||||
"severity": "info"
|
||||
},
|
||||
{
|
||||
"code": "EDGE_CROSSING_BRIDGED",
|
||||
"coordinates": [
|
||||
[
|
||||
590.0,
|
||||
513.0
|
||||
]
|
||||
],
|
||||
"element": "a-pass",
|
||||
"severity": "info"
|
||||
}
|
||||
],
|
||||
"mode": "architecture",
|
||||
"ok": true,
|
||||
"palette": {
|
||||
"below_target": [],
|
||||
"minimum_target": 4.5,
|
||||
"ratios": {
|
||||
"section_sub_fill": 4.76,
|
||||
"text_muted": 4.76,
|
||||
"text_primary": 17.85,
|
||||
"text_secondary": 7.58
|
||||
},
|
||||
"scope": "default opaque canvas text tokens; not a full rendered accessibility audit",
|
||||
"unsupported_tokens": []
|
||||
},
|
||||
"placements": {
|
||||
"legend": {
|
||||
"actual": [
|
||||
42.0,
|
||||
530.0
|
||||
],
|
||||
"bounds": [
|
||||
32.0,
|
||||
516.0,
|
||||
215.6,
|
||||
606.0
|
||||
],
|
||||
"moved": true,
|
||||
"requested": [
|
||||
42.0,
|
||||
540.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"schema_version": 1,
|
||||
"semantics": {
|
||||
"details": {},
|
||||
"ok": true,
|
||||
"profile": "generic",
|
||||
"style": 7,
|
||||
"visual_theme": "OpenAI"
|
||||
},
|
||||
"style": {
|
||||
"id": 7,
|
||||
"name": "OpenAI"
|
||||
},
|
||||
"summary": {
|
||||
"bridged_crossings": 5,
|
||||
"edges": 8,
|
||||
"nodes": 8
|
||||
},
|
||||
"text_metrics": "heuristic-v1",
|
||||
"typography": {
|
||||
"complete_text": true,
|
||||
"hint": null,
|
||||
"metrics": "heuristic widths; inspect the actual rendered font",
|
||||
"truncated": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"mode": "architecture",
|
||||
"template_type": "architecture",
|
||||
"style": 7,
|
||||
"quality_profile": "standard",
|
||||
"width": 1240,
|
||||
"height": 640,
|
||||
"title": "DNSSEC 验证链与本地验签",
|
||||
"subtitle": "DS 信任链自根向下逐级建立,递归侧以 DNSKEY 验证 RRset 签名",
|
||||
"containers": [
|
||||
{
|
||||
"id": "trust",
|
||||
"x": 40,
|
||||
"y": 110,
|
||||
"width": 1160,
|
||||
"height": 150,
|
||||
"label": "信任链 · 由根向下逐级签发",
|
||||
"stroke": "#e2e8f0",
|
||||
"fill": "none"
|
||||
},
|
||||
{
|
||||
"id": "verify",
|
||||
"x": 40,
|
||||
"y": 310,
|
||||
"width": 1160,
|
||||
"height": 250,
|
||||
"label": "递归解析侧 · 本地验签",
|
||||
"stroke": "#e2e8f0",
|
||||
"fill": "none"
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"id": "root",
|
||||
"kind": "rect",
|
||||
"x": 80,
|
||||
"y": 165,
|
||||
"width": 250,
|
||||
"height": 60,
|
||||
"type_label": "ROOT · 信任锚",
|
||||
"label": "根 DNS(内置信任锚)",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "tld",
|
||||
"kind": "double_rect",
|
||||
"x": 495,
|
||||
"y": 165,
|
||||
"width": 250,
|
||||
"height": 60,
|
||||
"type_label": "TLD · .top",
|
||||
"label": "顶级 DNS(发布 DS)",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#10a37f"
|
||||
},
|
||||
{
|
||||
"id": "auth",
|
||||
"kind": "double_rect",
|
||||
"x": 905,
|
||||
"y": 165,
|
||||
"width": 255,
|
||||
"height": 60,
|
||||
"type_label": "AUTHORITATIVE",
|
||||
"label": "权威 DNS(发布 DNSKEY)",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#10a37f"
|
||||
},
|
||||
{
|
||||
"id": "dnskey",
|
||||
"kind": "rect",
|
||||
"x": 80,
|
||||
"y": 370,
|
||||
"width": 250,
|
||||
"height": 60,
|
||||
"type_label": "DNSKEY",
|
||||
"label": "KSK / ZSK 密钥",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "rrset",
|
||||
"kind": "rect",
|
||||
"x": 495,
|
||||
"y": 370,
|
||||
"width": 250,
|
||||
"height": 60,
|
||||
"type_label": "RRSET + RRSIG",
|
||||
"label": "记录数据与签名",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "resolver",
|
||||
"kind": "double_rect",
|
||||
"x": 905,
|
||||
"y": 370,
|
||||
"width": 255,
|
||||
"height": 60,
|
||||
"type_label": "RECURSIVE · DO=1",
|
||||
"label": "递归解析器(带 DO 查询)",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#1d4ed8"
|
||||
},
|
||||
{
|
||||
"id": "check",
|
||||
"kind": "rect",
|
||||
"x": 300,
|
||||
"y": 485,
|
||||
"width": 290,
|
||||
"height": 56,
|
||||
"type_label": "VERIFY",
|
||||
"label": "RRSIG.Verify 本地验签",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "pass",
|
||||
"kind": "double_rect",
|
||||
"x": 730,
|
||||
"y": 485,
|
||||
"width": 290,
|
||||
"height": 56,
|
||||
"type_label": "RESULT",
|
||||
"label": "验证通过 · 数据完整可信",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#10a37f"
|
||||
}
|
||||
],
|
||||
"arrows": [
|
||||
{
|
||||
"id": "ds-tld",
|
||||
"source": "root",
|
||||
"target": "tld",
|
||||
"source_port": "right",
|
||||
"target_port": "left",
|
||||
"flow": "control",
|
||||
"label": "DS 签发"
|
||||
},
|
||||
{
|
||||
"id": "ds-auth",
|
||||
"source": "tld",
|
||||
"target": "auth",
|
||||
"source_port": "right",
|
||||
"target_port": "left",
|
||||
"flow": "control",
|
||||
"label": "DS 指向下级 KEY"
|
||||
},
|
||||
{
|
||||
"id": "pub-key",
|
||||
"source": "auth",
|
||||
"target": "dnskey",
|
||||
"source_port": "bottom",
|
||||
"target_port": "top",
|
||||
"flow": "write",
|
||||
"label": "发布密钥"
|
||||
},
|
||||
{
|
||||
"id": "sign",
|
||||
"source": "auth",
|
||||
"target": "rrset",
|
||||
"source_port": "bottom",
|
||||
"target_port": "top",
|
||||
"flow": "write",
|
||||
"label": "私钥签名"
|
||||
},
|
||||
{
|
||||
"id": "fetch-key",
|
||||
"source": "dnskey",
|
||||
"target": "resolver",
|
||||
"source_port": "right",
|
||||
"target_port": "left",
|
||||
"flow": "read",
|
||||
"label": "取回 DNSKEY"
|
||||
},
|
||||
{
|
||||
"id": "fetch-rr",
|
||||
"source": "rrset",
|
||||
"target": "resolver",
|
||||
"source_port": "right",
|
||||
"target_port": "left",
|
||||
"flow": "read",
|
||||
"label": "带签名应答"
|
||||
},
|
||||
{
|
||||
"id": "a-check",
|
||||
"source": "resolver",
|
||||
"target": "check",
|
||||
"source_port": "bottom",
|
||||
"target_port": "top",
|
||||
"flow": "control",
|
||||
"label": "RRSIG.Verify"
|
||||
},
|
||||
{
|
||||
"id": "a-pass",
|
||||
"source": "check",
|
||||
"target": "pass",
|
||||
"source_port": "right",
|
||||
"target_port": "left",
|
||||
"flow": "control",
|
||||
"label": "验签通过"
|
||||
}
|
||||
],
|
||||
"legend": [
|
||||
{
|
||||
"flow": "control",
|
||||
"label": "信任链 / 主验证路径"
|
||||
},
|
||||
{
|
||||
"flow": "read",
|
||||
"label": "数据获取"
|
||||
},
|
||||
{
|
||||
"flow": "write",
|
||||
"label": "权威侧写操作"
|
||||
}
|
||||
],
|
||||
"footer": "Style 7 · OpenAI Official · DNSSEC chain of trust",
|
||||
"footer_x": 48,
|
||||
"footer_y": 625
|
||||
}
|
||||
@@ -0,0 +1,648 @@
|
||||
{
|
||||
"canvas": {
|
||||
"height": 880.0,
|
||||
"width": 1240.0
|
||||
},
|
||||
"composition": {
|
||||
"limits": {
|
||||
"max_bends_per_edge": 4,
|
||||
"max_bridged_crossings": 14,
|
||||
"max_route_stretch": 5.0,
|
||||
"max_total_bends": 30,
|
||||
"min_container_gutter": 0.0,
|
||||
"min_label_clearance": 2.0,
|
||||
"min_node_gap": 0.0,
|
||||
"min_segment_length": 0.0,
|
||||
"profile": "standard"
|
||||
},
|
||||
"metrics": {
|
||||
"bridged_crossings": 3,
|
||||
"max_route_stretch": 2.625,
|
||||
"minimum_container_gutter": 10.0,
|
||||
"minimum_node_gap": 41.0,
|
||||
"shortest_segment": 3.0,
|
||||
"total_bends": 30
|
||||
},
|
||||
"ok": true,
|
||||
"profile": "standard",
|
||||
"score": 42,
|
||||
"violations": []
|
||||
},
|
||||
"edges": [
|
||||
{
|
||||
"bends": 0,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "a-reg",
|
||||
"length": 110.0,
|
||||
"route": [
|
||||
[
|
||||
270.0,
|
||||
170.0
|
||||
],
|
||||
[
|
||||
380.0,
|
||||
170.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "available",
|
||||
"source_port": [
|
||||
270.0,
|
||||
170.0
|
||||
],
|
||||
"target": "addperiod",
|
||||
"target_port": [
|
||||
380.0,
|
||||
170.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 2,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "a-ok",
|
||||
"length": 109.0,
|
||||
"route": [
|
||||
[
|
||||
600.0,
|
||||
170.0
|
||||
],
|
||||
[
|
||||
620.4,
|
||||
170.0
|
||||
],
|
||||
[
|
||||
620.4,
|
||||
179.0
|
||||
],
|
||||
[
|
||||
700.0,
|
||||
179.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "addperiod",
|
||||
"source_port": [
|
||||
600.0,
|
||||
170.0
|
||||
],
|
||||
"target": "active",
|
||||
"target_port": [
|
||||
700.0,
|
||||
179.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 2,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "a-hold-c",
|
||||
"length": 95.0,
|
||||
"route": [
|
||||
[
|
||||
910.0,
|
||||
152.0
|
||||
],
|
||||
[
|
||||
930.4,
|
||||
152.0
|
||||
],
|
||||
[
|
||||
930.4,
|
||||
137.0
|
||||
],
|
||||
[
|
||||
990.0,
|
||||
137.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "active",
|
||||
"source_port": [
|
||||
910.0,
|
||||
152.0
|
||||
],
|
||||
"target": "clienthold",
|
||||
"target_port": [
|
||||
990.0,
|
||||
137.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 2,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "a-hold-s",
|
||||
"length": 142.0,
|
||||
"route": [
|
||||
[
|
||||
910.0,
|
||||
170.0
|
||||
],
|
||||
[
|
||||
930.4,
|
||||
170.0
|
||||
],
|
||||
[
|
||||
930.4,
|
||||
232.0
|
||||
],
|
||||
[
|
||||
990.0,
|
||||
232.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "active",
|
||||
"source_port": [
|
||||
910.0,
|
||||
170.0
|
||||
],
|
||||
"target": "serverhold",
|
||||
"target_port": [
|
||||
990.0,
|
||||
232.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 2,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "a-renew",
|
||||
"length": 189.0,
|
||||
"route": [
|
||||
[
|
||||
787.0,
|
||||
200.0
|
||||
],
|
||||
[
|
||||
787.0,
|
||||
220.4
|
||||
],
|
||||
[
|
||||
796.0,
|
||||
220.4
|
||||
],
|
||||
[
|
||||
796.0,
|
||||
380.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "active",
|
||||
"source_port": [
|
||||
787.0,
|
||||
200.0
|
||||
],
|
||||
"target": "renewperiod",
|
||||
"target_port": [
|
||||
796.0,
|
||||
380.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 4,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "a-renew-back",
|
||||
"length": 195.0,
|
||||
"route": [
|
||||
[
|
||||
814.0,
|
||||
380.0
|
||||
],
|
||||
[
|
||||
814.0,
|
||||
359.6
|
||||
],
|
||||
[
|
||||
817.0,
|
||||
359.6
|
||||
],
|
||||
[
|
||||
817.0,
|
||||
220.4
|
||||
],
|
||||
[
|
||||
805.0,
|
||||
220.4
|
||||
],
|
||||
[
|
||||
805.0,
|
||||
200.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.032,
|
||||
"source": "renewperiod",
|
||||
"source_port": [
|
||||
814.0,
|
||||
380.0
|
||||
],
|
||||
"target": "active",
|
||||
"target_port": [
|
||||
805.0,
|
||||
200.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 3,
|
||||
"bridges": [
|
||||
[
|
||||
692.86,
|
||||
179.0
|
||||
]
|
||||
],
|
||||
"crossings": [
|
||||
[
|
||||
692.86,
|
||||
179.0
|
||||
]
|
||||
],
|
||||
"id": "a-expire",
|
||||
"length": 409.0,
|
||||
"route": [
|
||||
[
|
||||
700.0,
|
||||
161.0
|
||||
],
|
||||
[
|
||||
692.86,
|
||||
161.0
|
||||
],
|
||||
[
|
||||
692.86,
|
||||
224.0
|
||||
],
|
||||
[
|
||||
510.0,
|
||||
224.0
|
||||
],
|
||||
[
|
||||
510.0,
|
||||
380.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "active",
|
||||
"source_port": [
|
||||
700.0,
|
||||
161.0
|
||||
],
|
||||
"target": "autorenew",
|
||||
"target_port": [
|
||||
510.0,
|
||||
380.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 0,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "a-no-pay",
|
||||
"length": 120.0,
|
||||
"route": [
|
||||
[
|
||||
510.0,
|
||||
440.0
|
||||
],
|
||||
[
|
||||
510.0,
|
||||
560.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "autorenew",
|
||||
"source_port": [
|
||||
510.0,
|
||||
440.0
|
||||
],
|
||||
"target": "redemption",
|
||||
"target_port": [
|
||||
510.0,
|
||||
560.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 0,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "a-redemption-end",
|
||||
"length": 70.0,
|
||||
"route": [
|
||||
[
|
||||
380.0,
|
||||
590.0
|
||||
],
|
||||
[
|
||||
310.0,
|
||||
590.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "redemption",
|
||||
"source_port": [
|
||||
380.0,
|
||||
590.0
|
||||
],
|
||||
"target": "pendingdelete",
|
||||
"target_port": [
|
||||
310.0,
|
||||
590.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 4,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "a-release",
|
||||
"length": 341.2,
|
||||
"route": [
|
||||
[
|
||||
190.0,
|
||||
620.0
|
||||
],
|
||||
[
|
||||
190.0,
|
||||
640.4
|
||||
],
|
||||
[
|
||||
305.6,
|
||||
640.4
|
||||
],
|
||||
[
|
||||
305.6,
|
||||
732.86
|
||||
],
|
||||
[
|
||||
200.0,
|
||||
732.86
|
||||
],
|
||||
[
|
||||
200.0,
|
||||
740.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 2.625,
|
||||
"source": "pendingdelete",
|
||||
"source_port": [
|
||||
190.0,
|
||||
620.0
|
||||
],
|
||||
"target": "released",
|
||||
"target_port": [
|
||||
200.0,
|
||||
740.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 4,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "a-transfer",
|
||||
"length": 292.0,
|
||||
"route": [
|
||||
[
|
||||
910.0,
|
||||
188.0
|
||||
],
|
||||
[
|
||||
930.0,
|
||||
188.0
|
||||
],
|
||||
[
|
||||
930.0,
|
||||
356.0
|
||||
],
|
||||
[
|
||||
959.6,
|
||||
356.0
|
||||
],
|
||||
[
|
||||
959.6,
|
||||
410.0
|
||||
],
|
||||
[
|
||||
980.0,
|
||||
410.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.0,
|
||||
"source": "active",
|
||||
"source_port": [
|
||||
910.0,
|
||||
188.0
|
||||
],
|
||||
"target": "pendingtransfer",
|
||||
"target_port": [
|
||||
980.0,
|
||||
410.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 3,
|
||||
"bridges": [],
|
||||
"crossings": [],
|
||||
"id": "a-transfer-done",
|
||||
"length": 561.8,
|
||||
"route": [
|
||||
[
|
||||
1080.0,
|
||||
440.0
|
||||
],
|
||||
[
|
||||
1080.0,
|
||||
464.0
|
||||
],
|
||||
[
|
||||
679.6,
|
||||
464.0
|
||||
],
|
||||
[
|
||||
679.6,
|
||||
581.0
|
||||
],
|
||||
[
|
||||
700.0,
|
||||
581.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.078,
|
||||
"source": "pendingtransfer",
|
||||
"source_port": [
|
||||
1080.0,
|
||||
440.0
|
||||
],
|
||||
"target": "transferperiod",
|
||||
"target_port": [
|
||||
700.0,
|
||||
581.0
|
||||
],
|
||||
"waypoints": []
|
||||
},
|
||||
{
|
||||
"bends": 4,
|
||||
"bridges": [
|
||||
[
|
||||
787.0,
|
||||
200.0
|
||||
],
|
||||
[
|
||||
805.0,
|
||||
200.0
|
||||
]
|
||||
],
|
||||
"crossings": [
|
||||
[
|
||||
787.0,
|
||||
200.0
|
||||
],
|
||||
[
|
||||
805.0,
|
||||
200.0
|
||||
]
|
||||
],
|
||||
"id": "a-transfer-ok",
|
||||
"length": 570.0,
|
||||
"route": [
|
||||
[
|
||||
700.0,
|
||||
599.0
|
||||
],
|
||||
[
|
||||
676.0,
|
||||
599.0
|
||||
],
|
||||
[
|
||||
676.0,
|
||||
230.4
|
||||
],
|
||||
[
|
||||
700.0,
|
||||
230.4
|
||||
],
|
||||
[
|
||||
700.0,
|
||||
200.0
|
||||
],
|
||||
[
|
||||
823.0,
|
||||
200.0
|
||||
],
|
||||
[
|
||||
823.0,
|
||||
200.0
|
||||
]
|
||||
],
|
||||
"route_stretch": 1.092,
|
||||
"source": "transferperiod",
|
||||
"source_port": [
|
||||
700.0,
|
||||
599.0
|
||||
],
|
||||
"target": "active",
|
||||
"target_port": [
|
||||
823.0,
|
||||
200.0
|
||||
],
|
||||
"waypoints": []
|
||||
}
|
||||
],
|
||||
"input_schema": "v1",
|
||||
"issues": [
|
||||
{
|
||||
"code": "EDGE_CROSSING_BRIDGED",
|
||||
"coordinates": [
|
||||
[
|
||||
692.86,
|
||||
179.0
|
||||
]
|
||||
],
|
||||
"element": "a-expire",
|
||||
"severity": "info"
|
||||
},
|
||||
{
|
||||
"code": "EDGE_CROSSING_BRIDGED",
|
||||
"coordinates": [
|
||||
[
|
||||
787.0,
|
||||
200.0
|
||||
],
|
||||
[
|
||||
805.0,
|
||||
200.0
|
||||
]
|
||||
],
|
||||
"element": "a-transfer-ok",
|
||||
"severity": "info"
|
||||
}
|
||||
],
|
||||
"mode": "architecture",
|
||||
"ok": true,
|
||||
"palette": {
|
||||
"below_target": [],
|
||||
"minimum_target": 4.5,
|
||||
"ratios": {
|
||||
"section_sub_fill": 4.76,
|
||||
"text_muted": 4.76,
|
||||
"text_primary": 17.85,
|
||||
"text_secondary": 7.58
|
||||
},
|
||||
"scope": "default opaque canvas text tokens; not a full rendered accessibility audit",
|
||||
"unsupported_tokens": []
|
||||
},
|
||||
"placements": {
|
||||
"legend": {
|
||||
"actual": [
|
||||
42.0,
|
||||
698.0
|
||||
],
|
||||
"bounds": [
|
||||
32.0,
|
||||
684.0,
|
||||
305.6,
|
||||
730.0
|
||||
],
|
||||
"moved": true,
|
||||
"requested": [
|
||||
42.0,
|
||||
798.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"schema_version": 1,
|
||||
"semantics": {
|
||||
"details": {},
|
||||
"ok": true,
|
||||
"profile": "generic",
|
||||
"style": 7,
|
||||
"visual_theme": "OpenAI"
|
||||
},
|
||||
"style": {
|
||||
"id": 7,
|
||||
"name": "OpenAI"
|
||||
},
|
||||
"summary": {
|
||||
"bridged_crossings": 3,
|
||||
"edges": 13,
|
||||
"nodes": 12
|
||||
},
|
||||
"text_metrics": "heuristic-v1",
|
||||
"typography": {
|
||||
"complete_text": true,
|
||||
"hint": null,
|
||||
"metrics": "heuristic widths; inspect the actual rendered font",
|
||||
"truncated": []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
{
|
||||
"schema_version": 1,
|
||||
"mode": "architecture",
|
||||
"template_type": "architecture",
|
||||
"style": 7,
|
||||
"quality_profile": "standard",
|
||||
"width": 1240,
|
||||
"height": 880,
|
||||
"title": "域名生命周期状态机",
|
||||
"subtitle": "从可注册到释放的完整 EPP 状态流转(REGISTRY / REGISTRAR 管理方标注)",
|
||||
"composition": {
|
||||
"profile": "standard",
|
||||
"max_bridged_crossings": 14,
|
||||
"max_total_bends": 30,
|
||||
"max_bends_per_edge": 4
|
||||
},
|
||||
"containers": [
|
||||
{
|
||||
"id": "reg",
|
||||
"x": 40,
|
||||
"y": 70,
|
||||
"width": 1160,
|
||||
"height": 220,
|
||||
"label": "注册与活跃",
|
||||
"stroke": "#e2e8f0",
|
||||
"fill": "none"
|
||||
},
|
||||
{
|
||||
"id": "grace",
|
||||
"x": 40,
|
||||
"y": 330,
|
||||
"width": 1160,
|
||||
"height": 140,
|
||||
"label": "续费 · 到期 · 转移中",
|
||||
"stroke": "#e2e8f0",
|
||||
"fill": "none"
|
||||
},
|
||||
{
|
||||
"id": "end",
|
||||
"x": 40,
|
||||
"y": 510,
|
||||
"width": 1160,
|
||||
"height": 300,
|
||||
"label": "赎回 · 释放 · 转移完成",
|
||||
"stroke": "#e2e8f0",
|
||||
"fill": "none"
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"id": "available",
|
||||
"kind": "rect",
|
||||
"x": 70,
|
||||
"y": 140,
|
||||
"width": 200,
|
||||
"height": 60,
|
||||
"type_label": "REGISTRY",
|
||||
"label": "Available · 域名可注册",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "addperiod",
|
||||
"kind": "rect",
|
||||
"x": 380,
|
||||
"y": 140,
|
||||
"width": 220,
|
||||
"height": 60,
|
||||
"type_label": "REGISTRY",
|
||||
"label": "AddPeriod · 注册完成 5天",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "active",
|
||||
"kind": "double_rect",
|
||||
"x": 700,
|
||||
"y": 140,
|
||||
"width": 210,
|
||||
"height": 60,
|
||||
"type_label": "REGISTRAR · Active",
|
||||
"label": "Active (ok) · 正常解析",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#10a37f"
|
||||
},
|
||||
{
|
||||
"id": "clienthold",
|
||||
"kind": "rect",
|
||||
"x": 990,
|
||||
"y": 110,
|
||||
"width": 200,
|
||||
"height": 54,
|
||||
"type_label": "REGISTRAR",
|
||||
"label": "ClientHold · 客户暂停",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#f97316",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "serverhold",
|
||||
"kind": "rect",
|
||||
"x": 990,
|
||||
"y": 205,
|
||||
"width": 200,
|
||||
"height": 54,
|
||||
"type_label": "REGISTRY",
|
||||
"label": "ServerHold · 注册局暂停",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#f97316",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "renewperiod",
|
||||
"kind": "rect",
|
||||
"x": 700,
|
||||
"y": 380,
|
||||
"width": 210,
|
||||
"height": 60,
|
||||
"type_label": "REGISTRY",
|
||||
"label": "RenewPeriod · 手动续费 5天",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "autorenew",
|
||||
"kind": "rect",
|
||||
"x": 380,
|
||||
"y": 380,
|
||||
"width": 260,
|
||||
"height": 60,
|
||||
"type_label": "REGISTRY",
|
||||
"label": "AutoRenewPeriod · 等待扣费",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "pendingtransfer",
|
||||
"kind": "rect",
|
||||
"x": 980,
|
||||
"y": 380,
|
||||
"width": 200,
|
||||
"height": 60,
|
||||
"type_label": "REGISTRAR",
|
||||
"label": "PendingTransfer · 转移中",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "transferperiod",
|
||||
"kind": "rect",
|
||||
"x": 700,
|
||||
"y": 560,
|
||||
"width": 210,
|
||||
"height": 60,
|
||||
"type_label": "REGISTRAR",
|
||||
"label": "TransferPeriod · 5天",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "redemption",
|
||||
"kind": "rect",
|
||||
"x": 380,
|
||||
"y": 560,
|
||||
"width": 260,
|
||||
"height": 60,
|
||||
"type_label": "REGISTRY",
|
||||
"label": "RedemptionPeriod · 赎回 30天",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "pendingdelete",
|
||||
"kind": "rect",
|
||||
"x": 70,
|
||||
"y": 560,
|
||||
"width": 240,
|
||||
"height": 60,
|
||||
"type_label": "REGISTRY",
|
||||
"label": "PendingDelete · 删除 5天",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#dce5e3",
|
||||
"flat": true
|
||||
},
|
||||
{
|
||||
"id": "released",
|
||||
"kind": "double_rect",
|
||||
"x": 70,
|
||||
"y": 740,
|
||||
"width": 260,
|
||||
"height": 60,
|
||||
"type_label": "END",
|
||||
"label": "已释放 · 重新开放注册",
|
||||
"fill": "#ffffff",
|
||||
"stroke": "#1d4ed8"
|
||||
}
|
||||
],
|
||||
"arrows": [
|
||||
{
|
||||
"id": "a-reg",
|
||||
"source": "available",
|
||||
"target": "addperiod",
|
||||
"source_port": "right",
|
||||
"target_port": "left",
|
||||
"flow": "control",
|
||||
"label": "注册"
|
||||
},
|
||||
{
|
||||
"id": "a-ok",
|
||||
"source": "addperiod",
|
||||
"target": "active",
|
||||
"source_port": "right",
|
||||
"target_port": "left",
|
||||
"flow": "control",
|
||||
"label": "注册完成"
|
||||
},
|
||||
{
|
||||
"id": "a-hold-c",
|
||||
"source": "active",
|
||||
"target": "clienthold",
|
||||
"source_port": "right",
|
||||
"target_port": "left",
|
||||
"flow": "feedback",
|
||||
"label": "暂停解析"
|
||||
},
|
||||
{
|
||||
"id": "a-hold-s",
|
||||
"source": "active",
|
||||
"target": "serverhold",
|
||||
"source_port": "right",
|
||||
"target_port": "left",
|
||||
"flow": "feedback",
|
||||
"label": "违规暂停"
|
||||
},
|
||||
{
|
||||
"id": "a-renew",
|
||||
"source": "active",
|
||||
"target": "renewperiod",
|
||||
"source_port": "bottom",
|
||||
"target_port": "top",
|
||||
"flow": "control",
|
||||
"label": "续费"
|
||||
},
|
||||
{
|
||||
"id": "a-renew-back",
|
||||
"source": "renewperiod",
|
||||
"target": "active",
|
||||
"source_port": "top",
|
||||
"target_port": "bottom",
|
||||
"flow": "feedback",
|
||||
"label": "期满回到正常"
|
||||
},
|
||||
{
|
||||
"id": "a-expire",
|
||||
"source": "active",
|
||||
"target": "autorenew",
|
||||
"source_port": "left",
|
||||
"target_port": "top",
|
||||
"flow": "control",
|
||||
"label": "到期"
|
||||
},
|
||||
{
|
||||
"id": "a-no-pay",
|
||||
"source": "autorenew",
|
||||
"target": "redemption",
|
||||
"source_port": "bottom",
|
||||
"target_port": "top",
|
||||
"flow": "control",
|
||||
"label": "未支付"
|
||||
},
|
||||
{
|
||||
"id": "a-redemption-end",
|
||||
"source": "redemption",
|
||||
"target": "pendingdelete",
|
||||
"source_port": "left",
|
||||
"target_port": "right",
|
||||
"flow": "control",
|
||||
"label": "赎回期满"
|
||||
},
|
||||
{
|
||||
"id": "a-release",
|
||||
"source": "pendingdelete",
|
||||
"target": "released",
|
||||
"source_port": "bottom",
|
||||
"target_port": "top",
|
||||
"flow": "control",
|
||||
"label": "释放"
|
||||
},
|
||||
{
|
||||
"id": "a-transfer",
|
||||
"source": "active",
|
||||
"target": "pendingtransfer",
|
||||
"source_port": "right",
|
||||
"target_port": "left",
|
||||
"flow": "control",
|
||||
"label": "转移"
|
||||
},
|
||||
{
|
||||
"id": "a-transfer-done",
|
||||
"source": "pendingtransfer",
|
||||
"target": "transferperiod",
|
||||
"source_port": "bottom",
|
||||
"target_port": "left",
|
||||
"flow": "control",
|
||||
"label": "转移完成"
|
||||
},
|
||||
{
|
||||
"id": "a-transfer-ok",
|
||||
"source": "transferperiod",
|
||||
"target": "active",
|
||||
"source_port": "left",
|
||||
"target_port": "bottom",
|
||||
"flow": "feedback",
|
||||
"label": "转移生效"
|
||||
}
|
||||
],
|
||||
"legend_orientation": "horizontal",
|
||||
"legend": [
|
||||
{
|
||||
"flow": "control",
|
||||
"label": "状态流转"
|
||||
},
|
||||
{
|
||||
"flow": "feedback",
|
||||
"label": "回到活跃 / 暂停"
|
||||
}
|
||||
],
|
||||
"footer": "Style 7 · OpenAI Official · EPP domain lifecycle states",
|
||||
"footer_x": 48,
|
||||
"footer_y": 845
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
# DNSSEC 原理介绍
|
||||
|
||||
DNSSEC(Domain Name System Security Extensions,DNS 安全扩展)通过**数字签名**为 DNS 应答提供来源验证与数据完整性保护:解析器收到应答后,用域名公钥本地验证签名,确认记录确实来自该域名的权威 DNS、且在传输途中没有被篡改或劫持。它防的是 DNS 欺骗与中间人攻击,但不加密内容——机密性仍由 TLS 负责。
|
||||
|
||||

|
||||
|
||||
## 三类关键记录
|
||||
|
||||
| 记录 | 发布位置 | 作用 |
|
||||
| --- | --- | --- |
|
||||
| `DNSKEY` | 域名自身 | 域名公钥,分 KSK(签密钥集)与 ZSK(签记录集) |
|
||||
| `RRSIG` | 域名自身 | 对每类记录集(RRset)的数字签名,随应答一并返回 |
|
||||
| `DS` | **父区**(如 `.top`) | 子域 DNSKEY 的摘要,是把信任链"挂"到上级的凭证 |
|
||||
|
||||
## 信任链如何建立
|
||||
|
||||
验证从根开始逐级向下:根的信任锚 → 顶级域的 `DS` → 域名的 `DNSKEY`。解析器拿到 `RRSIG` 后,用对应的 `DNSKEY` 做 `RRSIG.Verify` 本地验签;`DNSKEY` 自身的真伪再由父区 `DS` 核对,如此递归到根——任何一环对不上,应答即判定为 BOGUS(伪造)。
|
||||
|
||||
**本站的验证路径**:查询 `DNSKEY` → 带 DO 位查询 A 记录取回 `RRSIG` → 本地 `RRSIG.Verify` 验签(对 TLD / 无 A 记录的域,退回用 DNSKEY 自验签)→ 核对 `DS`。因国内公共 DNS(DNSPod / doh.pub / AliDNS)即使带 DO 位也不返回 RRSIG,本站默认使用实测支持 DNSSEC 的境外解析器列表(`1.1.1.1` / `8.8.8.8` 等,IPv4/IPv6 双栈)。
|
||||
|
||||
## 查询结果字段说明
|
||||
|
||||
| 字段 | 含义 |
|
||||
| --- | --- |
|
||||
| `enabled` | 是否启用 DNSSEC(存在 RRSIG 或 DNSKEY) |
|
||||
| `valid` | 签名是否验证通过 |
|
||||
| `has_rrsig` / `has_dnskey` / `has_ds` | 是否查到对应记录 |
|
||||
| `algorithm` / `key_tag` | 签名算法与密钥标签(如算法 13 = ECDSAP256SHA256) |
|
||||
| `validation` | 人类可读的判定说明 |
|
||||
|
||||
## 常见"验证失败"原因
|
||||
|
||||
- 域名本身**未配置 DNSSEC**(最常见——先在注册商处确认是否已开启);
|
||||
- `DNSKEY` 与 `DS` 不匹配(密钥轮换后父区 `DS` 未同步更新);
|
||||
- 解析器不支持 DNSSEC(带 DO 位也不返回 RRSIG,本站已默认规避);
|
||||
- 域名处于 ClientHold / ServerHold 暂停状态。
|
||||
|
||||
[DNS 解析查询](/dns) | [Whois 域名查询](/whois) | [回到顶部](#dnssec-原理介绍)
|
||||
@@ -0,0 +1,179 @@
|
||||
# [API] 获取客户端公网 IP 及位置
|
||||
|
||||
## 1. 接口描述
|
||||
|
||||
> IP 库来源于网络,本项目不对结果的准确性负责,请在中国法律许可范围内使用.
|
||||
|
||||
接口地址: `https://cn-jiangsu.api-ipw.wsmdn.top/v1/location`(公开实例,见 1.1;换成你自己节点的域名同样可用)
|
||||
|
||||
请求方法:`GET`
|
||||
|
||||
用途:取**请求方自己**的公网 IP,并给出 IP 归属地。
|
||||
|
||||
- **不带参数**:用服务端看到的客户端地址(Go `gin` 的 `ClientIP()`),因此"查自己"只需这一个请求。
|
||||
- **多源聚合,不合并**:返回 10 个 IP 库各自的结论,按源名分组,便于交叉比对;本项目不替你做"以哪个源为准"的判断。
|
||||
- **只查本地库**:不依赖任何第三方在线查询接口(唯一例外是 `bilibili` 源,24 小时缓存)。
|
||||
- **免鉴权**:节点未配 `access-token` 时公开可访问;配了则需带 `Authorization: Bearer <access-token>`。
|
||||
|
||||
> 本接口属于"业务探测"端点,请求会被节点计入统计并周期上报收集中心(不落库明细)。
|
||||
|
||||
### 1.1 公开实例
|
||||
|
||||
本项目对外开放了一个江苏节点,可以直接用它把本接口调通,**无需令牌**:
|
||||
|
||||
| 方式 | 地址 |
|
||||
| --- | --- |
|
||||
| 直连节点(推荐) | `https://cn-jiangsu.api-ipw.wsmdn.top/v1/location` |
|
||||
| 经中间件转发 | **不适用**——中间件路径的最后一段(拨测目标)必须非空,而本接口没有目标参数 |
|
||||
|
||||
> 公共实例是**共享**的,调试与小流量接入没问题,请勿高频轮询、批量抓取,也不要拿它当线上服务的依赖。
|
||||
|
||||
### 1.2 还有别的节点 —— 拨测控制台
|
||||
|
||||
上面的江苏节点只是节点池里的一个。节点池的入口是拨测控制台 <https://boce.wsmdn.top>:
|
||||
登录后进「可用节点」页,能看到**全部已启用节点**的节点标识、归属地、归属池(定位 / 拨测)、
|
||||
协议栈与在线状态,并附上每个节点的调用前缀。
|
||||
|
||||
比自己搭一套省事的地方:
|
||||
|
||||
- **节点现成** —— 名单里的节点都是已经部署好的,不用自己找机器、装程序、配隧道。
|
||||
- **入口现成** —— 统一走 HTTPS 转发,证书与反向代理不用自己操心。
|
||||
- **一套规则调所有节点** —— 接口路径与返回结构完全一致,换节点只换地址。
|
||||
- **池与栈标得很清楚** —— 定位类请求走定位池,拨测类走拨测池,两个池都有的节点两种都能接。
|
||||
- **名单会自己更新** —— 新接入的节点自动出现在列表里,不需要改代码。
|
||||
|
||||
> 本接口("查自己")**只能直连节点**:中间件路径的最后一段必须是拨测目标,而"查自己"没有目标参数,
|
||||
> 所以走中间件转发不适用。换别的节点时,把上例的 `cn-jiangsu.api-ipw.wsmdn.top`
|
||||
> 换成该节点的接入域名即可(节点标识见控制台的「可用节点」页)。
|
||||
>
|
||||
> 节点有上下线,列表中会标出在线状态;离线节点调用会失败。
|
||||
|
||||
## 2. 输入参数
|
||||
|
||||
无。
|
||||
|
||||
## 3. 输出参数
|
||||
|
||||
顶层是「源名 → 该源结果」的字典,另有 `ip` 回显请求方地址:
|
||||
|
||||
| 字段 | 类型 | 描述 |
|
||||
| --- | --- | --- |
|
||||
| `ip` | String | 请求方公网 IP(本节点视角) |
|
||||
| `lemondb` | Object | `country`/`country_code`/`administrative_area`/`city`/`district`/`division_code`/`isp`/`type`/`latitude`/`longitude`/`coord_system`(自家 LemonDB 月更库:全球打底 + 中国省市县高精度层,坐标统一 WGS-84,上高德底图需自转 GCJ-02) |
|
||||
| `lemondb_asn` | Object | `asn`/`org`(GeoLite2-ASN 打底 + APNIC CN 精修) |
|
||||
| `ip2region` | Object | `country`/`administrative_area`/`city`(部分记录另带 `isp`) |
|
||||
| `ip2location` | Object | `country`/`country_code`/`administrative_area`/`city`/`district`/`zipcode`/`latitude`/`longitude`/`timezone`/`isp`/`asn`/`usagetype` |
|
||||
| `ip2location_asn` | Object | `asn`/`as` |
|
||||
| `qqwry` | Object | `country`/`country_code`/`administrative_area`/`city`/`isp` |
|
||||
| `maxmind_city` | Object | `country`/`country_code`/`administrative_area`/`city`/`latitude`/`longitude` |
|
||||
| `maxmind_asn` | Object | `asn`/`org` |
|
||||
| `dbip_city` | Object | `country`/`country_code`/`administrative_area`/`city`/`latitude`/`longitude` |
|
||||
| `dbip_asn` | Object | `asn`/`org` |
|
||||
| `geocn` | Object | `division_code`(中国行政区划码)/`administrative_area`/`city`/`isp`/`type` |
|
||||
| `bilibili` | Object | `country`/`administrative_area`/`city`/`isp`/`latitude`/`longitude`(在线源) |
|
||||
|
||||
取值约定:
|
||||
|
||||
- 某源**未加载**时该键为字符串 `"not loaded"`;该源**查询出错**时为字符串 `"error: ..."`。
|
||||
单个源失败**不会**让整个请求失败——HTTP 状态码仍是 `200`。
|
||||
- 库里没有的字段返回空串 `""`。IP2Location LITE 免费版缺失的字段(如 `isp`、`asn`)已统一过滤,不会出现 `"This parameter is unavailable"`。
|
||||
- 经纬度类型各源不一致:`ip2location` 是**字符串**,`maxmind_*` / `dbip_*` 是**数字**;`bilibili` 也是字符串。
|
||||
- ASN 带前缀与否各源不一致:`maxmind_asn` / `dbip_asn` 形如 `AS13335`,`ip2location_asn.asn` 是裸数字 `13335`。
|
||||
|
||||
## 4. 示例
|
||||
|
||||
### 4.1 cURL 获取本机公网 IP 及位置
|
||||
|
||||
```bash
|
||||
curl https://cn-jiangsu.api-ipw.wsmdn.top/v1/location
|
||||
```
|
||||
|
||||
输出示例(节选):
|
||||
|
||||
```json
|
||||
{
|
||||
"ip": "1.1.1.1",
|
||||
"ip2region": { "country": "Australia", "administrative_area": "Queensland", "city": "Brisbane" },
|
||||
"ip2location": {
|
||||
"country": "Australia", "country_code": "AU", "administrative_area": "Queensland",
|
||||
"city": "Brisbane", "zipcode": "4000", "timezone": "+10:00",
|
||||
"latitude": "-27.46754", "longitude": "153.02809"
|
||||
},
|
||||
"maxmind_asn": { "asn": "AS13335", "org": "Cloudflare, Inc." },
|
||||
"dbip_city": {
|
||||
"country": "澳大利亚", "country_code": "AU", "administrative_area": "New South Wales",
|
||||
"city": "Sydney", "latitude": -33.8688, "longitude": 151.209
|
||||
},
|
||||
"qqwry": { "country": "澳大利亚", "country_code": "AU", "administrative_area": "", "city": "", "isp": "APNIC" },
|
||||
"geocn": { "division_code": "0", "isp": "", "type": "" },
|
||||
"bilibili": { "country": "CLOUDFLARE.COM", "administrative_area": "CLOUDFLARE.COM", "city": "", "isp": "" }
|
||||
}
|
||||
```
|
||||
|
||||
### 4.2 Python
|
||||
|
||||
```python
|
||||
#!/usr/bin/python3
|
||||
|
||||
import json
|
||||
import requests
|
||||
|
||||
r = requests.get('https://cn-jiangsu.api-ipw.wsmdn.top/v1/location')
|
||||
data = json.loads(r.text)
|
||||
|
||||
print(data['ip']) # 本机公网 IP
|
||||
print(data['ip2location']['country'],
|
||||
data['ip2location']['administrative_area'],
|
||||
data['ip2location']['city']) # 取某一个源
|
||||
print(data['maxmind_asn']['org']) # 运营商 / 组织
|
||||
```
|
||||
|
||||
### 4.3 Golang
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
resp, err := http.Get("https://cn-jiangsu.api-ipw.wsmdn.top/v1/location")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
|
||||
// 各源字段不一致,逐源取用;此处只解出需要的部分
|
||||
var result map[string]json.RawMessage
|
||||
if err := json.Unmarshal(body, &result); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var ip string
|
||||
_ = json.Unmarshal(result["ip"], &ip)
|
||||
|
||||
var loc struct {
|
||||
Country string `json:"country"`
|
||||
City string `json:"city"`
|
||||
}
|
||||
_ = json.Unmarshal(result["ip2location"], &loc)
|
||||
|
||||
fmt.Println(ip, loc.Country, loc.City)
|
||||
}
|
||||
```
|
||||
|
||||
## 5. 错误码
|
||||
|
||||
| 现象 | 说明 |
|
||||
| --- | --- |
|
||||
| `404 page not found` | 该节点 `ipdb` 已关闭:IP 库不加载时 `/v1/location`、`/v1/asn/:ip` 路由不注册 |
|
||||
| `401` | 节点配了 `access-token` 而未携带正确的 `Authorization: Bearer <access-token>` |
|
||||
| 全部源都是 `"error: ..."` / `"not loaded"` | IP 库仍在下载/加载,或本地库文件缺失。节点启动时自动拉取全套库(首次约 450MB),之后每 24h 更新一次 |
|
||||
| `ip` 是内网地址(如 `10.x`) | 直连节点、未经代理时看到的就是内网地址,属预期 |
|
||||
| `ip` 是代理/CDN 的地址 | 节点前置了 Nginx/CDN 但未配 `trusted-proxies`,`X-Forwarded-For` 不被信任。配置方式见《节点 API 与协议参考》 |
|
||||
@@ -0,0 +1,129 @@
|
||||
# [API] 获取客户端公网 IP 地址
|
||||
|
||||
## 1. 接口描述
|
||||
|
||||
> 该接口用于网络排障,请在中国法律许可范围内使用.
|
||||
|
||||
接口地址: `https://test.wsmdn.top/`(本项目公共实例,双栈;另有仅 IPv4 / 仅 IPv6 的实例,见下文)
|
||||
|
||||
请求方法:`GET`
|
||||
|
||||
用途:**原样**返回访问者的公网 IP——纯文本、无 JSON 包裹、无参数、无鉴权、不查任何 IP 库。
|
||||
|
||||
实现是本项目自带的两个边缘函数(任选其一部署,都只做这一件事):
|
||||
|
||||
| 形态 | 代码 | 取 IP 的方式 |
|
||||
| --- | --- | --- |
|
||||
| Cloudflare Workers | `serverless/lemon-getip` | `CF-Connecting-IP` 请求头 |
|
||||
| EdgeOne Edge Functions | `serverless/edgeone-getip` | `request.eo.clientIp` |
|
||||
|
||||
两者都返回 `content-type: text/plain` 并带 `Access-Control-Allow-Origin: *`,所以浏览器里可以直接跨域取、也可以 `curl`。
|
||||
|
||||
**按协议栈部署三份**,域名的解析记录决定拿到哪一族的地址:
|
||||
|
||||
| 用途 | DNS 记录 | 行为 |
|
||||
| --- | --- | --- |
|
||||
| 双栈 | A + AAAA | 返回客户端**实际使用**的那一族地址 |
|
||||
| 仅 IPv4 | 只配 A | 强制走 v4 出口,返回 IPv4 地址 |
|
||||
| 仅 IPv6 | 只配 AAAA | 纯 IPv6 网络下返回 IPv6 地址;本机没有 IPv6 出口时域名**解析不出来**(请求直接失败,而不是返回空) |
|
||||
|
||||
本项目公共实例即按此部署:`4.wsmdn.top`(仅 IPv4)、`6.wsmdn.top`(仅 IPv6)、`test.wsmdn.top`(双栈)。
|
||||
|
||||
> 想把"本机 IP"和"归属地"一次拿全,用同一套体系里的 `/v1/location`(见「获取客户端公网 IP 及位置」),
|
||||
> 它的 `ip` 字段与这里返回的是同一个地址。江苏节点公开实例:
|
||||
> `curl https://cn-jiangsu.api-ipw.wsmdn.top/v1/location`(无需令牌;该接口没有目标参数,
|
||||
> 只能直连节点,见该页的「公开实例」)。
|
||||
|
||||
## 2. 输入参数
|
||||
|
||||
无。
|
||||
|
||||
## 3. 输出参数
|
||||
|
||||
| 参数名称 | 类型 | 描述 |
|
||||
| --- | --- | --- |
|
||||
| 无 | String | 响应体**本身就是**客户端公网 IP 文本,例如 `223.68.219.100` |
|
||||
|
||||
判定要点:
|
||||
|
||||
- 只有 IP 一个 token,没有换行、没有 JSON 包裹;末尾是否带 `\n` 取决于边缘平台,取值前先 `strip()`。
|
||||
- 不查库 ⇒ 不会出现 `"not loaded"` 之类的占位串,也没有归属地信息。
|
||||
- 边缘函数按平台提供的客户端地址取值,**不解析 `X-Forwarded-For`**:它本身就是直接面向公网的入口。若你在它前面又套了一层自建代理,拿到的是代理地址。
|
||||
|
||||
## 4. 示例
|
||||
|
||||
### 4.1 cURL 获取本机公网 IP
|
||||
|
||||
```bash
|
||||
# 双栈(返回实际使用的栈)
|
||||
curl https://test.wsmdn.top
|
||||
|
||||
# 只要 IPv4 / 只要 IPv6
|
||||
curl https://4.wsmdn.top
|
||||
curl https://6.wsmdn.top
|
||||
```
|
||||
|
||||
输出示例:
|
||||
|
||||
```
|
||||
223.68.219.100
|
||||
```
|
||||
|
||||
### 4.2 Python
|
||||
|
||||
```python
|
||||
#!/usr/bin/python3
|
||||
|
||||
import requests
|
||||
|
||||
r = requests.get('https://test.wsmdn.top')
|
||||
clientIP = r.text.strip()
|
||||
|
||||
print(clientIP)
|
||||
```
|
||||
|
||||
### 4.3 Golang
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
resp, err := http.Get("https://test.wsmdn.top")
|
||||
if err != nil {
|
||||
fmt.Println("获取外网 IP 失败,请检查网络")
|
||||
panic(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
clientIP := strings.TrimSpace(string(body))
|
||||
|
||||
fmt.Println(clientIP)
|
||||
}
|
||||
```
|
||||
|
||||
### 4.4 浏览器里直接取(CORS 已放开)
|
||||
|
||||
```js
|
||||
const ip = await fetch('https://test.wsmdn.top').then(r => r.text())
|
||||
console.log(ip.trim())
|
||||
```
|
||||
|
||||
> 要判断"当前访问更偏向 IPv4 还是 IPv6",可以同时取双栈域名与两个单栈域名做对比,
|
||||
> 思路见「JS 检查网络是 IPv4 还是 IPv6」。
|
||||
|
||||
## 5. 错误码
|
||||
|
||||
| 现象 | 说明 |
|
||||
| --- | --- |
|
||||
| 域名解析失败 / 连接超时 | 用的是**仅 IPv6** 的域名,而本机没有 IPv6 出口。改用双栈或仅 IPv4 的域名 |
|
||||
| 返回 `Unable to determine IP address` | 边缘平台没有提供客户端地址。常见于本地直连调试(`wrangler dev` / EdgeOne 本地调试)或自建前置代理未透传 |
|
||||
| 返回的是代理地址 | 你在边缘函数前面又套了一层代理;该函数只认平台提供的客户端地址,不解析 `X-Forwarded-For` |
|
||||
| 拿到私有地址(如 `192.168.x.x`) | 本地/内网调试环境,边缘平台看到的就是内网出口 |
|
||||
@@ -0,0 +1,189 @@
|
||||
# [API] 查询指定 IP 地址的位置信息
|
||||
|
||||
## 1. 接口描述
|
||||
|
||||
> IP 库来源于网络,本项目不对结果的准确性负责,请在中国法律许可范围内使用.
|
||||
|
||||
接口地址: `https://cn-jiangsu.api-ipw.wsmdn.top/v1/location/<ip>`(公开实例,见 1.1)
|
||||
|
||||
请求方法:`GET`
|
||||
|
||||
用途:查询**任意 IP**(IPv4 或 IPv6)的归属地,返回与本项目其他查询同一套多源聚合结果。
|
||||
|
||||
- IP 写在**路径**里,不是查询串:`/v1/location/106.224.145.147`。IPv6 直接用标准写法(含 `:`)即可,无需 URL 编码以外的特殊处理。
|
||||
- 与「获取客户端公网 IP 及位置」共用同一个处理器与同一份 IP 库,**区别只是"查谁"**:不带路径参数 = 查请求方自己,带 = 查指定地址。
|
||||
- 出参结构与「获取客户端公网 IP 及位置」**完全一致**,见该页的字段表,此处不重复。
|
||||
- 免鉴权规则同所有 `/v1/*` 端点:节点配了 `access-token` 才需要 `Authorization: Bearer`。
|
||||
- 查 IP 归属地**不需要**目标是本项目节点、也不做连通性探测,只查库;因此查任何公网 IP 都是同样耗时。
|
||||
|
||||
### 1.1 公开实例
|
||||
|
||||
本项目对外开放了一个江苏节点,可以直接用它把本接口调通,**无需令牌**:
|
||||
|
||||
| 方式 | 地址 |
|
||||
| --- | --- |
|
||||
| 直连节点(推荐) | `https://cn-jiangsu.api-ipw.wsmdn.top/v1/location/<ip>` |
|
||||
| 经中间件转发 | `https://middleware-1.api-ipw.wsmdn.top/v1/cn-jiangsu/location/<ip>` |
|
||||
|
||||
两种写法都是「节点 / 接口 / 目标」三段:直连时端点本身就是节点,经中间件时多一段节点标识。
|
||||
中间件入口的 `/v1/` 前缀与 `/middleware/` 前缀等价,用哪个都行。
|
||||
|
||||
> 公共实例是**共享**的,调试与小流量接入没问题,请勿高频轮询、批量抓取,也不要拿它当线上服务的依赖。
|
||||
|
||||
### 1.2 还有别的节点 —— 拨测控制台
|
||||
|
||||
上面的江苏节点只是节点池里的一个。节点池的入口是拨测控制台 <https://boce.wsmdn.top>:
|
||||
登录后进「可用节点」页,能看到**全部已启用节点**的节点标识、归属地、归属池(定位 / 拨测)、
|
||||
协议栈与在线状态,每行都能一键复制调用前缀 —— 把上面那个中间件地址换成控制台给你的入口域名,
|
||||
再接上 `/v1/<节点标识>/` 就是完整前缀,**换节点只动中间那一段标识**。
|
||||
|
||||
比自己搭一套省事的地方:
|
||||
|
||||
- **节点现成** —— 名单里的节点都是已经部署好的,不用自己找机器、装程序、配隧道。
|
||||
- **入口现成** —— 统一走 HTTPS 转发,证书与反向代理不用自己操心。
|
||||
- **一套地址调所有节点** —— 换节点只改标识,接口路径、参数、返回结构都不变。
|
||||
- **池与栈标得很清楚** —— 定位类请求走定位池,拨测类走拨测池,两个池都有的节点两种都能接。
|
||||
- **名单会自己更新** —— 新接入的节点自动出现在列表里,不需要改代码。
|
||||
|
||||
用它调本接口(可直接粘贴执行):
|
||||
|
||||
```bash
|
||||
# 用列表里的江苏节点查一个 IP
|
||||
curl https://middleware-1.api-ipw.wsmdn.top/v1/cn-jiangsu/location/106.224.145.147
|
||||
|
||||
# 换成别的节点:只改中间那一段标识
|
||||
curl https://middleware-1.api-ipw.wsmdn.top/v1/<节点标识>/location/106.224.145.147
|
||||
```
|
||||
|
||||
> 节点有上下线,**离线的节点调用会失败**(返回 `502`)——名单上标了在线状态,挑在线的用。
|
||||
|
||||
## 2. 输入参数
|
||||
|
||||
| 参数名称 | 类型 | 描述 |
|
||||
| --- | --- | --- |
|
||||
| `ip`(必选,路径) | String | 要查询的 IP,IPv4 或 IPv6 均可,例如 `/v1/location/106.224.145.147` |
|
||||
|
||||
> 路径中的 IP 不要带方括号。IPv6 形如 `/v1/location/2400:3200::1`。
|
||||
|
||||
## 3. 输出参数
|
||||
|
||||
与「获取客户端公网 IP 及位置」相同:顶层为「源名 → 该源结果」的字典,`ip` 字段回显被查询的地址。取值约定(未加载、出错、空字段、经纬度类型)也一致。
|
||||
|
||||
**非法 IP 是"看起来成功"的**:IP 传错时 HTTP 仍返回 `200`,但每个源会各自报错,形如:
|
||||
|
||||
```json
|
||||
{
|
||||
"ip": "not-an-ip",
|
||||
"ip2region": "error: parse ip not-an-ip: invalid ip address: not-an-ip",
|
||||
"maxmind_city": "error: ParseAddr(\"not-an-ip\"): unable to parse IP",
|
||||
"ip2location": { "country": "Invalid IP address.", "city": "Invalid IP address." },
|
||||
"ip2location_asn": { "asn": "Invalid IP address.", "as": "Invalid IP address." }
|
||||
}
|
||||
```
|
||||
|
||||
所以**判断成功与否要看字段内容,不能只看状态码**:字段是对象才有结论;是 `"error: ..."` 字符串或 `"Invalid IP address."` 就是没查到。建议调用前先自行校验 IP 格式。
|
||||
|
||||
## 4. 示例
|
||||
|
||||
### 4.1 cURL 查询指定 IP 的位置
|
||||
|
||||
```bash
|
||||
curl https://cn-jiangsu.api-ipw.wsmdn.top/v1/location/106.224.145.147
|
||||
|
||||
# IPv6 同样直接拼:curl https://cn-jiangsu.api-ipw.wsmdn.top/v1/location/2400:3200::1
|
||||
|
||||
# 经公共中间件转发(见 1.1):
|
||||
# curl https://middleware-1.api-ipw.wsmdn.top/v1/cn-jiangsu/location/106.224.145.147
|
||||
```
|
||||
|
||||
输出示例(节选,真实响应):
|
||||
|
||||
```json
|
||||
{
|
||||
"ip": "106.224.145.147",
|
||||
"ip2region": { "country": "中国", "administrative_area": "江西省", "city": "南昌市", "isp": "电信" },
|
||||
"ip2location": {
|
||||
"country": "China", "country_code": "CN", "administrative_area": "Jiangxi",
|
||||
"city": "Ji'an", "zipcode": "343000", "timezone": "+08:00",
|
||||
"latitude": "27.11716", "longitude": "114.97927"
|
||||
},
|
||||
"qqwry": { "country": "中国", "country_code": "CN", "administrative_area": "江西", "city": "吉安", "isp": "电信" },
|
||||
"geocn": { "country": "中国", "administrative_area": "江西省", "city": "南昌市", "division_code": "360100", "isp": "电信" },
|
||||
"maxmind_asn": { "asn": "AS4134", "org": "Chinanet" }
|
||||
}
|
||||
```
|
||||
|
||||
> 上面同一 IP 出现了**南昌 / 吉安**两种结论:这就是"多源并列、不做合并"的含义——
|
||||
> 各库口径与更新批次不同,写法也不统一(`江西省` / `Jiangxi`、`南昌市` / `Nanchang`)。
|
||||
> 想要单一结论请自行选源或做交叉投票。
|
||||
|
||||
### 4.2 Python
|
||||
|
||||
```python
|
||||
#!/usr/bin/python3
|
||||
|
||||
import requests
|
||||
|
||||
queryIP = '106.224.145.147'
|
||||
r = requests.get('https://cn-jiangsu.api-ipw.wsmdn.top/v1/location/' + queryIP)
|
||||
data = r.json()
|
||||
|
||||
qqwry = data.get('qqwry', {})
|
||||
if isinstance(qqwry, dict):
|
||||
print(qqwry.get('country'), qqwry.get('administrative_area'),
|
||||
qqwry.get('city'), qqwry.get('isp'))
|
||||
else:
|
||||
print('该源不可用:', qqwry)
|
||||
```
|
||||
|
||||
### 4.3 Golang
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
queryIP := "106.224.145.147"
|
||||
|
||||
resp, err := http.Get("https://cn-jiangsu.api-ipw.wsmdn.top/v1/location/" + queryIP)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
|
||||
var result map[string]json.RawMessage
|
||||
if err := json.Unmarshal(body, &result); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var loc struct {
|
||||
Country string `json:"country"`
|
||||
City string `json:"city"`
|
||||
Isp string `json:"isp"`
|
||||
}
|
||||
if err := json.Unmarshal(result["qqwry"], &loc); err != nil {
|
||||
fmt.Println("该源不可用,原始值:", string(result["qqwry"]))
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("%s %s %s\n", loc.Country, loc.City, loc.Isp)
|
||||
}
|
||||
```
|
||||
|
||||
## 5. 错误码
|
||||
|
||||
| 现象 | 说明 |
|
||||
| --- | --- |
|
||||
| 字段是 `"Invalid IP address."`(`ip2location` 系列) | 路径里的 IP 不合法。该库对非法输入仍返回对象,值里写明原因 |
|
||||
| 字段是 `"error: ... unable to parse IP"` | 同上,其它源对非法输入直接返回错误字符串 |
|
||||
| `404 page not found` | 该节点 `ipdb` 已关闭,`/v1/location/:ip` 未注册 |
|
||||
| `401` | 节点配了 `access-token` 但未携带正确的 `Authorization: Bearer <access-token>` |
|
||||
| 结果与常识不符 | 免费 IP 库本身有偏差;本项目是**多源并列**,可交叉比对,不保证单一源正确 |
|
||||
@@ -0,0 +1,228 @@
|
||||
# [API] 查询域名的 WHOIS 信息
|
||||
|
||||
## 1. 接口描述
|
||||
|
||||
> 该接口用于学习域名基础信息,请在中国法律许可范围内使用.
|
||||
|
||||
接口地址: `https://cn-jiangsu.api-ipw.wsmdn.top/v1/whois/<domain>`(公开实例,见 1.1)
|
||||
|
||||
请求方法:`GET`
|
||||
|
||||
用途:查询域名注册信息——注册局记录 + 注册商数据,结构化返回,同时附带原始文本。
|
||||
|
||||
本项目自有的查询流程(不是简单地把库调用包一层):
|
||||
|
||||
1. **先问 IANA**:用域名后缀查 `whois.iana.org`,拿到该后缀的注册局服务器(不猜、不硬编码后缀表);
|
||||
2. **只查注册局**:关闭 whois 库自带的转介链,避免被不可达的注册商服务器拖到超时;
|
||||
3. **补查注册商**:若注册局响应里给出注册商转介服务器(如 `.com` 的 thick 注册局),**限时**再查一次,把结果追加进 `raw`;这一步失败不影响已到手的注册局数据;
|
||||
4. **解析失败不算请求失败**:查询/解析的错误放进响应体的 `error` 字段,HTTP 状态码仍是 `200`。
|
||||
|
||||
其他特性:
|
||||
|
||||
- **结果缓存 5 分钟**。缓存键是**传入的原始字符串**,未做归一化:`QQ.com` 与 `qq.com` 各占一份。
|
||||
- **IPv4 / IPv6 双栈解析** whois 服务器地址(Happy Eyeballs,v6 延迟 150ms 起步),某一栈不通时另一栈仍可用。
|
||||
- **超时预算是分层的**:库单跳 6s(主路径 IANA + 注册局两跳),注册商转介补查另有 3s 总预算且失败即弃。
|
||||
- **入参不做归一化**:不剥 `www.`、不吃 `host:port`。要查的是"注册的那个域名"本身。
|
||||
- `QQ.COM`、`qq.com` 都可以(大小写不敏感,结果里 `domain` 统一大写);
|
||||
- `www.qq.com` 会去查这个**子域**,注册信息为空——不是接口坏了;
|
||||
- `qq.com:43` 不支持,返回 `whois: no whois server found for domain: qq.com:43`。
|
||||
- 免鉴权规则同所有 `/v1/*` 端点:节点配了 `access-token` 才需要 `Authorization: Bearer`。
|
||||
|
||||
### 1.1 公开实例
|
||||
|
||||
本项目对外开放了一个江苏节点,可以直接用它把本接口调通,**无需令牌**:
|
||||
|
||||
| 方式 | 地址 |
|
||||
| --- | --- |
|
||||
| 直连节点(推荐) | `https://cn-jiangsu.api-ipw.wsmdn.top/v1/whois/<domain>` |
|
||||
| 经中间件转发 | `https://middleware-1.api-ipw.wsmdn.top/v1/cn-jiangsu/whois/<domain>` |
|
||||
|
||||
两种写法都是「节点 / 接口 / 目标」三段:直连时端点本身就是节点,经中间件时多一段节点标识。
|
||||
中间件入口的 `/v1/` 前缀与 `/middleware/` 前缀等价,用哪个都行。
|
||||
|
||||
> 公共实例是**共享**的,调试与小流量接入没问题,请勿高频轮询、批量抓取,也不要拿它当线上服务的依赖。
|
||||
|
||||
### 1.2 还有别的节点 —— 拨测控制台
|
||||
|
||||
上面的江苏节点只是节点池里的一个。节点池的入口是拨测控制台 <https://boce.wsmdn.top>:
|
||||
登录后进「可用节点」页,能看到**全部已启用节点**的节点标识、归属地、归属池(定位 / 拨测)、
|
||||
协议栈与在线状态,每行都能一键复制调用前缀 —— 把上面那个中间件地址换成控制台给你的入口域名,
|
||||
再接上 `/v1/<节点标识>/` 就是完整前缀,**换节点只动中间那一段标识**。
|
||||
|
||||
比自己搭一套省事的地方:
|
||||
|
||||
- **节点现成** —— 名单里的节点都是已经部署好的,不用自己找机器、装程序、配隧道。
|
||||
- **入口现成** —— 统一走 HTTPS 转发,证书与反向代理不用自己操心。
|
||||
- **一套地址调所有节点** —— 换节点只改标识,接口路径、参数、返回结构都不变。
|
||||
- **池与栈标得很清楚** —— 定位类请求走定位池,拨测类走拨测池,两个池都有的节点两种都能接。
|
||||
- **名单会自己更新** —— 新接入的节点自动出现在列表里,不需要改代码。
|
||||
|
||||
用它调本接口(可直接粘贴执行):
|
||||
|
||||
```bash
|
||||
# 用列表里的江苏节点查一个域名
|
||||
curl https://middleware-1.api-ipw.wsmdn.top/v1/cn-jiangsu/whois/qq.com
|
||||
|
||||
# 换成别的节点:只改中间那一段标识
|
||||
curl https://middleware-1.api-ipw.wsmdn.top/v1/<节点标识>/whois/qq.com
|
||||
```
|
||||
|
||||
> 节点有上下线,**离线的节点调用会失败**(返回 `502`)——名单上标了在线状态,挑在线的用。
|
||||
|
||||
## 2. 输入参数
|
||||
|
||||
| 参数名称 | 类型 | 描述 |
|
||||
| --- | --- | --- |
|
||||
| `domain`(必选,路径) | String | 要查询的域名,例如 `/v1/whois/qq.com`。写注册域名本身,不要带子域 |
|
||||
|
||||
## 3. 输出参数
|
||||
|
||||
| 参数名称 | 类型 | 描述 |
|
||||
| --- | --- | --- |
|
||||
| `domain` | String | 归一化后的域名(**大写**,如 `QQ.COM`) |
|
||||
| `status` | Array \| null | EPP 状态码列表,如 `["clientTransferProhibited"]`;**没拿到时为 `null`**(不是空数组) |
|
||||
| `registrar.name` | String | 注册商名称 |
|
||||
| `registrar.ianaId` | String | 注册商 IANA ID |
|
||||
| `registrant` | Object | 注册人:`name`/`org`/`phone`/`email`/`province`/`contactUri` |
|
||||
| `technical` | Object | 技术联系人,字段同上 |
|
||||
| `abuseContact` | Object | 滥用投诉联系人,字段同上 |
|
||||
| `dates.registration` | String | 注册时间(RFC3339,缺失为 `""`) |
|
||||
| `dates.expiration` | String | 到期时间(RFC3339,缺失为 `""`) |
|
||||
| `dates.lastChanged` | String | 最后变更时间(RFC3339,缺失为 `""`) |
|
||||
| `nameservers` | Array | NS 列表(保留注册局原始大小写) |
|
||||
| `whoisServer` | String | 最终实际查询的 whois 服务器;未找到后缀对应服务器时为空串 |
|
||||
| `raw` | String | 注册局响应原文(含补查到的注册商内容),排查用 |
|
||||
| `error` | String | 查询/解析错误信息;成功时为空串 `""` |
|
||||
|
||||
判定要点:
|
||||
|
||||
- **字段缺失一律返回空串,不会省略键**;所以判断"有没有数据"要看内容而不是键是否存在。
|
||||
- `status` 为 `null` 与 `[]` 含义不同:前者是**没取到**,后者是取到了但确实没有状态。
|
||||
- 隐私保护(GDPR、注册商隐私服务)会让 `registrant` / `technical` 的字段为空或提示串(例如要求到注册商网页填表才能看邮箱),这是上游数据的样子,不是解析失败。
|
||||
- 想拿"能不能注册 / 什么时候释放",以 `dates.expiration` 与 `status`(是否 `pendingDelete`、`redemptionPeriod`)为准。
|
||||
|
||||
## 4. 示例
|
||||
|
||||
### 4.1 cURL 查询域名注册信息
|
||||
|
||||
```bash
|
||||
curl https://cn-jiangsu.api-ipw.wsmdn.top/v1/whois/qq.com
|
||||
|
||||
# 经公共中间件转发(见 1.1):
|
||||
# curl https://middleware-1.api-ipw.wsmdn.top/v1/cn-jiangsu/whois/qq.com
|
||||
```
|
||||
|
||||
输出示例(真实响应,节选):
|
||||
|
||||
```json
|
||||
{
|
||||
"domain": "QQ.COM",
|
||||
"status": [
|
||||
"clientDeleteProhibited", "clientTransferProhibited", "clientUpdateProhibited",
|
||||
"serverDeleteProhibited", "serverTransferProhibited", "serverUpdateProhibited"
|
||||
],
|
||||
"registrar": { "name": "MarkMonitor Information Technology (Shanghai) Co., Ltd.", "ianaId": "3838" },
|
||||
"registrant": {
|
||||
"name": "",
|
||||
"org": "深圳市腾讯计算机系统有限公司",
|
||||
"phone": "",
|
||||
"email": "select request email form at https://domains.markmonitor.com/whois/qq.com",
|
||||
"province": "",
|
||||
"contactUri": ""
|
||||
},
|
||||
"abuseContact": { "name": "", "org": "", "phone": "+1.2086851750", "email": "abusecomplaints@markmonitor.com" },
|
||||
"dates": {
|
||||
"registration": "1995-05-04T04:00:00Z",
|
||||
"expiration": "2034-07-27T02:09:19Z",
|
||||
"lastChanged": "2026-09-23T10:00:17Z"
|
||||
},
|
||||
"nameservers": ["ns1.qq.com", "ns2.qq.com", "ns3.qq.com", "ns4.qq.com"],
|
||||
"whoisServer": "whois.markmonitor.com",
|
||||
"error": ""
|
||||
}
|
||||
```
|
||||
|
||||
### 4.2 Python
|
||||
|
||||
```python
|
||||
#!/usr/bin/python3
|
||||
|
||||
import requests
|
||||
|
||||
queryDomain = 'qq.com'
|
||||
r = requests.get('https://cn-jiangsu.api-ipw.wsmdn.top/v1/whois/' + queryDomain)
|
||||
data = r.json()
|
||||
|
||||
if data.get('error'):
|
||||
print('查询出错:', data['error'])
|
||||
else:
|
||||
print('Domain Name: %s' % data['domain'])
|
||||
print('Status: %s' % data.get('status'))
|
||||
print('Registrar: %s' % data['registrar']['name'])
|
||||
print('Registration Time: %s' % data['dates']['registration'])
|
||||
print('Expiration Time: %s' % data['dates']['expiration'])
|
||||
```
|
||||
|
||||
### 4.3 Golang
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
queryDomain := "qq.com"
|
||||
|
||||
resp, err := http.Get("https://cn-jiangsu.api-ipw.wsmdn.top/v1/whois/" + queryDomain)
|
||||
if err != nil {
|
||||
fmt.Println("请检查网络")
|
||||
panic(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
|
||||
var result struct {
|
||||
Domain string `json:"domain"`
|
||||
Status []string `json:"status"`
|
||||
Nameservers []string `json:"nameservers"`
|
||||
Dates struct {
|
||||
Registration string `json:"registration"`
|
||||
Expiration string `json:"expiration"`
|
||||
} `json:"dates"`
|
||||
Registrar struct {
|
||||
Name string `json:"name"`
|
||||
} `json:"registrar"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
if err := json.Unmarshal(body, &result); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if result.Error != "" {
|
||||
fmt.Println("查询出错:", result.Error)
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Domain: %s\n", result.Domain)
|
||||
fmt.Printf("Registrar: %s\n", result.Registrar.Name)
|
||||
fmt.Printf("Expiration: %s\n", result.Dates.Expiration)
|
||||
}
|
||||
```
|
||||
|
||||
## 5. 错误码
|
||||
|
||||
| 现象 | 原因与处理 |
|
||||
| --- | --- |
|
||||
| `400 {"error":"Domain parameter is required"}` | 路径里没有域名 |
|
||||
| `401` | 节点配了 `access-token` 而未携带正确的 `Authorization: Bearer <access-token>` |
|
||||
| `500 {"error":"..."}` | 上游查询异常(网络不可达等),可稍后重试 |
|
||||
| `200` 且 `error` 为 `whois: no whois server found for domain: xxx` | 该后缀**没有 whois 服务器**(国家后缀常见)或不支持。换用该后缀的注册局查询入口 |
|
||||
| `200` 且各字段全空、`status` 为 `null` | 域名格式不合法(如 `not_a_domain`),IANA 查不到对应后缀;或传了子域(如 `www.qq.com`),因注册信息不在子域上故为空 |
|
||||
| `200` 但 `registrant`/`technical` 为空或提示串 | 上游做了隐私保护;`raw` 里能看到原文措辞 |
|
||||
| 改了域名的注册信息但查询结果是旧的 | 命中 5 分钟缓存;等待或用另一个节点查(缓存是**节点本地**的) |
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
原版支持 IPv6 本地网络(宽带)开启验证、IPv6 网站开启检测、IPv6 TCPing 延迟测试、IPv6 网站测速、IPv6地址查询、IPv6 DNS解析。
|
||||
镜像站点由于开发者财力限制,测速、TCPing、DNS等需要多地测速节点的功能无重现计划
|
||||
本文档并不一定完全和ipw.cn文档相同,部分文段有删改
|
||||
本文档并不一定完全和原版文档相同,部分文段有删改
|
||||
|
||||
## 本地网络(宽带)开启IPv6验证
|
||||
工具地址:[IPv6 地址查询](https://ipw.wsmdn.top/)。
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
# <span style="background-color: #b95442;color: white;font-size: 0.43em;border-radius: 5px;padding: 2px 5px;">转载</span> JS:检查网络是IPv4还是IPv6
|
||||
|
||||
> 仅供个人测试学习之用,本站不对稳定性负责。
|
||||
|
||||
通过一段 js 代码可以显示用户请求网络是 IPv4 访问优先,还是 IPv6 访问优先。
|
||||
|
||||
## 效果
|
||||
|
||||
> 如果你没有 IPv6 的网络环境,可以先用手机流量访问该页面。
|
||||
|
||||
## 代码
|
||||
|
||||
```html
|
||||
<template>
|
||||
<div>
|
||||
<a href='https://nipw.cn' target='_blank'> <b>访客IP:</b> {{IP}},您的网络 {{IPVersion}} 访问优先</a>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Axios from "axios";
|
||||
|
||||
export default {
|
||||
name: "Home",
|
||||
data(){
|
||||
return{
|
||||
IP: "",
|
||||
IPVersion: "",
|
||||
}
|
||||
},
|
||||
headers:
|
||||
{
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Access-Control-Allow-Origin': "*"
|
||||
},
|
||||
|
||||
methods:{
|
||||
getData(){
|
||||
var that=this
|
||||
// 双栈接口:按本次请求实际走的协议,返回纯文本的 IPv4 或 IPv6 地址
|
||||
var api = "https://test.wsmdn.top";
|
||||
|
||||
Axios.get(api)
|
||||
.then(function (res) {
|
||||
// handle success
|
||||
console.log(res.data);
|
||||
var ip = String(res.data).trim();
|
||||
console.log(ip);
|
||||
that.IP = ip
|
||||
// 返回的地址含冒号即 IPv6,否则为 IPv4
|
||||
that.IPVersion = ip.indexOf(':') > -1 ? "IPv6" : "IPv4"
|
||||
console.log(that.IPVersion);
|
||||
})
|
||||
.catch(function (error) {
|
||||
// handle error
|
||||
console.log(error);
|
||||
})
|
||||
.then(function () {
|
||||
// always executed
|
||||
});
|
||||
},
|
||||
},
|
||||
mounted(){
|
||||
this.getData();
|
||||
},
|
||||
}
|
||||
</script>
|
||||
```
|
||||
@@ -35,7 +35,7 @@
|
||||
查看 Response Header 来确认服务器支持的 HTTP 的版本。
|
||||
|
||||
```
|
||||
$ curl -I https://ipw.cn
|
||||
$ curl -I https://nipw.cn
|
||||
HTTP/2 200
|
||||
server: nginx
|
||||
content-type: text/html
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# <span style="background-color: #b95442;color: white;font-size: 0.43em;border-radius: 5px;padding: 2px 5px;">转载</span> 网站如何开启 TLS
|
||||
|
||||
## TLS是什么?
|
||||
|
||||
[RFC 8446: The Transport Layer Security (TLS) Protocol Version 1.3](https://datatracker.ietf.org/doc/html/rfc8446)
|
||||
|
||||
TLS allows client/server applications to communicate over the Internet in a way that is designed to prevent eavesdropping, tampering, and message forgery.
|
||||
|
||||
### Major Differences from TLS 1.2
|
||||
|
||||
## Wireshark 抓包分析
|
||||
|
||||
### TCP 三次握手
|
||||
|
||||
- SYN 
|
||||
- SYN ACK 
|
||||
- ACK 
|
||||
|
||||
### TLS 协商
|
||||
|
||||
以 TLS 1.3 为例
|
||||
|
||||
- Client Hello 
|
||||
- Server Hello, Change Cipher Spec, Encrypted Extensions 
|
||||
- Certificate, Certificate Verify, Finished 
|
||||
- Change Cipher Spec, Finished 
|
||||
@@ -12,7 +12,7 @@
|
||||
- 禁用 IPv6 本地网络
|
||||
```sh
|
||||
# 验证是否可以访问 IPv6 网络
|
||||
$ curl 6.ipw.cn
|
||||
$ curl 6.wsmdn.top
|
||||
2408:824c:200::2b8b:336f:cc9c
|
||||
|
||||
# 找到网络设备的名字,这里用的是 Wi-Fi (因为 macbook 用的是无线网络访问,即 Wi-Fi)
|
||||
@@ -25,12 +25,12 @@ Bluetooth PAN
|
||||
$ networksetup -setv6off Wi-Fi
|
||||
|
||||
# 请求 IPv4/IPv6 双栈网络,返回 IPv4 地址,证明 IPv4 访问优先。
|
||||
$ curl test.ipw.cn
|
||||
$ curl test.wsmdn.top
|
||||
159.75.190.197
|
||||
|
||||
# 访问 IPv6 网络失败
|
||||
$ curl 6.ipw.cn
|
||||
curl: (6) Could not resolve host: 6.ipw.cn
|
||||
$ curl 6.wsmdn.top
|
||||
curl: (6) Could not resolve host: 6.wsmdn.top
|
||||
```
|
||||
- 启用 IPv6 本地网络
|
||||
```sh
|
||||
@@ -38,7 +38,7 @@ curl: (6) Could not resolve host: 6.ipw.cn
|
||||
$ networksetup -setv6automatic Wi-Fi
|
||||
|
||||
# 验证本地 IPv6 网络访问是否成功
|
||||
$ curl test.ipw.cn
|
||||
$ curl test.wsmdn.top
|
||||
2408:824c:200::2b8b:336f:cc9c
|
||||
```
|
||||
## Window10 禁用或启用 IPv6 本地网络
|
||||
@@ -55,7 +55,7 @@ WLAN Internet 协议版本 6 (TCP/IPv6)
|
||||
以太网 Internet 协议版本 6 (TCP/IPv6) ms_tcpip6 True
|
||||
|
||||
# 验证本地 IPv6 网络是否访问成功
|
||||
PS C:\WINDOWS\system32> curl 6.ipw.cn
|
||||
PS C:\WINDOWS\system32> curl 6.wsmdn.top
|
||||
Content : 2408:824c:200::2b8b:336f:cc9c
|
||||
|
||||
# 禁用 WLAN 设备的本地 IPv6 网络(因为笔记本用的是 无线,即 WLAN)
|
||||
@@ -70,10 +70,10 @@ WLAN Internet 协议版本 6 (TCP/IPv6)
|
||||
以太网 Internet 协议版本 6 (TCP/IPv6) ms_tcpip6 True
|
||||
|
||||
# 无法访问 IPv6 网络
|
||||
PS C:\WINDOWS\system32> curl 6.ipw.cn
|
||||
PS C:\WINDOWS\system32> curl 6.wsmdn.top
|
||||
curl : 无法连接到远程服务器
|
||||
|
||||
PS C:\WINDOWS\system32> curl 4.ipw.cn
|
||||
PS C:\WINDOWS\system32> curl 4.wsmdn.top
|
||||
Content : 159.75.190.197
|
||||
```
|
||||
- 启用 IPv6 本地网络
|
||||
@@ -82,7 +82,7 @@ Content : 159.75.190.197
|
||||
PS C:\WINDOWS\system32> Enable-NetAdapterBinding -Name "WLAN" -ComponentID ms_tcpip6
|
||||
|
||||
# 验证 IPv6 网络是否访问成功
|
||||
PS C:\WINDOWS\system32> curl 6.ipw.cn
|
||||
PS C:\WINDOWS\system32> curl 6.wsmdn.top
|
||||
|
||||
Content : 2408:824c:200::2b8b:336f:cc9c
|
||||
```
|
||||
@@ -97,15 +97,15 @@ Content : 2408:824c:200::2b8b:336f:cc9c
|
||||
$ networksetup -setv4off Wi-Fi
|
||||
|
||||
# 访问 IPv4 网络失败
|
||||
$ curl 4.ipw.cn
|
||||
curl: (6) Could not resolve host: 4.ipw.cn
|
||||
$ curl 4.wsmdn.top
|
||||
curl: (6) Could not resolve host: 4.wsmdn.top
|
||||
```
|
||||
|
||||
- 启用 IPv4 本地网络
|
||||
```sh
|
||||
$ networksetup -setdhcp Wi-Fi
|
||||
|
||||
$ curl 4.ipw.cn
|
||||
$ curl 4.wsmdn.top
|
||||
159.75.190.197
|
||||
```
|
||||
### Window10 禁用/启用IPv4本地网络
|
||||
@@ -115,13 +115,13 @@ $ curl 4.ipw.cn
|
||||
```sh
|
||||
PS C:\WINDOWS\system32> Disable-NetAdapterBinding -Name "WLAN" -ComponentID ms_tcpip
|
||||
|
||||
PS C:\WINDOWS\system32> curl 4.ipw.cn
|
||||
PS C:\WINDOWS\system32> curl 4.wsmdn.top
|
||||
curl : 无法连接到远程服务器
|
||||
```
|
||||
- 启用 IPv4 本地网络
|
||||
```sh
|
||||
PS C:\WINDOWS\system32> Enable-NetAdapterBinding -Name "WLAN" -ComponentID ms_tcpip
|
||||
|
||||
PS C:\WINDOWS\system32> curl 4.ipw.cn
|
||||
PS C:\WINDOWS\system32> curl 4.wsmdn.top
|
||||
159.75.190.197
|
||||
```
|
||||
@@ -0,0 +1,218 @@
|
||||
# <span style="background-color: #b95442;color: white;font-size: 0.43em;border-radius: 5px;padding: 2px 5px;">转载</span> Python/Golang获取 IPv4 和 IPv6 地址
|
||||
|
||||
> 本站是个人站点,用于作者实战学习前端和后台知识,请勿用于商业用途,仅供个人测试学习之用,请遵守中国法律法规
|
||||
|
||||
通过 Python/Golang 获取公网 IPv4 和 IPv6 地址,还可以返回是 IPv4 还是 IPv6 访问优先。
|
||||
|
||||
## 1. Python/Golang获取 IPv4 地址
|
||||
|
||||
### 1.1 Python 获取本机公网IPv4地址
|
||||
|
||||
- 输入示例
|
||||
|
||||
```python
|
||||
#!/usr/bin/python3
|
||||
|
||||
import requests
|
||||
|
||||
# 获取 IPv4 地址接口; https://4.wsmdn.top
|
||||
r = requests.get('https://4.wsmdn.top')
|
||||
|
||||
clientIP = r.text
|
||||
|
||||
print(clientIP)
|
||||
```
|
||||
|
||||
- 输出示例
|
||||
|
||||
```
|
||||
106.224.145.147
|
||||
```
|
||||
|
||||
### 1.2 Golang 获取本机公网IPv4 地址
|
||||
|
||||
- 输入示例
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// 获取 IPv4 地址接口; https://4.wsmdn.top
|
||||
responseClient, errClient := http.Get("https://4.wsmdn.top")
|
||||
|
||||
if errClient != nil {
|
||||
fmt.Printf("获取外网 IP 失败,请检查网络\n")
|
||||
panic(errClient)
|
||||
}
|
||||
defer responseClient.Body.Close()
|
||||
|
||||
// 获取 http response 的 body
|
||||
body, _ := ioutil.ReadAll(responseClient.Body)
|
||||
clientIP := string(body)
|
||||
|
||||
print(clientIP)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
- 输出示例
|
||||
|
||||
```
|
||||
106.224.145.147
|
||||
```
|
||||
|
||||
## 2. Python/Golang获取 IPv6 地址
|
||||
|
||||
### 2.1 Python 获取本机公网IPv6地址
|
||||
|
||||
- 输入示例
|
||||
|
||||
```python
|
||||
#!/usr/bin/python3
|
||||
|
||||
import requests
|
||||
|
||||
r = requests.get('https://6.wsmdn.top')
|
||||
|
||||
clientIP = r.text
|
||||
|
||||
print(clientIP)
|
||||
```
|
||||
|
||||
- 输出示例
|
||||
|
||||
```
|
||||
2408:824c:200::2b8b:336f:cc9c
|
||||
```
|
||||
|
||||
### 2.2 Golang 获取本机公网IPv6地址
|
||||
|
||||
- 输入示例
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
responseClient, errClient := http.Get("https://6.wsmdn.top")
|
||||
|
||||
if errClient != nil {
|
||||
fmt.Printf("获取外网 IP 失败,请检查网络\n")
|
||||
panic(errClient)
|
||||
}
|
||||
defer responseClient.Body.Close()
|
||||
|
||||
// 获取 http response 的 body
|
||||
body, _ := ioutil.ReadAll(responseClient.Body)
|
||||
clientIP := string(body)
|
||||
|
||||
print(clientIP)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
- 输出示例
|
||||
|
||||
```
|
||||
2408:824c:200::2b8b:336f:cc9c
|
||||
```
|
||||
|
||||
## 3. 测试网络是IPv4还是IPv6访问优先
|
||||
|
||||
### 3.1 Python 测试网络是IPv4还是IPv6访问优先
|
||||
|
||||
- 输入示例
|
||||
|
||||
```python
|
||||
#!/usr/bin/python3
|
||||
|
||||
import requests
|
||||
|
||||
## HTTP GET,返回的是纯文本地址
|
||||
r = requests.get('https://test.wsmdn.top')
|
||||
|
||||
IP = r.text.strip()
|
||||
|
||||
## 返回的地址含冒号即 IPv6,否则为 IPv4
|
||||
IPVersion = 'IPv6' if ':' in IP else 'IPv4'
|
||||
|
||||
## 打印
|
||||
print('IP:',IP)
|
||||
print('IPVersion:',IPVersion)
|
||||
```
|
||||
|
||||
- 输出示例
|
||||
|
||||
```bash
|
||||
## 返回示例1(IPv4 访问优先)
|
||||
IP: 106.224.145.147
|
||||
IPVersion: IPv4
|
||||
|
||||
## 返回示例2(IPv6 访问优先)
|
||||
IP: 2408:824c:200::2b8b:336f:cc9c
|
||||
IPVersion: IPv6
|
||||
```
|
||||
|
||||
### 3.2 Golang 测试网络是IPv4还是IPv6访问优先
|
||||
|
||||
- 输入示例
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
responseClient, errClient := http.Get("https://test.wsmdn.top") // 获取外网 IP
|
||||
if errClient != nil {
|
||||
fmt.Printf("获取外网 IP 失败,请检查网络\n")
|
||||
panic(errClient)
|
||||
}
|
||||
// 程序在使用完 response 后必须关闭 response 的主体。
|
||||
defer responseClient.Body.Close()
|
||||
|
||||
body, _ := ioutil.ReadAll(responseClient.Body)
|
||||
|
||||
IP := strings.TrimSpace(string(body))
|
||||
|
||||
// 返回的地址含冒号即 IPv6,否则为 IPv4
|
||||
IPVersion := "IPv4"
|
||||
if strings.Contains(IP, ":") {
|
||||
IPVersion = "IPv6"
|
||||
}
|
||||
|
||||
fmt.Printf("IP: %s\n", IP)
|
||||
fmt.Printf("IPVersion: %s\n", IPVersion)
|
||||
}
|
||||
```
|
||||
|
||||
- 输出示例
|
||||
|
||||
```bash
|
||||
## 返回示例1(IPv4 访问优先)
|
||||
IP: 106.224.145.147
|
||||
IPVersion: IPv4
|
||||
|
||||
## 返回示例2(IPv6 访问优先)
|
||||
IP: 2408:824c:200::2b8b:336f:cc9c
|
||||
IPVersion: IPv6
|
||||
```
|
||||
@@ -0,0 +1,25 @@
|
||||
# <span style="background-color: #b95442;color: white;font-size: 0.43em;border-radius: 5px;padding: 2px 5px;">转载</span> DNS解析流程
|
||||
|
||||
## SRV 记录
|
||||
|
||||
SRV 记录:找到要添加 SRV 记录的位置,然后输入:
|
||||
|
||||
端口 协议 名称 服务 优先级 权重 目标 443 _tcp @ _autodiscover 100 1 autodiscover.secureserver.net
|
||||
|
||||

|
||||
|
||||
### 用途
|
||||
|
||||
SRV记录,全称为服务定位(Service Location)记录,是一种在DNS(域名系统)中指定服务位置的记录。它允许用户不仅可以通过域名找到一个服务的地址,还可以找到该服务在特定主机上运行的端口号以及该服务的一些额外信息。SRV记录在多种网络服务中起着关键作用,尤其是在需要定位特定类型服务的应用场景中,如电子邮件、即时通讯、VoIP(Voice over Internet Protocol)等。
|
||||
|
||||
根据您提供的信息,我们可以详细解读这条SRV记录的各个组成部分及其用途:
|
||||
|
||||
- **端口(Port):**`443`。这是服务监听的端口号。在这个例子中,端口443通常用于HTTPS服务,表示这是一个通过安全的方式提供服务的端口。
|
||||
- **协议(Protocol):**`_tcp`。这指定了服务使用的协议类型。在这里,`_tcp`表示该服务使用TCP(传输控制协议)进行通信。SRV记录中的协议通常以`_`开头。
|
||||
- **名称(Name):**`@`。这通常表示当前域,即将这条SRV记录应用于整个域。有时,这里可以指定子域或特定主机。
|
||||
- **服务(Service):**`_autodiscover`。这指定了服务的类型。在这个例子中,`_autodiscover`服务通常与电子邮件相关,用于自动发现邮件服务器的配置信息,使得用户能够仅通过电子邮件地址和密码自动配置他们的邮件客户端。
|
||||
- **优先级(Priority):**`100`。这个数字表示了多个SRV记录之间的优先级。数字越小,优先级越高。在有多个记录指向不同服务器的情况下,客户端会首先尝试优先级最高的服务器。
|
||||
- **权重(Weight):**`1`。当有多个具有相同优先级的SRV记录时,权重决定了这些记录的相对处理顺序。权重越高,该服务器被选中的可能性就越大。权重用于在具有相同优先级的服务器之间分配负载。
|
||||
- **目标(Target):**`autodiscover.secureserver.net`。这是提供服务的服务器的域名。客户端将使用这个地址来访问服务。
|
||||
|
||||
总的来说,这条SRV记录的用途是指导客户端如何找到并连接到提供`_autodiscover`服务的服务器。这对于自动配置电子邮件客户端尤其重要,因为它简化了用户设置邮箱的过程,使用户无需手动输入服务器地址和端口信息。
|
||||
@@ -86,13 +86,13 @@ IPv6 网络开启成功后,我们需要验证下是否真正开启成功。
|
||||
>该站点仅支持 IPv6 网络访问,IPv4 网络无法访问。
|
||||
|
||||
```json
|
||||
// https://6.ipw.cn/
|
||||
// https://6.wsmdn.dpdns.org/
|
||||
240e:3b7:3b7:3b7::3b7
|
||||
```
|
||||
打开 [https://test.wsmdn.dpdns.org/](https://test.wsmdn.dpdns.org/),**如果返回的 IPVersion 字段为 IPv6,则当前网络 IPv6 访问优先,**如果返回的 IPVersion 字段为 IPv4,则当前网络 IPv4 访问优先。
|
||||
打开 [https://test.wsmdn.dpdns.org/](https://test.wsmdn.dpdns.org/),**如果返回的是 IPv6 地址,则当前网络 IPv6 访问优先,**如果返回的是 IPv4 地址,则当前网络 IPv4 访问优先。
|
||||
>[test.wsmdn.dpdns.org](https://test.wsmdn.dpdns.org/) 支持 IPv4/IPv6双栈访问。
|
||||
```json
|
||||
// https://test.ipw.cn/
|
||||
// https://test.wsmdn.dpdns.org/
|
||||
240e:3b7:3b7:3b7::3b7
|
||||
```
|
||||
|
||||
@@ -197,7 +197,7 @@ PING6(56=40+8+8 bytes) --> 2402:4e00:40:40::2:331
|
||||
16 bytes from 2402:4e00:40:40::2:331, icmp_seq=1 hlim=53 time=16.393 ms
|
||||
16 bytes from 2402:4e00:40:40::2:331, icmp_seq=2 hlim=53 time=14.736 ms
|
||||
16 bytes from 2402:4e00:40:40::2:331, icmp_seq=3 hlim=53 time=14.062 ms
|
||||
--- ipw.cn ping6 statistics ---
|
||||
--- ipw.wsmdn.top ping6 statistics ---
|
||||
4 packets transmitted, 4 packets received, 0.0% packet loss
|
||||
round-trip min/avg/max/std-dev = 14.062/15.811/18.052/1.547 ms
|
||||
```
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
访问 `http://[2402:4e00:1013:e500:0:9671:f018:4947]` ,会返回本机 IPv6 IP地址。
|
||||
|
||||

|
||||

|
||||
|
||||
如果有端口,在 IP 地址后面添加端口,比如
|
||||
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
# <span style="background-color: #b95442;color: white;font-size: 0.43em;border-radius: 5px;padding: 2px 5px;">转载</span> Wireshare 分析 IPv6 包
|
||||
|
||||
>[WARNING]
|
||||
>本文的部分URL已失效,但为了保留原文,未作修改
|
||||
|
||||
## 场景
|
||||
|
||||
执行 `curl 6.ipw.cn`,查看本机的 IPv6 通信包。
|
||||
执行 `curl 6.wsmdn.top`,查看本机的 IPv6 通信包。
|
||||
|
||||
> 如果有 DNS 缓存,可以执行 `sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache` 清理缓存
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
### 域名生命周期流程图
|
||||
|
||||

|
||||

|
||||
### 域名状态详解
|
||||
|
||||
| 状态 | 描述 | 特征/影响 |
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
import { brotliCompressSync, gzipSync, constants } from 'node:zlib'
|
||||
import type { NitroApp } from 'nitro/types'
|
||||
|
||||
/**
|
||||
* SSR HTML 压缩。
|
||||
*
|
||||
* ## 为什么要压
|
||||
*
|
||||
* nitro 不压 SSR 响应体(静态资源另有 compressPublicAssets 预压缩),
|
||||
* 本地直连 / Lighthouse 测到的 HTML 就是裸传的。生产链路前面有 EdgeOne 兜底,
|
||||
* 但源站自己压是标准做法,也让本地测量贴近线上。
|
||||
*
|
||||
* 只压 SSR 渲染出的 text/html:body 是字符串、体积 > 1KB、对方 Accept-Encoding
|
||||
* 支持才压,按客户端优先级选 br(brotli)否则 gzip。
|
||||
*
|
||||
* ## 为什么必须显式指定 brotli quality = 4(别删这行)
|
||||
*
|
||||
* `brotliCompressSync` 不带 params 时默认 **quality 11**,那是给「离线压一次、
|
||||
* 反复复用」准备的(压一次存盘,读一万次)。SSR 是**每请求现压**:
|
||||
*
|
||||
* quality 33KB HTML 68KB HTML
|
||||
* 11 123ms / 7.2KB 169ms / 11.0KB
|
||||
* 6 4ms / 7.8KB 5ms / 12.2KB
|
||||
* 4 2ms / 8.6KB 3ms / 13.5KB
|
||||
*
|
||||
* Node 是单线程,这段同步压缩**全程阻塞事件循环,直接进 TTFB**。
|
||||
* 首页 TTFB 实测:q11 时 225~260ms,改 q4 后 55~105ms —— 差的就是这 120~170ms。
|
||||
* q4 只多 2.5KB,在 1.6Mbps 上是 12ms,换回 166ms,净赚。
|
||||
*
|
||||
* 教训:凡「每请求现压」的同步压缩都要显式指定质量,别吃库默认值。
|
||||
*/
|
||||
export default defineNitroPlugin((nitroApp: NitroApp) => {
|
||||
nitroApp.hooks.hook('render:response', (response, { event }) => {
|
||||
const headers = (response.headers ??= {})
|
||||
const type = String(
|
||||
headers['content-type'] ?? event.node.res.getHeader('content-type') ?? '',
|
||||
)
|
||||
if (!type.includes('text/html')) return
|
||||
if (typeof response.body !== 'string' || response.body.length < 1024) return
|
||||
if (headers['content-encoding']) return // 已有编码(异常路径),不叠加
|
||||
|
||||
// —— modulepreload 降优先级(2026-10-04 实测,mobile LH 三档对比后选定 low)——
|
||||
// entry 的 26 个静态依赖 chunk 默认 High 优先级,和 4 个 render-blocking CSS 一起
|
||||
// 排队(本地 H1 只有 6 个连接),CSS 被挤到后面 ⇒ Lantern 模拟 FCP 2345ms。
|
||||
// 加 fetchpriority="low" 后 CSS 先行:FCP 2345→1109(-1236ms,首次过 1800 满分线),
|
||||
// desktop 三轮全 100。代价是 JS 下载推迟 → hydration 落到 FCP 之后,TBT 86→213。
|
||||
// 三档实测(mobile perf):无 fp 94/95,medium 92/93(medium 仍挤 CSS,FCP 2253,
|
||||
// 收益尽失),low 94/95 —— low 总分最优。
|
||||
// TBT 的 213 是这项改动的全部代价:FCP 提前后,原本在 FCP 前不计账的 hydration
|
||||
// 长任务进了 TBT 窗口(FCP 每提前 ~500ms,TBT 约 +55,两者在当前架构下互斥)。
|
||||
if (response.body.includes('rel="modulepreload"')) {
|
||||
response.body = response.body.replaceAll(
|
||||
'rel="modulepreload"',
|
||||
'rel="modulepreload" fetchpriority="low"',
|
||||
)
|
||||
}
|
||||
|
||||
const accept = String(event.node.req.headers['accept-encoding'] ?? '')
|
||||
let encoding: 'br' | 'gzip'
|
||||
if (/\bbr\b/.test(accept)) {
|
||||
response.body = brotliCompressSync(Buffer.from(response.body), {
|
||||
params: { [constants.BROTLI_PARAM_QUALITY]: 4 },
|
||||
})
|
||||
encoding = 'br'
|
||||
} else if (/\bgzip\b/.test(accept)) {
|
||||
response.body = gzipSync(Buffer.from(response.body))
|
||||
encoding = 'gzip'
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
headers['content-encoding'] = encoding
|
||||
// 体积变了,content-length 必须跟着改,否则连接会被截断/挂起
|
||||
headers['content-length'] = String((response.body as Buffer).length)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,14 @@
|
||||
// /ipv6 是历史对外地址(ipw.cn 同款 ?ip= 参数曾大量被外部引用,不能 404)。
|
||||
// 原实现是一个客户端 onMounted 跳转的空壳页:无 title、无 description、无 h1,
|
||||
// 被 SEO 审计判为「缺少 H1」页,还以低质量页面的身份混进 sitemap。
|
||||
// 这里改为服务端 301:爬虫直接拿到重定向,HTML 空壳页不复存在,
|
||||
// query 原样带到 /location(?ip=xxx → /location?ip=xxx)。
|
||||
export default defineEventHandler((event) => {
|
||||
const query = getQuery(event)
|
||||
const qs = new URLSearchParams(
|
||||
Object.entries(query).flatMap(([k, v]) =>
|
||||
v === undefined ? [] : Array.isArray(v) ? v.map((item) => [k, String(item)] as [string, string]) : [[k, String(v)] as [string, string]]
|
||||
)
|
||||
).toString()
|
||||
return sendRedirect(event, '/location' + (qs ? `?${qs}` : ''), 301)
|
||||
})
|
||||
@@ -41,10 +41,20 @@ export default defineEventHandler(async (event) => {
|
||||
throw createError({ statusCode: 429, statusMessage: 'Too Many Requests' })
|
||||
}
|
||||
|
||||
const slugString: string = event.context.params?.slug as any
|
||||
if (!slugString) {
|
||||
const rawSlug: string = event.context.params?.slug as any
|
||||
if (!rawSlug) {
|
||||
throw createError({ statusCode: 400, statusMessage: 'Missing slug parameter' })
|
||||
}
|
||||
}
|
||||
// h3 出于路径安全不会把 %2F 解码回 '/',而 detail/ssl/speed 的目标 URL 恰恰依赖它
|
||||
// (前端 encodeURIComponent('https://x') → 'https%3A%2F%2Fx')。远程中间件(fiber)会解码,
|
||||
// 这里补齐同样的语义,否则内置中间件转发带协议头的拨测目标必然拼坏
|
||||
// (下游拿到 'https://https:%2F%2Fx')。畸形 % 序列解码失败时按原文处理。
|
||||
let slugString: string = rawSlug
|
||||
try {
|
||||
slugString = decodeURIComponent(rawSlug)
|
||||
} catch {
|
||||
// keep raw
|
||||
}
|
||||
// 将路径参数转为数组
|
||||
let slug: string[] = slugString ? slugString.split('/') : []
|
||||
console.debug('[middleware debug] raw slugString:', slugString, '| split:', slug)
|
||||
@@ -133,10 +143,17 @@ export default defineEventHandler(async (event) => {
|
||||
if (apiBaseUrl.slice(-1) != '/') {
|
||||
apiBaseUrl = `${apiBaseUrl}/`
|
||||
}
|
||||
data = await $fetch(`${apiBaseUrl}v1/${apiType}/${raw}`, {
|
||||
const queryString = new URLSearchParams(
|
||||
Object.entries(query).filter(([_, v]) => v !== undefined) as [string, string][]
|
||||
).toString()
|
||||
|
||||
data = await $fetch(`${apiBaseUrl}v1/${apiType}/${raw}${queryString ? '?' + queryString : ''}`, {
|
||||
method: 'GET',
|
||||
headers: authHeaders,
|
||||
timeout: 15_000,
|
||||
// 关闭 ofetch 内置重试:上游超时/5xx 时它会在同一节点立即重打一遍(retryDelay 默认 0,无退避),
|
||||
// 把 15s 超时变成 30s。重试统一由前端候选循环承担。
|
||||
retry: false,
|
||||
}).catch((error: any) => {
|
||||
console.error(`Error fetching from ${apiBaseUrl}:`, error)
|
||||
const errStatus = error?.status ?? error?.statusCode
|
||||
@@ -179,6 +196,7 @@ export default defineEventHandler(async (event) => {
|
||||
method: 'GET',
|
||||
headers: authHeaders,
|
||||
timeout: 30_000, // tcping/测速上游本身较慢,给更长超时
|
||||
retry: false, // 同上:不让 ofetch 把 30s 超时放大成 60s
|
||||
}).catch((error: any) => {
|
||||
console.error(`Error fetching from ${apiBaseUrl}:`, error)
|
||||
const errStatus = error?.status ?? error?.statusCode
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// IndexNow 提交的共享实现:server/api/indexnow.get.ts / indexnow.post.ts 与
|
||||
// scripts/indexnow-submit.mjs(CI 部署后一次性提交)三方语义保持一致。
|
||||
//
|
||||
// key 是「站点所有权凭证」而非机密:IndexNow 的校验方式就是抓取
|
||||
// https://nipw.cn/<key>.txt 并比对,所以 key 必须能公开访问(见 public/ 下的 key 文件)。
|
||||
// 放进 runtimeConfig 只是为了支持环境变量覆盖(NUXT_INDEXNOW_KEY),默认值与 key 文件一致。
|
||||
import { useRuntimeConfig } from '#imports'
|
||||
|
||||
const INDEXNOW_ENDPOINT = 'https://api.indexnow.org/IndexNow'
|
||||
|
||||
export interface IndexNowResult {
|
||||
submitted: number
|
||||
status: number
|
||||
body: string
|
||||
}
|
||||
|
||||
// 归一化 + 同域校验:只允许提交本站 URL(相对路径按 siteUrl 补全),
|
||||
// 防止提交端点被当作向 IndexNow 提交任意域名的跳板。
|
||||
export function normalizeIndexNowUrls(input: unknown[], siteUrl: string): string[] {
|
||||
const origin = new URL(siteUrl).origin
|
||||
const out = new Set<string>()
|
||||
for (const raw of input) {
|
||||
if (typeof raw !== 'string' || !raw) continue
|
||||
const abs = new URL(raw, siteUrl)
|
||||
if (abs.origin !== origin) continue
|
||||
out.add(abs.href)
|
||||
}
|
||||
return [...out]
|
||||
}
|
||||
|
||||
// 拉取 sitemap.xml 并抽出全部 <loc>(本站 sitemap 的 XML 很简单,正则足够且免依赖)
|
||||
export async function fetchSitemapUrls(siteUrl: string): Promise<string[]> {
|
||||
const res = await fetch(new URL('sitemap.xml', siteUrl).href)
|
||||
if (!res.ok) throw new Error(`sitemap fetch failed: ${res.status}`)
|
||||
const xml = await res.text()
|
||||
return [...xml.matchAll(/<loc>([^<]+)<\/loc>/g)].map(m => m[1].trim())
|
||||
}
|
||||
|
||||
export async function submitIndexNow(urls: string[], siteUrl: string): Promise<IndexNowResult> {
|
||||
const key = useRuntimeConfig().indexnowKey
|
||||
if (!key) throw new Error('indexnowKey is not configured')
|
||||
const res = await fetch(INDEXNOW_ENDPOINT, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json; charset=utf-8' },
|
||||
body: JSON.stringify({
|
||||
host: new URL(siteUrl).host,
|
||||
key,
|
||||
keyLocation: new URL(`/${key}.txt`, siteUrl).href,
|
||||
// IndexNow 单请求最多 1 万条 URL,超出截断(本站量级远够)
|
||||
urlList: urls.slice(0, 10_000),
|
||||
}),
|
||||
})
|
||||
const body = await res.text().catch(() => '')
|
||||
return { submitted: urls.length, status: res.status, body: body.slice(0, 200) }
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// WGS84 → GCJ-02(火星坐标)互转:国内地图底图(高德/腾讯)均为 GCJ-02 坐标系,
|
||||
// IP 库返回的经纬度是 WGS84,直接叠点会偏移 100~700 米,须先转换再打点。
|
||||
// 境外坐标原样返回(GCJ-02 仅在中国境内有偏移)。
|
||||
|
||||
const PI = Math.PI
|
||||
const A = 6378245 // 长半轴
|
||||
const EE = 0.00669342162296594323 // 偏心率平方
|
||||
|
||||
function outOfChina(lat: number, lng: number): boolean {
|
||||
return lng < 72.004 || lng > 137.8347 || lat < 0.8293 || lat > 55.8271
|
||||
}
|
||||
|
||||
function transformLat(x: number, y: number): number {
|
||||
let ret =
|
||||
-100 + 2 * x + 3 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x))
|
||||
ret += ((20 * Math.sin(6 * x * PI) + 20 * Math.sin(2 * x * PI)) * 2) / 3
|
||||
ret += ((20 * Math.sin(y * PI) + 40 * Math.sin((y / 3) * PI)) * 2) / 3
|
||||
ret += ((160 * Math.sin((y / 12) * PI) + 320 * Math.sin((y * PI) / 30)) * 2) / 3
|
||||
return ret
|
||||
}
|
||||
|
||||
function transformLng(x: number, y: number): number {
|
||||
let ret =
|
||||
300 + x + 2 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x))
|
||||
ret += ((20 * Math.sin(6 * x * PI) + 20 * Math.sin(2 * x * PI)) * 2) / 3
|
||||
ret += ((20 * Math.sin(x * PI) + 40 * Math.sin((x / 3) * PI)) * 2) / 3
|
||||
ret += ((150 * Math.sin((x / 12) * PI) + 300 * Math.sin((x / 30) * PI)) * 2) / 3
|
||||
return ret
|
||||
}
|
||||
|
||||
/** WGS84 → GCJ-02;境外坐标原样返回 */
|
||||
export function wgs84ToGcj02(lat: number, lng: number): { lat: number; lng: number } {
|
||||
if (outOfChina(lat, lng)) return { lat, lng }
|
||||
let dLat = transformLat(lng - 105, lat - 35)
|
||||
let dLng = transformLng(lng - 105, lat - 35)
|
||||
const radLat = (lat / 180) * PI
|
||||
let magic = Math.sin(radLat)
|
||||
magic = 1 - EE * magic * magic
|
||||
const sqrtMagic = Math.sqrt(magic)
|
||||
dLat = (dLat * 180) / ((A * (1 - EE)) / sqrtMagic * PI)
|
||||
dLng = (dLng * 180) / (A / sqrtMagic * Math.cos(radLat) * PI)
|
||||
return { lat: lat + dLat, lng: lng + dLng }
|
||||
}
|
||||
@@ -31,11 +31,19 @@ function isConnectionError(e: any): boolean {
|
||||
// 401 未授权、403 被 CDN/WAF 风控拦截、418 被反爬/限流标记、502 中间件/上游不可用 —— 换一个节点往往就能恢复
|
||||
const RETRY_STATUS_CODES = new Set([401, 403, 418, 502])
|
||||
|
||||
// 过滤掉 useFetch 专属选项(对 $fetch 无意义),其余(method/query/params/headers/body/timeout 等)原样透传
|
||||
// 过滤掉 useFetch 专属选项(对 $fetch 无意义),其余(method/query/params/headers/body/timeout 等)原样透传。
|
||||
//
|
||||
// 默认关闭 ofetch 内置重试(retry: false):
|
||||
// ofetch 对 GET 默认重试 1 次,且「拿不到响应(网络层错误)」会按 500 参与重试(见 ofetch onError:
|
||||
// responseCode = response.status || 500)。于是 502、429、超时、"连不上"这几种最贵的失败,
|
||||
// 都会在**同一个节点**上被立即重打一遍(retryDelay 默认 0,无退避),
|
||||
// 请求数与等待时间同时 ×2 —— 而外层候选循环本来就会换节点重试,这层纯属重复。
|
||||
// 调用方若显式传 retry,以调用方为准(rest 在后覆盖)。
|
||||
const DEFAULT_RETRY = false
|
||||
|
||||
function toFetchOptions(options?: any) {
|
||||
if (!options) return undefined
|
||||
const { immediate, watch, key, deep, server, lazy, default: _default, transform, pick, getCachedData, dedupe, ...rest } = options
|
||||
return rest
|
||||
const { immediate, watch, key, deep, server, lazy, default: _default, transform, pick, getCachedData, dedupe, ...rest } = options || {}
|
||||
return { retry: DEFAULT_RETRY, ...rest }
|
||||
}
|
||||
|
||||
// useMiddlewareFetch:在 Vue 页面中调用中间件(替代直接 useFetch('/middleware/...'))。
|
||||
@@ -44,6 +52,7 @@ function toFetchOptions(options?: any) {
|
||||
// Nuxt useAsyncData 在 key 变化时会重新绑定 data/error 状态,导致切换后的数据无法可靠渲染):
|
||||
// - 依次尝试 config.Middleware 中的外部节点 + 前端自带中间件兜底;
|
||||
// - 仅当"节点无法连接"或上游返回 401/403/418 时切下一个候选;
|
||||
// - 每次 $fetch 默认 retry: false,同一条通道不会被重打第二遍(重试统一由本循环承担);
|
||||
// - 成功后 data 立即更新为最终节点的数据,调用方 await execute() 后可直接读取并渲染;
|
||||
// - 全部候选失败时 error 为最终错误。
|
||||
export function useMiddlewareFetch<T = any>(url: MaybeRefOrGetter<string>, options?: any) {
|
||||
|
||||
@@ -2,7 +2,14 @@ import { codeToHtml } from './shiki.bundle'
|
||||
|
||||
export async function highlightCode(code: string, lang: string) {
|
||||
try {
|
||||
return await codeToHtml(code, { lang, theme: 'github-dark' })
|
||||
return await codeToHtml(code, {
|
||||
lang,
|
||||
theme: 'github-dark',
|
||||
// github-dark 的注释色 #6A737D 在它自带底色 #24292E 上只有 3.04:1(axe 的 color-contrast,
|
||||
// 首页 12 条里有 5 条都是它)。用 shiki 原生的颜色替换提亮到 #8B949E = 4.77:1 ——
|
||||
// 只动这一个 token,换主题(比如已在 bundle 里的 vitesse-dark)会把整块代码的配色一起换掉。
|
||||
colorReplacements: { '#6a737d': '#8b949e' },
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error highlighting code:', error)
|
||||
return code
|
||||
|
||||
@@ -40,3 +40,17 @@ export function isIPv4(ip: string): boolean {
|
||||
const ipRegex = /^(\d{1,3}\.){3}\d{1,3}$/;
|
||||
return ipRegex.test(ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* 把参数对象拼到 URL 上(空值跳过,自动判断用 ? 还是 &)。
|
||||
* 用于高级选项:dns4/dns6/resolve/resolve4/resolve6 这些都是「请求级解析参数」,
|
||||
* 只有用户填了才下发,没填时 URL 与加参数之前逐字节一致(缓存键也不变)。
|
||||
*/
|
||||
export function withQuery(url: string, params: Record<string, string>): string {
|
||||
const pairs: string[] = []
|
||||
for (const [key, value] of Object.entries(params)) {
|
||||
if (value) pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(value))
|
||||
}
|
||||
if (pairs.length === 0) return url
|
||||
return url + (url.includes('?') ? '&' : '?') + pairs.join('&')
|
||||
}
|
||||
@@ -4,7 +4,9 @@
|
||||
# - 自动检测架构并下载最新 release 二进制
|
||||
# - 交互式输入配置(环境变量注入,无需 setting.json)
|
||||
# - 生成并启用 systemd 守护进程
|
||||
# 用法:sudo bash install.sh
|
||||
# - 非 root 运行时会提示是否改用 systemd --user(用户级服务)
|
||||
# 用法:sudo bash install.sh # 系统级安装(推荐,开机自启、独立于登录会话)
|
||||
# bash install.sh # 非 root:确认后走 systemd --user,仅对当前用户生效
|
||||
# ============================================================
|
||||
|
||||
text="
|
||||
@@ -20,15 +22,58 @@ echo "$text"
|
||||
|
||||
set -e
|
||||
|
||||
# ---------- 前置检查 ----------
|
||||
# ---------- 前置检查与 systemd 作用域 ----------
|
||||
|
||||
# system = 系统级:写 /etc/systemd/system,开机自启走 multi-user.target(需 root)
|
||||
# user = 用户级:写 ~/.config/systemd/user,开机自启走 default.target(systemd --user,无需 root)
|
||||
SYSTEMD_MODE="system"
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "错误:需要 root 权限(写入 /etc/systemd/system 与安装目录),请用 sudo 运行" >&2
|
||||
exit 1
|
||||
echo "提示:当前不是 root 环境,无法写入 /etc/systemd/system 与系统安装目录。"
|
||||
read -r -p "是否改用 systemd --user(用户级服务,仅对当前用户生效)?[y/N]: " USE_USER_SYSTEMD
|
||||
case "${USE_USER_SYSTEMD,,}" in
|
||||
y|yes) SYSTEMD_MODE="user" ;;
|
||||
*)
|
||||
echo "已取消:如需系统级安装,请用 sudo 重新运行" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if ! command -v systemctl >/dev/null 2>&1; then
|
||||
echo "错误:未检测到 systemd(systemctl 不存在),无法创建守护进程" >&2
|
||||
exit 1
|
||||
fi
|
||||
# 用户级实例依赖登录会话与 DBus,容器 / cron 等环境常常拿不到,提前拦掉
|
||||
if [ "$SYSTEMD_MODE" = "user" ] && ! systemctl --user list-units >/dev/null 2>&1; then
|
||||
echo "错误:当前环境无法使用 systemd --user(无用户级 systemd 实例或缺少 DBus 会话)" >&2
|
||||
echo " 可改用 sudo bash install.sh 做系统级安装" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SERVICE_NAME="lemon-ipw"
|
||||
if [ "$SYSTEMD_MODE" = "user" ]; then
|
||||
SERVICE_FILE="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user/${SERVICE_NAME}.service"
|
||||
DEFAULT_INSTALL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/lemon-ipw"
|
||||
UNIT_USER_LINE=""
|
||||
UNIT_NETWORK_LINES=""
|
||||
UNIT_WANTED_BY="default.target"
|
||||
else
|
||||
SERVICE_FILE="/etc/systemd/system/${SERVICE_NAME}.service"
|
||||
DEFAULT_INSTALL_DIR="/opt/lemon-ipw"
|
||||
# 系统级 unit 的 User= 行与 network-online 依赖;用户级没有这两个概念
|
||||
UNIT_USER_LINE="User=root
|
||||
"
|
||||
UNIT_NETWORK_LINES="After=network-online.target
|
||||
Wants=network-online.target
|
||||
"
|
||||
UNIT_WANTED_BY="multi-user.target"
|
||||
fi
|
||||
|
||||
# 统一 systemctl / journalctl 调用(用户级自动补 --user)
|
||||
sc() { if [ "$SYSTEMD_MODE" = "user" ]; then systemctl --user "$@"; else systemctl "$@"; fi; }
|
||||
jc() { if [ "$SYSTEMD_MODE" = "user" ]; then journalctl --user "$@"; else journalctl "$@"; fi; }
|
||||
|
||||
if ! command -v wget >/dev/null 2>&1 && ! command -v curl >/dev/null 2>&1; then
|
||||
echo "错误:未找到 wget 或 curl,无法下载" >&2
|
||||
exit 1
|
||||
@@ -68,8 +113,16 @@ echo "========================================"
|
||||
echo " 配置后端节点(直接回车使用默认值)"
|
||||
echo "========================================"
|
||||
|
||||
read -r -p "安装目录 [/opt/lemon-ipw]: " INSTALL_DIR
|
||||
INSTALL_DIR=${INSTALL_DIR:-/opt/lemon-ipw}
|
||||
read -r -p "安装目录 [$DEFAULT_INSTALL_DIR]: " INSTALL_DIR
|
||||
INSTALL_DIR=${INSTALL_DIR:-$DEFAULT_INSTALL_DIR}
|
||||
# unit 里 WorkingDirectory/ExecStart 按 systemd 语法裸写(不加引号),
|
||||
# 路径含空白会被拆成多个参数导致启动失败,这里提前拦掉
|
||||
case "$INSTALL_DIR" in
|
||||
*[[:space:]]*)
|
||||
echo "错误:安装目录不能包含空格或制表符(当前值:$INSTALL_DIR)" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
read -r -p "监听端口 [8080]: " PORTS
|
||||
PORTS=${PORTS:-8080}
|
||||
@@ -82,10 +135,10 @@ read -r -p "DNS 服务器(留空=启动时自动探测系统 DNS;主从逗
|
||||
|
||||
read -r -p "DNSSEC 专用 DNS(留空=沿用上面 dns-server): " DNSSEC_DNS_SERVER
|
||||
|
||||
read -r -p "启用 IP 数据库 ipdb(首次启动下载约 450MB)[Y/n]: " IPDB_CHOICE
|
||||
read -r -p "启用 IP 数据库 ipdb(首次启动下载约 450MB,用于 IP 归属地/ASN 类拨测)[y/N]: " IPDB_CHOICE
|
||||
case "${IPDB_CHOICE,,}" in
|
||||
n|no) IPDB="false" ;;
|
||||
*) IPDB="true" ;;
|
||||
y|yes) IPDB="true" ;;
|
||||
*) IPDB="false" ;;
|
||||
esac
|
||||
|
||||
read -r -p "CORS 允许来源(逗号分隔,留空=不限): " CORS
|
||||
@@ -106,11 +159,35 @@ NODE_KEY=""
|
||||
WS_USED_DEFAULT=""
|
||||
case "${WS_CHOICE,,}" in
|
||||
y|yes)
|
||||
read -r -p " 中间件 WS 完整地址(含 wss:// 前缀与 /ws 路径,如 wss://host:8092/ws;留空=贡献节点给柠檬 wss://boce-api.api-ipw.wsmdn.top/ws;逗号分隔多个将同时连接全部): " WS_URL
|
||||
read -r -p " 中间件 WS 完整地址(含 wss:// 前缀与 /ws 路径,如 wss://host:8092/ws;多个用逗号分隔将同时连接全部;留空=贡献节点给柠檬的两条公共中间件): " WS_URL
|
||||
if [ -z "$WS_URL" ]; then
|
||||
WS_URL="wss://boce-api.api-ipw.wsmdn.top/ws"
|
||||
WS_URL="wss://boce-api.api-ipw.wsmdn.top/ws,wss://middleware-1.api-ipw.wsmdn.top/ws"
|
||||
WS_USED_DEFAULT="true"
|
||||
fi
|
||||
# 多地址(逗号分隔):逐段去掉首尾空白并校验 scheme。
|
||||
# 不清理的话空格会原样写进 unit 的 Environment,节点侧解析失败后只会反复重连,很难排查。
|
||||
_ws_norm=""
|
||||
_old_ifs="$IFS"; IFS=','
|
||||
for _seg in $WS_URL; do
|
||||
_seg="${_seg#"${_seg%%[![:space:]]*}"}"
|
||||
_seg="${_seg%"${_seg##*[![:space:]]}"}"
|
||||
case "$_seg" in
|
||||
ws://*|wss://*) ;;
|
||||
"")
|
||||
IFS="$_old_ifs"
|
||||
echo "错误:WS 地址含空段(检查是否多写了逗号)" >&2
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
IFS="$_old_ifs"
|
||||
echo "错误:WS 地址的每一段都需以 ws:// 或 wss:// 开头(问题段:${_seg})" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
_ws_norm="${_ws_norm:+${_ws_norm},}${_seg}"
|
||||
done
|
||||
IFS="$_old_ifs"
|
||||
WS_URL="$_ws_norm"
|
||||
read -r -p " 注册 key(留空自动生成,中间件 ws-keys 必须包含此节点,否则注册被拒 401): " NODE_KEY
|
||||
if [ -z "$NODE_KEY" ]; then
|
||||
NODE_KEY=$(gen_uuid | tr -d '-')
|
||||
@@ -141,6 +218,11 @@ echo " 配置汇总"
|
||||
echo "========================================"
|
||||
echo "安装目录: $INSTALL_DIR"
|
||||
echo "服务名: lemon-ipw"
|
||||
if [ "$SYSTEMD_MODE" = "user" ]; then
|
||||
echo "服务作用域: 用户级(systemd --user,仅对当前用户生效)"
|
||||
else
|
||||
echo "服务作用域: 系统级(systemd)"
|
||||
fi
|
||||
echo "监听端口: $PORTS"
|
||||
echo "节点 id: $NODE_ID"
|
||||
echo "单栈模式: ${SINGLE_STACK:-双栈}"
|
||||
@@ -182,7 +264,9 @@ chmod +x "$INSTALL_DIR/lemonipw"
|
||||
echo "二进制已安装到 $INSTALL_DIR/lemonipw"
|
||||
|
||||
# ---------- 生成 systemd 服务 ----------
|
||||
SERVICE_FILE="/etc/systemd/system/lemon-ipw.service"
|
||||
|
||||
# 用户级 unit 目录(~/.config/systemd/user)默认可能不存在
|
||||
mkdir -p "$(dirname "$SERVICE_FILE")"
|
||||
|
||||
# 收集环境变量(仅非空的写入,避免空值覆盖默认)
|
||||
# 值里的双引号/反斜杠需要转义,否则会提前终止 systemd 的引号包裹、损坏 unit
|
||||
@@ -216,43 +300,66 @@ fi
|
||||
cat > "$SERVICE_FILE" << EOF
|
||||
[Unit]
|
||||
Description=Lemon IPW Backend Node
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
${UNIT_NETWORK_LINES}
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
WorkingDirectory="${INSTALL_DIR}"
|
||||
ExecStart="${INSTALL_DIR}/lemonipw"
|
||||
${UNIT_USER_LINE}WorkingDirectory=${INSTALL_DIR}
|
||||
ExecStart=${INSTALL_DIR}/lemonipw
|
||||
${ENV_LINES}Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
WantedBy=${UNIT_WANTED_BY}
|
||||
EOF
|
||||
|
||||
echo "已生成服务文件 $SERVICE_FILE"
|
||||
|
||||
# ---------- 启动服务 ----------
|
||||
systemctl daemon-reload
|
||||
sc daemon-reload
|
||||
# restart 而非 enable --now:重跑安装改配置后旧进程必须重启才会生效
|
||||
systemctl enable lemon-ipw
|
||||
systemctl restart lemon-ipw
|
||||
systemctl status lemon-ipw --no-pager | head -15
|
||||
sc enable lemon-ipw
|
||||
sc restart lemon-ipw
|
||||
sc status lemon-ipw --no-pager | head -15
|
||||
|
||||
# 用户级服务默认随最后一个会话结束而停止,注销后要继续跑必须开 linger
|
||||
if [ "$SYSTEMD_MODE" = "user" ]; then
|
||||
if loginctl show-user "$(id -un)" -p Linger 2>/dev/null | grep -q 'Linger=yes'; then
|
||||
echo "linger 已启用:用户注销后服务继续运行"
|
||||
elif loginctl enable-linger "$(id -un)" >/dev/null 2>&1; then
|
||||
echo "已启用 linger:用户注销后服务继续运行"
|
||||
else
|
||||
echo "提示:未能自动启用 linger,注销后服务会被停止。请手动执行:" >&2
|
||||
echo " sudo loginctl enable-linger $(id -un)" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "========================================"
|
||||
echo " 安装完成"
|
||||
echo "========================================"
|
||||
# 用户级服务的运维命令都要带 --user,否则看到的是系统级命名空间(空)
|
||||
if [ "$SYSTEMD_MODE" = "user" ]; then
|
||||
CTL_CMD="systemctl --user"
|
||||
JRN_CMD="journalctl --user -u"
|
||||
else
|
||||
CTL_CMD="systemctl"
|
||||
JRN_CMD="journalctl -u"
|
||||
fi
|
||||
echo "常用命令:"
|
||||
echo " systemctl status lemon-ipw # 查看状态"
|
||||
echo " journalctl -u lemon-ipw -f # 查看日志"
|
||||
echo " systemctl restart lemon-ipw # 重启(改配置后)"
|
||||
echo " $CTL_CMD status lemon-ipw # 查看状态"
|
||||
echo " $JRN_CMD lemon-ipw -f # 查看日志"
|
||||
echo " $CTL_CMD restart lemon-ipw # 重启(改配置后)"
|
||||
echo "验证:curl http://127.0.0.1:$PORTS/ 应返回 {\"status\":\"ok\"}"
|
||||
if [ -n "$WS_URL" ]; then
|
||||
echo ""
|
||||
echo "WS 通道已启用,请把节点注册信息加入中间件 setting.json 的 ws-keys:"
|
||||
echo "WS 通道已启用,请把节点注册信息加入每一个对应中间件 setting.json 的 ws-keys(缺一个该条连接会被拒 401):"
|
||||
echo " \"$NODE_ID\": \"$NODE_KEY\""
|
||||
echo " 地址清单:"
|
||||
_old_ifs="$IFS"; IFS=','
|
||||
for _seg in $WS_URL; do
|
||||
echo " - $_seg"
|
||||
done
|
||||
IFS="$_old_ifs"
|
||||
fi
|
||||
if [ -n "$WS_USED_DEFAULT" ]; then
|
||||
echo ""
|
||||
|
||||
@@ -348,6 +348,18 @@ func middlewareHandler(c fiber.Ctx) error {
|
||||
|
||||
query := c.Queries()
|
||||
|
||||
// 请求级 query 透传给节点(过滤空值,等价 TS 版 URLSearchParams 过滤):
|
||||
// 两个分支都要用 —— tcping/udping/speed 的 port/count/version,以及 detail/ssl/dns/whois 的 dns/dns4/dns6。
|
||||
// HTTP 侧用 url.Values 重新编码后拼接(原样透传会被下一跳的 query 解析器重新切分),WS 侧以 map 形式进 RequestProbe。
|
||||
queryString := url.Values{}
|
||||
queryMap := make(map[string]string)
|
||||
for k, v := range query {
|
||||
if v != "" {
|
||||
queryString.Set(k, v)
|
||||
queryMap[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
// 从 API_KEYS 查找 token,未配置时回退到环境变量 API_KEYS (JSON 字符串)
|
||||
apiKey := lookupAPIKey(backendID)
|
||||
|
||||
@@ -378,7 +390,7 @@ func middlewareHandler(c fiber.Ctx) error {
|
||||
// 不再静默落回空 URL 的 HTTP 转发(必然 502 且掩盖真实配置错误)
|
||||
return c.Status(fiber.StatusBadGateway).SendString("Node " + backendID + " is WS-only but WS channel is disabled (ws-port=0 or bind failed)")
|
||||
}
|
||||
status, body, err := wsSrv.RequestProbe(backendID, apiType, raw, nil, wsProbeTimeout())
|
||||
status, body, err := wsSrv.RequestProbe(backendID, apiType, raw, queryMap, wsProbeTimeout())
|
||||
if err != nil {
|
||||
return c.Status(fiber.StatusBadGateway).SendString("WS probe failed: " + err.Error())
|
||||
}
|
||||
@@ -391,22 +403,12 @@ func middlewareHandler(c fiber.Ctx) error {
|
||||
}
|
||||
|
||||
// 上游错误原样透传(状态码 + body),网络错误返回 502
|
||||
return forwardUpstream(c, apiBaseUrl, apiBaseUrl+"v1/"+apiType+"/"+raw, authHeaders, nil)
|
||||
return forwardUpstream(c, apiBaseUrl, apiBaseUrl+"v1/"+apiType+"/"+raw, authHeaders, queryString)
|
||||
|
||||
case "tcping", "udping", "speed":
|
||||
// tcping/udping/speed 统一走 APIBaseURL 节点池
|
||||
apiBaseUrls := flattenStack(API_BASE_URLS)
|
||||
|
||||
// 转发 query 参数(过滤空值,等价于 TS 中 URLSearchParams 过滤 undefined)
|
||||
queryString := url.Values{}
|
||||
queryMap := make(map[string]string)
|
||||
for k, v := range query {
|
||||
if v != "" {
|
||||
queryString.Set(k, v)
|
||||
queryMap[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
node := findNode(apiBaseUrls, backendID)
|
||||
if node == nil || (!node.UseWS() && node.URL == "") {
|
||||
return badRequest(c, "Invalid backend ID")
|
||||
|
||||
@@ -184,8 +184,11 @@ type SSLCheckDetail struct {
|
||||
IssuerOrganization []string `json:"issuer_organization"`
|
||||
IssuerCommonName string `json:"issuer_common_name"`
|
||||
SubjectCommonName string `json:"subject_common_name"`
|
||||
IsExpired bool `json:"is_expired"`
|
||||
IsReachable bool `json:"is_reachable"`
|
||||
// SAN 证书主体别名(Subject Alternative Names):DNS 名在前、IP 在后,
|
||||
// 与 CN 相互独立——校验「证书覆盖了哪些域名」以这里为准
|
||||
SAN []string `json:"san"`
|
||||
IsExpired bool `json:"is_expired"`
|
||||
IsReachable bool `json:"is_reachable"`
|
||||
}
|
||||
|
||||
type SSLCheckResult struct {
|
||||
@@ -202,26 +205,39 @@ func initHttpClient() {
|
||||
dialer := &net.Dialer{Timeout: 10 * time.Second, KeepAlive: 30 * time.Second}
|
||||
return &http.Transport{
|
||||
DialContext: func(ctx context.Context, _, addr string) (net.Conn, error) {
|
||||
if ssrf.Enabled() {
|
||||
host, port, err := net.SplitHostPort(addr)
|
||||
// DNS 接管与 SSRF 解耦:域名一律先经 webtest 解析成 IP 再拨号。
|
||||
// 服务器取请求级覆盖(dns=/dns4=/dns6=,经 ctx 传来),无覆盖则用配置 dns-server;
|
||||
// 不这样时关掉 SSRF 会绕过配置/系统 DNS,detail/ssl/speed 与 tcping/dns 各问各的。
|
||||
// SSRF 只保留「私网校验」职责,不再是 DNS 接管的开关。
|
||||
// 同源:SSRF 预检(ValidateOutboundTarget)经 InstallSSRFResolver 读到的是同一份 ctx 配置。
|
||||
req := webtest.ReqResolveFromContext(ctx)
|
||||
host, port, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 强制解析(resolve=/resolve4=/resolve6=):命中就把目标填回 host。
|
||||
// 目标是 IP → 走下面的字面 IP 分支(私网检测后直连,不再查 DNS);
|
||||
// 目标是域名 → 当作新 host 交给下面的解析分支。
|
||||
if target := req.Override(host, network == "tcp6"); target != "" {
|
||||
host = strings.Trim(target, "[]")
|
||||
addr = net.JoinHostPort(host, port)
|
||||
}
|
||||
if ip := net.ParseIP(host); ip != nil {
|
||||
if ssrf.Enabled() && ssrf.IsPrivateIP(ip) {
|
||||
slog.Warn("Blocked connection to private IP", "host", host)
|
||||
return nil, fmt.Errorf("request to private/internal address is not allowed")
|
||||
}
|
||||
} else {
|
||||
var dnsResult webtest.DNSResult
|
||||
if network == "tcp4" {
|
||||
dnsResult, err = webtest.ResolveARecord(host, req.Servers("ipv4"))
|
||||
} else {
|
||||
dnsResult, err = webtest.ResolveAAAARecord(host, req.Servers("ipv6"))
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if ip := net.ParseIP(host); ip != nil {
|
||||
if ssrf.IsPrivateIP(ip) {
|
||||
slog.Warn("Blocked connection to private IP", "host", host)
|
||||
return nil, fmt.Errorf("request to private/internal address is not allowed")
|
||||
}
|
||||
} else {
|
||||
var dnsResult webtest.DNSResult
|
||||
if network == "tcp4" {
|
||||
dnsResult, err = webtest.ResolveARecord(host)
|
||||
} else {
|
||||
dnsResult, err = webtest.ResolveAAAARecord(host)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if ssrf.Enabled() {
|
||||
for _, ipStr := range dnsResult.Record {
|
||||
ip := net.ParseIP(ipStr)
|
||||
if ip != nil && ssrf.IsPrivateIP(ip) {
|
||||
@@ -229,9 +245,9 @@ func initHttpClient() {
|
||||
return nil, fmt.Errorf("request to private/internal address is not allowed")
|
||||
}
|
||||
}
|
||||
if len(dnsResult.Record) > 0 {
|
||||
addr = net.JoinHostPort(dnsResult.Record[0], port)
|
||||
}
|
||||
}
|
||||
if len(dnsResult.Record) > 0 {
|
||||
addr = net.JoinHostPort(dnsResult.Record[0], port)
|
||||
}
|
||||
}
|
||||
return dialer.DialContext(ctx, network, addr)
|
||||
@@ -301,13 +317,16 @@ func (b *zstdReader) Close() error {
|
||||
return b.closeErr
|
||||
}
|
||||
|
||||
func checkWebsite(url string, version string) (*WebsiteCheckDetail, error) {
|
||||
// checkWebsite 对单个栈做站点拨测;req 为请求级解析配置(dns*/resolve*,零值 = 用配置 DNS)。
|
||||
func checkWebsite(url string, version string, req webtest.ReqResolve) (*WebsiteCheckDetail, error) {
|
||||
ctx := context.Background()
|
||||
var err error
|
||||
ctx, err = ssrf.ValidateOutboundTarget(ctx, url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 请求级解析配置进 ctx:DialContext 与 SSRF 预检同源读取(dns=/dns4=/dns6=、resolve=)
|
||||
ctx = webtest.WithReqResolve(ctx, req)
|
||||
|
||||
client := V4Client
|
||||
if version == "v6" {
|
||||
@@ -338,7 +357,7 @@ func checkWebsite(url string, version string) (*WebsiteCheckDetail, error) {
|
||||
|
||||
dnsLookupTime := trace.DNSLookup.Seconds() * 1000
|
||||
if dnsLookupTime == 0 {
|
||||
dnsLookupTime = measureDNSTime(url, version)
|
||||
dnsLookupTime = measureDNSTime(url, version, req)
|
||||
}
|
||||
tcpConnectTime := trace.TCPConnTime.Seconds() * 1000
|
||||
httpConnectTime := trace.ConnTime.Seconds() * 1000
|
||||
@@ -373,13 +392,16 @@ func checkWebsite(url string, version string) (*WebsiteCheckDetail, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func websiteSpeed(url string, version string) (*WebsiteSpeedTestResult, error) {
|
||||
// websiteSpeed 对单个栈做测速拨测;req 为请求级解析配置(零值 = 用配置 DNS)。
|
||||
func websiteSpeed(url string, version string, req webtest.ReqResolve) (*WebsiteSpeedTestResult, error) {
|
||||
ctx := context.Background()
|
||||
var err error
|
||||
ctx, err = ssrf.ValidateOutboundTarget(ctx, url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 请求级解析配置进 ctx:DialContext 与 SSRF 预检同源读取(dns=/dns4=/dns6=、resolve=)
|
||||
ctx = webtest.WithReqResolve(ctx, req)
|
||||
|
||||
client := V4Client
|
||||
if version == "v6" {
|
||||
@@ -409,7 +431,7 @@ func websiteSpeed(url string, version string) (*WebsiteSpeedTestResult, error) {
|
||||
|
||||
dnsLookupTime := trace.DNSLookup.Seconds() * 1000
|
||||
if dnsLookupTime == 0 {
|
||||
dnsLookupTime = measureDNSTime(url, version)
|
||||
dnsLookupTime = measureDNSTime(url, version, req)
|
||||
}
|
||||
tcpConnectTime := trace.TCPConnTime.Seconds() * 1000
|
||||
httpConnectTime := trace.ConnTime.Seconds() * 1000
|
||||
@@ -445,7 +467,7 @@ func websiteSpeed(url string, version string) (*WebsiteSpeedTestResult, error) {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func measureDNSTime(urlStr string, version string) float64 {
|
||||
func measureDNSTime(urlStr string, version string, req webtest.ReqResolve) float64 {
|
||||
parsed, err := url.Parse(urlStr)
|
||||
if err != nil {
|
||||
return 0
|
||||
@@ -454,12 +476,15 @@ func measureDNSTime(urlStr string, version string) float64 {
|
||||
if host == "" {
|
||||
return 0
|
||||
}
|
||||
// 与拨测同源:走请求级 DNS 覆盖(dns4/dns6),无覆盖用配置 dns-server
|
||||
servers := req.Servers("ipv4")
|
||||
start := time.Now()
|
||||
var dnsErr error
|
||||
if version == "v6" {
|
||||
_, dnsErr = webtest.ResolveAAAARecord(host)
|
||||
servers = req.Servers("ipv6")
|
||||
_, dnsErr = webtest.ResolveAAAARecord(host, servers)
|
||||
} else {
|
||||
_, dnsErr = webtest.ResolveARecord(host)
|
||||
_, dnsErr = webtest.ResolveARecord(host, servers)
|
||||
}
|
||||
if dnsErr != nil {
|
||||
return 0
|
||||
@@ -467,13 +492,15 @@ func measureDNSTime(urlStr string, version string) float64 {
|
||||
return time.Since(start).Seconds() * 1000
|
||||
}
|
||||
|
||||
func checkSSL(url string, version string) (*SSLCheckDetail, error) {
|
||||
func checkSSL(url string, version string, req webtest.ReqResolve) (*SSLCheckDetail, error) {
|
||||
ssrfCtx := context.Background()
|
||||
var err error
|
||||
ssrfCtx, err = ssrf.ValidateOutboundTarget(ssrfCtx, url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// 请求级解析配置进 ctx:DialContext 与 SSRF 预检同源读取(dns=/dns4=/dns6=、resolve=)
|
||||
ssrfCtx = webtest.WithReqResolve(ssrfCtx, req)
|
||||
|
||||
client := V4Client
|
||||
if version == "v6" {
|
||||
@@ -504,6 +531,7 @@ func checkSSL(url string, version string) (*SSLCheckDetail, error) {
|
||||
var certStartTime, certEndTime time.Time
|
||||
var issuerOrganization []string
|
||||
var issuerCommonName, subjectCommonName, domain string
|
||||
var san []string
|
||||
|
||||
if rawResp.TLS != nil && len(rawResp.TLS.PeerCertificates) > 0 {
|
||||
cert = rawResp.TLS.PeerCertificates[0]
|
||||
@@ -516,6 +544,12 @@ func checkSSL(url string, version string) (*SSLCheckDetail, error) {
|
||||
issuerCommonName = cert.Issuer.CommonName
|
||||
subjectCommonName = cert.Subject.CommonName
|
||||
domain = cleanHostRecord(cert.Subject.CommonName)
|
||||
// SAN:DNS 名在前、IP 在后(IP 站点证书可能只有 IP SAN)
|
||||
san = make([]string, 0, len(cert.DNSNames)+len(cert.IPAddresses))
|
||||
san = append(san, cert.DNSNames...)
|
||||
for _, ip := range cert.IPAddresses {
|
||||
san = append(san, ip.String())
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("no SSL certificate found")
|
||||
}
|
||||
@@ -534,6 +568,7 @@ func checkSSL(url string, version string) (*SSLCheckDetail, error) {
|
||||
IssuerOrganization: issuerOrganization,
|
||||
IssuerCommonName: issuerCommonName,
|
||||
SubjectCommonName: subjectCommonName,
|
||||
SAN: san,
|
||||
IsReachable: true,
|
||||
}
|
||||
|
||||
@@ -600,19 +635,28 @@ func checkWebsiteHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if cached, ok := websiteCache.Load(testUrl); ok {
|
||||
req, err := webtest.ParseReqResolve(func(k string) string { return c.Query(k) })
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
// 缓存键带上请求级 DNS 覆盖:结果取决于所用服务器,参数不同必须各占一条,
|
||||
// 否则互相串味;无覆盖时 req.CacheKey() 为空串,键与旧版完全一致。
|
||||
cacheKey := testUrl + req.CacheKey()
|
||||
|
||||
if cached, ok := websiteCache.Load(cacheKey); ok {
|
||||
entry := cached.(websiteCacheEntry)
|
||||
if time.Since(entry.timestamp) < 5*time.Minute {
|
||||
c.JSON(200, entry.result)
|
||||
return
|
||||
}
|
||||
websiteCache.Delete(testUrl)
|
||||
websiteCache.Delete(cacheKey)
|
||||
}
|
||||
|
||||
result := &WebsiteCheckResult{}
|
||||
switch SINGLE_STACK {
|
||||
case "ipv4":
|
||||
ipv4, errV4 := checkWebsite(testUrl, "v4")
|
||||
ipv4, errV4 := checkWebsite(testUrl, "v4", req)
|
||||
if errV4 != nil {
|
||||
ipv4 = &WebsiteCheckDetail{
|
||||
HostRecord: "Error: " + errV4.Error(),
|
||||
@@ -625,7 +669,7 @@ func checkWebsiteHandler(c *gin.Context) {
|
||||
IsReachable: false,
|
||||
}
|
||||
case "ipv6":
|
||||
ipv6, errV6 := checkWebsite(testUrl, "v6")
|
||||
ipv6, errV6 := checkWebsite(testUrl, "v6", req)
|
||||
if errV6 != nil {
|
||||
ipv6 = &WebsiteCheckDetail{
|
||||
HostRecord: "Error: " + errV6.Error(),
|
||||
@@ -643,7 +687,7 @@ func checkWebsiteHandler(c *gin.Context) {
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
ipv6, errV6 := checkWebsite(testUrl, "v6")
|
||||
ipv6, errV6 := checkWebsite(testUrl, "v6", req)
|
||||
if errV6 != nil {
|
||||
ipv6 = &WebsiteCheckDetail{
|
||||
HostRecord: "Error: " + errV6.Error(),
|
||||
@@ -655,7 +699,7 @@ func checkWebsiteHandler(c *gin.Context) {
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
ipv4, errV4 := checkWebsite(testUrl, "v4")
|
||||
ipv4, errV4 := checkWebsite(testUrl, "v4", req)
|
||||
if errV4 != nil {
|
||||
ipv4 = &WebsiteCheckDetail{
|
||||
HostRecord: "Error: " + errV4.Error(),
|
||||
@@ -667,14 +711,14 @@ func checkWebsiteHandler(c *gin.Context) {
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
websiteCache.Store(testUrl, websiteCacheEntry{result: result, timestamp: time.Now()})
|
||||
websiteCache.Store(cacheKey, websiteCacheEntry{result: result, timestamp: time.Now()})
|
||||
|
||||
// If both IPv4 and IPv6 fail, only cache for 30 seconds
|
||||
// 如果 IPv4 和 IPv6 都失败,只缓存30秒
|
||||
if (result.IPv4 != nil && !result.IPv4.IsReachable) && (result.IPv6 != nil && !result.IPv6.IsReachable) {
|
||||
go func() {
|
||||
time.Sleep(30 * time.Second)
|
||||
websiteCache.Delete(testUrl)
|
||||
websiteCache.Delete(cacheKey)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -701,19 +745,27 @@ func sslCheckHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if cached, ok := sslCache.Load(testUrl); ok {
|
||||
req, err := webtest.ParseReqResolve(func(k string) string { return c.Query(k) })
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
// 缓存键带上请求级 DNS 覆盖(结果取决于所用服务器,参数不同不能共用)
|
||||
cacheKey := testUrl + req.CacheKey()
|
||||
|
||||
if cached, ok := sslCache.Load(cacheKey); ok {
|
||||
entry := cached.(sslCacheEntry)
|
||||
if time.Since(entry.timestamp) < 5*time.Minute {
|
||||
c.JSON(200, entry.result)
|
||||
return
|
||||
}
|
||||
sslCache.Delete(testUrl)
|
||||
sslCache.Delete(cacheKey)
|
||||
}
|
||||
|
||||
result := &SSLCheckResult{}
|
||||
switch SINGLE_STACK {
|
||||
case "ipv4":
|
||||
ipv4, errV4 := checkSSL(testUrl, "v4")
|
||||
ipv4, errV4 := checkSSL(testUrl, "v4", req)
|
||||
if errV4 != nil {
|
||||
ipv4 = &SSLCheckDetail{
|
||||
HostRecord: "Error: " + errV4.Error(),
|
||||
@@ -726,7 +778,7 @@ func sslCheckHandler(c *gin.Context) {
|
||||
IsExpired: true,
|
||||
}
|
||||
case "ipv6":
|
||||
ipv6, errV6 := checkSSL(testUrl, "v6")
|
||||
ipv6, errV6 := checkSSL(testUrl, "v6", req)
|
||||
if errV6 != nil {
|
||||
ipv6 = &SSLCheckDetail{
|
||||
HostRecord: "Error: " + errV6.Error(),
|
||||
@@ -745,7 +797,7 @@ func sslCheckHandler(c *gin.Context) {
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
ipv6, errV6 := checkSSL(testUrl, "v6")
|
||||
ipv6, errV6 := checkSSL(testUrl, "v6", req)
|
||||
if errV6 != nil {
|
||||
ipv6 = &SSLCheckDetail{
|
||||
HostRecord: "Error: " + errV6.Error(),
|
||||
@@ -757,7 +809,7 @@ func sslCheckHandler(c *gin.Context) {
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
ipv4, errV4 := checkSSL(testUrl, "v4")
|
||||
ipv4, errV4 := checkSSL(testUrl, "v4", req)
|
||||
if errV4 != nil {
|
||||
ipv4 = &SSLCheckDetail{
|
||||
HostRecord: "Error: " + errV4.Error(),
|
||||
@@ -770,13 +822,13 @@ func sslCheckHandler(c *gin.Context) {
|
||||
wg.Wait()
|
||||
}
|
||||
|
||||
sslCache.Store(testUrl, sslCacheEntry{result: result, timestamp: time.Now()})
|
||||
sslCache.Store(cacheKey, sslCacheEntry{result: result, timestamp: time.Now()})
|
||||
|
||||
// 如果 IPv4 和 IPv6 都失败,只缓存30秒
|
||||
if (result.IPv4 != nil && !result.IPv4.IsReachable) && (result.IPv6 != nil && !result.IPv6.IsReachable) {
|
||||
go func() {
|
||||
time.Sleep(30 * time.Second)
|
||||
sslCache.Delete(testUrl)
|
||||
sslCache.Delete(cacheKey)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -796,6 +848,13 @@ func websiteSpeedTestHandler(c *gin.Context) {
|
||||
}
|
||||
url := normalizeURL(testUrl)
|
||||
|
||||
req, err := webtest.ParseReqResolve(func(k string) string { return c.Query(k) })
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
// 检查请求版本是否与 SINGLE_STACK 配置匹配
|
||||
switch SINGLE_STACK {
|
||||
case "ipv4":
|
||||
if version != "v4" {
|
||||
@@ -815,7 +874,8 @@ func websiteSpeedTestHandler(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
cacheKey := fmt.Sprintf("%s:%s", url, version)
|
||||
// 缓存键:URL + 版本 + 请求级 DNS 覆盖(结果取决于所用服务器,参数不同不能共用)
|
||||
cacheKey := fmt.Sprintf("%s:%s%s", url, version, req.CacheKey())
|
||||
|
||||
if cached, ok := speedCache.Load(cacheKey); ok {
|
||||
entry := cached.(speedCacheEntry)
|
||||
@@ -828,9 +888,9 @@ func websiteSpeedTestHandler(c *gin.Context) {
|
||||
|
||||
switch version {
|
||||
case "v6":
|
||||
result, err = websiteSpeed(url, "v6")
|
||||
result, err = websiteSpeed(url, "v6", req)
|
||||
case "v4":
|
||||
result, err = websiteSpeed(url, "v4")
|
||||
result, err = websiteSpeed(url, "v4", req)
|
||||
default:
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"error": "Invalid version",
|
||||
@@ -868,93 +928,35 @@ func dnsQueryHandler(c *gin.Context) {
|
||||
domain = parsedURL.Host
|
||||
recodeType := c.Param("type")
|
||||
switch recodeType {
|
||||
case "a":
|
||||
result, err := webtest.ResolveARecord(domain)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, result)
|
||||
case "aaaa":
|
||||
result, err := webtest.ResolveAAAARecord(domain)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, result)
|
||||
case "cname":
|
||||
result, err := webtest.ResolveCNAMERecord(domain)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, result)
|
||||
case "mx":
|
||||
result, err := webtest.ResolveMXRecord(domain)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, result)
|
||||
case "ns":
|
||||
result, err := webtest.ResolveNSRecord(domain)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, result)
|
||||
case "ptr":
|
||||
result, err := webtest.ResolvePTRRecord(domain)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, result)
|
||||
case "srv":
|
||||
result, err := webtest.ResolveSRVRecord(domain)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, result)
|
||||
case "txt":
|
||||
result, err := webtest.ResolveTXTRecord(domain)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, result)
|
||||
case "caa":
|
||||
result, err := webtest.ResolveCAARecord(domain)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, result)
|
||||
case "a", "aaaa", "cname", "mx", "ns", "ptr", "srv", "txt", "caa":
|
||||
default:
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"error": "Invalid record type",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
req, err := webtest.ParseReqResolve(func(k string) string { return c.Query(k) })
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
// 按 qtype 选栈:a→dns4|dns,aaaa→dns6|dns,其余→dns
|
||||
stack := ""
|
||||
if recodeType == "a" {
|
||||
stack = "ipv4"
|
||||
} else if recodeType == "aaaa" {
|
||||
stack = "ipv6"
|
||||
}
|
||||
|
||||
result, err := webtest.ResolveByType(domain, recodeType, req.Servers(stack))
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"error": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
func pingHandler(c *gin.Context) {
|
||||
@@ -982,7 +984,15 @@ func pingHandler(c *gin.Context) {
|
||||
count = n
|
||||
}
|
||||
|
||||
cacheKey := fmt.Sprintf("%s:%s:%d", host, port, count)
|
||||
req, err := webtest.ParseReqResolve(func(k string) string { return c.Query(k) })
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
// 缓存键带上请求级 DNS 覆盖:不同 dns=/resolve= 的结果不能互相污染;
|
||||
// 无覆盖时 req.CacheKey() 为空串,键与旧版完全一致。
|
||||
cacheKey := fmt.Sprintf("%s:%s:%d%s", host, port, count, req.CacheKey())
|
||||
if cached, ok := pingCache.Load(cacheKey); ok {
|
||||
entry := cached.(pingCacheEntry)
|
||||
if time.Since(entry.timestamp) < 5*time.Minute {
|
||||
@@ -996,7 +1006,7 @@ func pingHandler(c *gin.Context) {
|
||||
|
||||
switch SINGLE_STACK {
|
||||
case "ipv4":
|
||||
ipv4, errV4 := webtest.TCPingRun(host, port, count, "v4", 10*time.Second, 100*time.Millisecond)
|
||||
ipv4, errV4 := webtest.TCPingRunWith(host, port, count, "v4", 10*time.Second, 100*time.Millisecond, req)
|
||||
if errV4 != nil {
|
||||
ipv4 = &webtest.TCPingStats{
|
||||
IP: "Error: " + errV4.Error(),
|
||||
@@ -1007,7 +1017,7 @@ func pingHandler(c *gin.Context) {
|
||||
IP: "Skipped due to SINGLE_STACK=ipv4",
|
||||
}
|
||||
case "ipv6":
|
||||
ipv6, errV6 := webtest.TCPingRun(host, port, count, "v6", 10*time.Second, 100*time.Millisecond)
|
||||
ipv6, errV6 := webtest.TCPingRunWith(host, port, count, "v6", 10*time.Second, 100*time.Millisecond, req)
|
||||
if errV6 != nil {
|
||||
ipv6 = &webtest.TCPingStats{
|
||||
IP: "Error: " + errV6.Error(),
|
||||
@@ -1023,7 +1033,7 @@ func pingHandler(c *gin.Context) {
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
ipv6, errV6 := webtest.TCPingRun(host, port, count, "v6", 10*time.Second, 100*time.Millisecond)
|
||||
ipv6, errV6 := webtest.TCPingRunWith(host, port, count, "v6", 10*time.Second, 100*time.Millisecond, req)
|
||||
if errV6 != nil {
|
||||
ipv6 = &webtest.TCPingStats{
|
||||
IP: "Error: " + errV6.Error(),
|
||||
@@ -1034,7 +1044,7 @@ func pingHandler(c *gin.Context) {
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
ipv4, errV4 := webtest.TCPingRun(host, port, count, "v4", 10*time.Second, 100*time.Millisecond)
|
||||
ipv4, errV4 := webtest.TCPingRunWith(host, port, count, "v4", 10*time.Second, 100*time.Millisecond, req)
|
||||
if errV4 != nil {
|
||||
ipv4 = &webtest.TCPingStats{
|
||||
IP: "Error: " + errV4.Error(),
|
||||
@@ -1315,6 +1325,9 @@ func main() {
|
||||
initHttpClient()
|
||||
webtest.SetDNSServer(DNS_SERVER)
|
||||
webtest.SetDNSSecServer(DNSSEC_DNS_SERVER)
|
||||
// SSRF 预检改走 webtest 的自定义 DNS(含请求级 dns= 覆盖),
|
||||
// 避免「预检用系统解析器、拨号用自定义 DNS」两套解析器口径不一
|
||||
webtest.InstallSSRFResolver()
|
||||
slog.Info("Starting server", "port", PORTS, "single_stack", SINGLE_STACK)
|
||||
|
||||
// 数据上报:周期把本节点的统计与拨测明细上报到收集中心(详见 report.go)
|
||||
|
||||
@@ -45,6 +45,23 @@ func SetEnabled(v bool) {
|
||||
blockPrivateIPs = v
|
||||
}
|
||||
|
||||
// ResolveFunc 把主机名解析为 IP 列表。默认 net.LookupIP(系统解析器)。
|
||||
// 可由上层(webtest)通过 SetResolveFunc 注入,使出站校验与真正的拨号走同一个 DNS
|
||||
// ——包括请求级 DNS 服务器覆盖。否则预检(系统解析器)与拨号(自定义 DNS)会用两套解析器,
|
||||
// 既多一次查询,结果也可能不一致。
|
||||
type ResolveFunc func(ctx context.Context, host string) ([]net.IP, error)
|
||||
|
||||
var resolveHostFn ResolveFunc = func(_ context.Context, host string) ([]net.IP, error) {
|
||||
return net.LookupIP(host)
|
||||
}
|
||||
|
||||
// SetResolveFunc 注入自定义解析器(传 nil 忽略,保持默认 net.LookupIP)。
|
||||
func SetResolveFunc(f ResolveFunc) {
|
||||
if f != nil {
|
||||
resolveHostFn = f
|
||||
}
|
||||
}
|
||||
|
||||
// Go 标准库 IsPrivate 只覆盖 RFC1918 与 fd00::/8,这里补齐其余不应出网的内部/特殊网段
|
||||
var extraPrivateNets = mustParseCIDRs(
|
||||
"100.64.0.0/10", // CGNAT:运营商级 NAT、云内网、Tailscale 等
|
||||
@@ -99,7 +116,7 @@ func IsPrivateIP(ip net.IP) bool {
|
||||
// Used in handlers to short-circuit requests to internal hosts before making outbound connections.
|
||||
// 用于在发起出站连接前,在处理器中短路对内部主机的请求。
|
||||
func HasLocalOrPrivateIP(host string) bool {
|
||||
ips, err := net.LookupIP(host)
|
||||
ips, err := resolveHostFn(context.Background(), host)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
@@ -142,7 +159,7 @@ func ValidateOutboundTarget(ctx context.Context, targetURL string) (context.Cont
|
||||
if parsed.Scheme != "http" && parsed.Scheme != "https" {
|
||||
return ctx, fmt.Errorf("invalid scheme: %s", parsed.Scheme)
|
||||
}
|
||||
ips, err := net.LookupIP(host)
|
||||
ips, err := resolveHostFn(ctx, host)
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
}
|
||||
@@ -179,7 +196,7 @@ func SecureCheckRedirect(req *http.Request, via []*http.Request) error {
|
||||
if len(via) >= 10 {
|
||||
return fmt.Errorf("stopped after 10 redirects")
|
||||
}
|
||||
ips, err := net.LookupIP(host)
|
||||
ips, err := resolveHostFn(req.Context(), host)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
package webtest
|
||||
|
||||
// EO(EdgeOne)特供版的 DNS 模块:与主线 ipw-cn/src/webtest/dns.go 同源,
|
||||
// 但保留 EO 部署形态的两点差异:
|
||||
// 1. DoH / UDP 双通道互备(单地址配置下主通道失败自动回退另一通道);
|
||||
// 2. 查询耗时沿调用链透出(float64 毫秒),供上层(tcping 的 ResolveHostWith 等)复用。
|
||||
// 主线对 dns.go 的行为修正与新增能力已同步至此:Rcode 透出、服务器地址格式校验、
|
||||
// 请求级解析配置(dns=/dns4=/dns6=、resolve=/resolve4=/resolve6=,经 context 透传)、
|
||||
// ResolveByType 统一分发、各 Resolve*Record 的 servers 参数化。
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -26,15 +38,13 @@ var dnsMode = "doh"
|
||||
// dnsServers 普通 DNS 查询服务器列表(主从:第一个为主,主失败自动切换后续从服务器)
|
||||
var dnsServers []string
|
||||
|
||||
// dnssecServers DNSSEC 专用服务器列表(未配置时沿用 dnsServers)
|
||||
var dnssecServers []string
|
||||
// dnssecServers DNSSEC 专用服务器列表:默认内置实测支持 DO 位的境外解析器
|
||||
//(国内公共 DNS 带 DO 也不返回 RRSIG,普通解析回退会让验签永远失败,见 dnssec.go)。
|
||||
// 网络屏蔽/劫持这些 UDP 53 时请配置 dnssec-server 指向可达的解析器。
|
||||
var dnssecServers = defaultDOCapableServers
|
||||
|
||||
type DNSResult struct {
|
||||
Domain string `json:"domain"`
|
||||
Duration float64 `json:"duration"`
|
||||
Record []string `json:"record"`
|
||||
TTL uint32 `json:"ttl"`
|
||||
}
|
||||
// defaultUDPServer 兜底 UDP 服务器
|
||||
const defaultUDPServer = "119.28.28.28:53"
|
||||
|
||||
// SetDNSServer 设置 DNS 服务器:支持逗号分隔多地址主从 failover(第一个为主,主失败自动切换后续从服务器)。
|
||||
// 每项支持 "ip:port"(UDP)或 DoH URL http(s)://...;单地址时保持原有语义。
|
||||
@@ -42,15 +52,22 @@ func SetDNSServer(server string) {
|
||||
if server == "" {
|
||||
return
|
||||
}
|
||||
list := splitServers(server)
|
||||
// dns-server 既能由本地管理面 PATCH 改,也能由远端托管配置下发 —— 都是外部可控输入。
|
||||
// 在这里先挡掉畸形值,总比留到查询时才以"莫名其妙的超时/报错"暴露好排查;
|
||||
// 全部非法时保留原有配置(与"空串不覆盖"的既有语义一致)。
|
||||
list := validServers(splitServers(server))
|
||||
if len(list) == 0 {
|
||||
slog.Warn("all DNS server addresses invalid, keeping previous config", "server", server)
|
||||
return
|
||||
}
|
||||
dnsServers = list
|
||||
// 兼容单地址的旧语义:URL → DoH 主通道;ip:port → UDP 主通道
|
||||
if len(list) == 1 {
|
||||
if strings.HasPrefix(server, "http://") || strings.HasPrefix(server, "https://") {
|
||||
dohEndpoint = server
|
||||
if strings.HasPrefix(list[0], "http://") || strings.HasPrefix(list[0], "https://") {
|
||||
dohEndpoint = list[0]
|
||||
dnsMode = "doh"
|
||||
} else {
|
||||
dnsServer = server
|
||||
dnsServer = list[0]
|
||||
dnsMode = "udp"
|
||||
}
|
||||
}
|
||||
@@ -58,7 +75,7 @@ func SetDNSServer(server string) {
|
||||
|
||||
// SetDNSSecServer 设置 DNSSEC 专用 DNS 服务器(逗号分隔主从;留空 = 沿用 dns-server 配置)
|
||||
func SetDNSSecServer(server string) {
|
||||
if list := splitServers(server); len(list) > 0 {
|
||||
if list := validServers(splitServers(server)); len(list) > 0 {
|
||||
dnssecServers = list
|
||||
}
|
||||
}
|
||||
@@ -75,6 +92,274 @@ func splitServers(s string) []string {
|
||||
return out
|
||||
}
|
||||
|
||||
// validServers 过滤掉格式非法的地址(保留原顺序)。
|
||||
//
|
||||
// dns-server / dnssec-server 既能由本地管理面 PATCH 改,也能由远端托管配置下发 —— 都是外部可控输入。
|
||||
// 在这里先挡掉畸形值,总比留到查询时才以"莫名其妙的超时/报错"暴露好排查。
|
||||
// 全部非法时返回空列表,调用方据此保留原有配置(与"空串不覆盖"的既有语义一致)。
|
||||
func validServers(list []string) []string {
|
||||
out := make([]string, 0, len(list))
|
||||
for _, s := range list {
|
||||
if err := validateServerAddr(s); err != nil {
|
||||
slog.Warn("ignored invalid DNS server address", "server", s, "error", err)
|
||||
continue
|
||||
}
|
||||
out = append(out, s)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// validateServerAddr 校验单个 DNS 服务器地址的格式:
|
||||
// - DoH URL:必须是 http/https 且 host 非空(**不限制私网** —— 节点自建内网 DoH 是合理部署);
|
||||
// - UDP/TCP:必须是 host:port 且端口合法。
|
||||
//
|
||||
// 注意:UDP 形式**不禁止私有地址** —— 节点上跑本地缓存解析器(127.0.0.1:53、内网 10.x:53)是常见部署,
|
||||
// 它是节点侧基础设施配置、不是被拨测目标,一并堵掉会直接让 DNS 拨测失效。
|
||||
func validateServerAddr(server string) error {
|
||||
if strings.HasPrefix(server, "http://") || strings.HasPrefix(server, "https://") {
|
||||
u, err := url.Parse(server)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if u.Hostname() == "" {
|
||||
return fmt.Errorf("missing host")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
host, port, err := net.SplitHostPort(server)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if strings.TrimSpace(host) == "" {
|
||||
return fmt.Errorf("missing host")
|
||||
}
|
||||
if p, err := strconv.Atoi(port); err != nil || p < 1 || p > 65535 {
|
||||
return fmt.Errorf("invalid port %q", port)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// NormalizeServers 解析「逗号分隔的 DNS 服务器」字符串并做格式校验,规则与配置侧一致:
|
||||
// 每项为 "ip:port"(UDP/TCP)或 http(s):// DoH URL;非法项丢弃(记 Warn)。全非法时返回空。
|
||||
// 供请求级参数(dns / dns4 / dns6)复用,避免两套校验漂移。
|
||||
func NormalizeServers(s string) []string {
|
||||
return validServers(splitServers(s))
|
||||
}
|
||||
|
||||
// ---- 请求级解析配置:dns*/resolve* ----
|
||||
//
|
||||
// dns=1.1.1.1:53 两栈都用这个服务器(换服务器去问)
|
||||
// dns4=1.1.1.1:53,dns6=[2400::1]:53 按栈覆盖(优先于 dns=)
|
||||
// resolve=example.com:1.2.3.4 两栈都把 example.com 解析成 1.2.3.4(直接改答案)
|
||||
// resolve4=example.com:1.2.3.4 只 IPv4 侧生效(优先于 resolve=)
|
||||
// resolve6=example.com:[::1] 只 IPv6 侧生效(优先于 resolve=)
|
||||
// resolve=www.example.com:origin.net 目标是域名时把它当作新的 host 再解析
|
||||
//
|
||||
// 只在「域名 → IP」这一步生效:detail/ssl/speed(经 DialContext)、tcping、SSRF 预检;
|
||||
// whois 与 dns 拨测不接 resolve*(前者只做归属查询,后者问的就是真实解析)。
|
||||
//
|
||||
// 为什么走 context:HTTP 拨测的解析发生在 net/http 的 DialContext 里,那里只有 ctx、
|
||||
// 没有直接入参;存进 ctx 后 DialContext 与 SSRF 预检便能同源读到同一份配置。
|
||||
|
||||
// ReqResolve 一次拨测的请求级解析配置。零值 = 没有任何请求级覆盖。
|
||||
type ReqResolve struct {
|
||||
dns []string // dns=
|
||||
dns4 []string // dns4=
|
||||
dns6 []string // dns6=
|
||||
|
||||
resolve map[string]string // resolve=:域名 → IP 或另一域名
|
||||
resolve4 map[string]string // resolve4=
|
||||
resolve6 map[string]string // resolve6=
|
||||
}
|
||||
|
||||
// ParseReqResolve 从 query 解析全部 9 个参数(dns/dns4/dns6、resolve/resolve4/resolve6)。
|
||||
// 参数存在但**全部项非法**时报错(handler 返 400),避免「看起来指定了、实际被静默忽略」;
|
||||
// 缺省/为空则视为不覆盖。
|
||||
func ParseReqResolve(get func(string) string) (ReqResolve, error) {
|
||||
var out ReqResolve
|
||||
// DNS 服务器:逗号分隔的 ip:port 或 DoH URL
|
||||
for _, item := range []struct {
|
||||
key string
|
||||
dst *[]string
|
||||
}{
|
||||
{"dns", &out.dns}, {"dns4", &out.dns4}, {"dns6", &out.dns6},
|
||||
} {
|
||||
if raw := strings.TrimSpace(get(item.key)); raw != "" {
|
||||
if list := NormalizeServers(raw); len(list) > 0 {
|
||||
*item.dst = list
|
||||
} else {
|
||||
return ReqResolve{}, fmt.Errorf("%s must be a comma-separated list of ip:port or DoH URLs", item.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 强制解析:逗号分隔的 域名:IP 或 域名:域名(后者按新 host 再解析)
|
||||
for _, item := range []struct {
|
||||
key string
|
||||
dst *map[string]string
|
||||
}{
|
||||
{"resolve", &out.resolve}, {"resolve4", &out.resolve4}, {"resolve6", &out.resolve6},
|
||||
} {
|
||||
if raw := strings.TrimSpace(get(item.key)); raw != "" {
|
||||
if m := parseResolveMap(raw); len(m) > 0 {
|
||||
*item.dst = m
|
||||
} else {
|
||||
return ReqResolve{}, fmt.Errorf("%s must be a comma-separated list of host:ip or host:cname", item.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// parseResolveMap 把「域名:目标,域名:目标」切成映射表,非法项丢弃。
|
||||
// 每组按**第一个冒号**切:域名不含冒号,IPv6 目标可带或不带方括号。
|
||||
func parseResolveMap(s string) map[string]string {
|
||||
out := map[string]string{}
|
||||
for _, item := range strings.Split(s, ",") {
|
||||
item = strings.TrimSpace(item)
|
||||
idx := strings.Index(item, ":")
|
||||
if idx <= 0 || idx == len(item)-1 {
|
||||
continue
|
||||
}
|
||||
host, target := canonicalHost(item[:idx]), strings.TrimSpace(item[idx+1:])
|
||||
if host == "" || strings.ContainsAny(host, " /\\") || !validResolveTarget(target) {
|
||||
continue
|
||||
}
|
||||
out[host] = target
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// canonicalHost 归一化主机名:去首尾空白、转小写、去结尾的点,便于与查询域名匹配。
|
||||
func canonicalHost(host string) string {
|
||||
return strings.ToLower(strings.TrimSuffix(strings.TrimSpace(host), "."))
|
||||
}
|
||||
|
||||
// validResolveTarget 目标必须是 IP 或形如域名的字符串(含点、无空格、无端口)。
|
||||
func validResolveTarget(target string) bool {
|
||||
t := strings.Trim(target, "[]")
|
||||
if net.ParseIP(t) != nil {
|
||||
return true
|
||||
}
|
||||
// 非 IP 却含冒号:视为「带端口」的误用,丢弃(映射不需要端口)
|
||||
if strings.Contains(t, ":") || !strings.Contains(t, ".") || strings.ContainsAny(t, " /\\") {
|
||||
return false
|
||||
}
|
||||
for _, r := range t {
|
||||
if r >= 'a' && r <= 'z' || r >= 'A' && r <= 'Z' || r >= '0' && r <= '9' ||
|
||||
r == '.' || r == '-' || r == '_' || r == '*' {
|
||||
continue
|
||||
}
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Empty 无任何请求级覆盖(此时才允许走共享缓存)。
|
||||
func (r ReqResolve) Empty() bool {
|
||||
return len(r.dns)+len(r.dns4)+len(r.dns6)+len(r.resolve)+len(r.resolve4)+len(r.resolve6) == 0
|
||||
}
|
||||
|
||||
// Servers 按栈名取本次生效的 DNS 服务器:stack 为 "ipv4"/"ipv6" 时优先取对应覆盖,
|
||||
// 其余(含空串)取 dns= 默认;最终为 nil 表示用配置 dns-server。
|
||||
// 供 whois、dns 拨测等按记录类型选栈的调用方使用。
|
||||
func (r ReqResolve) Servers(stack string) []string {
|
||||
switch stack {
|
||||
case "ipv4":
|
||||
if len(r.dns4) > 0 {
|
||||
return r.dns4
|
||||
}
|
||||
case "ipv6":
|
||||
if len(r.dns6) > 0 {
|
||||
return r.dns6
|
||||
}
|
||||
}
|
||||
return r.dns
|
||||
}
|
||||
|
||||
// Override 返回该域名在指定族下的强制解析目标;"" 表示未命中(照常走 DNS)。
|
||||
// 优先级与 dns* 对称:resolve4/resolve6 非空时覆盖 resolve。
|
||||
// 目标是 IP 还是域名由调用方判断——IP 直连、域名当作新 host 再解析。
|
||||
func (r ReqResolve) Override(host string, wantV6 bool) string {
|
||||
m := r.resolve
|
||||
if wantV6 && len(r.resolve6) > 0 {
|
||||
m = r.resolve6
|
||||
} else if !wantV6 && len(r.resolve4) > 0 {
|
||||
m = r.resolve4
|
||||
}
|
||||
return m[canonicalHost(host)]
|
||||
}
|
||||
|
||||
// CacheKey 返回请求级配置的规范化片段,拼在拨测缓存键末尾。
|
||||
// 零值返回空串(缓存键与「没有任何请求级参数」时完全一致);
|
||||
// 否则形如 ";dns=1.1.1.1:53,8.8.8.8:53;resolve6=example.com:[::1]"。
|
||||
//
|
||||
// 逐字段拼接而不是 join 结构体:字段名与顺序由这里固定,避免参数书写顺序
|
||||
// (dns= 在前还是 dns6= 在前)把同一个请求拆成两条缓存。
|
||||
func (r ReqResolve) CacheKey() string {
|
||||
var b strings.Builder
|
||||
for _, f := range []struct {
|
||||
name string
|
||||
vals []string
|
||||
}{
|
||||
{"dns", r.dns}, {"dns4", r.dns4}, {"dns6", r.dns6},
|
||||
} {
|
||||
if len(f.vals) == 0 {
|
||||
continue
|
||||
}
|
||||
b.WriteString(";")
|
||||
b.WriteString(f.name)
|
||||
b.WriteString("=")
|
||||
b.WriteString(strings.Join(f.vals, ","))
|
||||
}
|
||||
for _, f := range []struct {
|
||||
name string
|
||||
vals map[string]string
|
||||
}{
|
||||
{"resolve", r.resolve}, {"resolve4", r.resolve4}, {"resolve6", r.resolve6},
|
||||
} {
|
||||
if len(f.vals) == 0 {
|
||||
continue
|
||||
}
|
||||
// map 迭代顺序随机:必须按键排序,否则同一请求每次拼出的键都不同,缓存永远命不中
|
||||
keys := make([]string, 0, len(f.vals))
|
||||
for k := range f.vals {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
pairs := make([]string, 0, len(keys))
|
||||
for _, k := range keys {
|
||||
pairs = append(pairs, k+":"+f.vals[k])
|
||||
}
|
||||
b.WriteString(";")
|
||||
b.WriteString(f.name)
|
||||
b.WriteString("=")
|
||||
b.WriteString(strings.Join(pairs, ","))
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// reqResolveCtxKey 请求级解析配置在 context 中的键。
|
||||
type reqResolveCtxKey struct{}
|
||||
|
||||
// WithReqResolve 把请求级解析配置写进 context(空配置原样返回,零开销)。
|
||||
func WithReqResolve(ctx context.Context, r ReqResolve) context.Context {
|
||||
if r.Empty() {
|
||||
return ctx
|
||||
}
|
||||
return context.WithValue(ctx, reqResolveCtxKey{}, r)
|
||||
}
|
||||
|
||||
// ReqResolveFromContext 取出请求级解析配置(零值 = 无覆盖)。
|
||||
func ReqResolveFromContext(ctx context.Context) ReqResolve {
|
||||
if ctx == nil {
|
||||
return ReqResolve{}
|
||||
}
|
||||
if v, ok := ctx.Value(reqResolveCtxKey{}).(ReqResolve); ok {
|
||||
return v
|
||||
}
|
||||
return ReqResolve{}
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// ⭐️ 底层核心:DoH + UDP 双通道 DNS 查询
|
||||
// ==========================================
|
||||
@@ -112,6 +397,15 @@ func queryDNSSECMsg(msg *dns.Msg) (*dns.Msg, float64, error) {
|
||||
return queryDNSMsg(msg)
|
||||
}
|
||||
|
||||
// queryOne 向单个 DNS 服务器查询:配置为 URL(http/https)走 DoH,否则走 UDP
|
||||
//(DNSSEC 的 DO 能力探测按服务器逐台试探,需要单发入口)
|
||||
func queryOne(msg *dns.Msg, server string) (*dns.Msg, float64, error) {
|
||||
if strings.HasPrefix(server, "http://") || strings.HasPrefix(server, "https://") {
|
||||
return queryDoHMsg(msg, server)
|
||||
}
|
||||
return queryUDPMsg(msg, server)
|
||||
}
|
||||
|
||||
// queryWithServers 依次尝试服务器列表,主失败切从;每个服务器按类型走 DoH 或 UDP
|
||||
func queryWithServers(msg *dns.Msg, servers []string) (*dns.Msg, float64, error) {
|
||||
if len(servers) == 0 {
|
||||
@@ -119,14 +413,7 @@ func queryWithServers(msg *dns.Msg, servers []string) (*dns.Msg, float64, error)
|
||||
}
|
||||
var lastErr error
|
||||
for i, srv := range servers {
|
||||
var resp *dns.Msg
|
||||
var dur float64
|
||||
var err error
|
||||
if strings.HasPrefix(srv, "http://") || strings.HasPrefix(srv, "https://") {
|
||||
resp, dur, err = queryDoHMsg(msg, srv)
|
||||
} else {
|
||||
resp, dur, err = queryUDPMsg(msg, srv)
|
||||
}
|
||||
resp, dur, err := queryOne(msg, srv)
|
||||
if err == nil {
|
||||
return resp, dur, nil
|
||||
}
|
||||
@@ -139,9 +426,6 @@ func queryWithServers(msg *dns.Msg, servers []string) (*dns.Msg, float64, error)
|
||||
return nil, 0, lastErr
|
||||
}
|
||||
|
||||
// defaultUDPServer 兜底 UDP 服务器
|
||||
const defaultUDPServer = "119.28.28.28:53"
|
||||
|
||||
// queryUDPMsg 通过 UDP/TCP 向指定 DNS 服务器发送查询(miekg/dns 自动处理大响应切 TCP)
|
||||
func queryUDPMsg(msg *dns.Msg, server string) (*dns.Msg, float64, error) {
|
||||
client := &dns.Client{Timeout: 5 * time.Second}
|
||||
@@ -154,7 +438,12 @@ func queryUDPMsg(msg *dns.Msg, server string) (*dns.Msg, float64, error) {
|
||||
return resp, duration, nil
|
||||
}
|
||||
|
||||
// queryDoHMsg 通过 DoH(RFC 8484,POST application/dns-message)向指定端点发送查询
|
||||
// queryDoHMsg 通过 DoH(RFC 8484,POST application/dns-message)向指定端点发送查询。
|
||||
//
|
||||
// 这里**刻意不做私网/回环拦截**(与 website / ssl / speed 那三处不同):
|
||||
// endpoint 来自 dns-server 配置,而节点上自建内网 DoH(127.0.0.1 / 10.x)是合理部署,
|
||||
// 堵私网会直接打死功能;配置又是管理员凭据才能改的,不构成匿名可达攻击面。
|
||||
// 地址**格式**校验已在 SetDNSServer 入口由 validateServerAddr 完成(http/https + host 非空)。
|
||||
func queryDoHMsg(msg *dns.Msg, endpoint string) (*dns.Msg, float64, error) {
|
||||
packedMsg, err := msg.Pack()
|
||||
if err != nil {
|
||||
@@ -192,247 +481,191 @@ func queryDoHMsg(msg *dns.Msg, endpoint string) (*dns.Msg, float64, error) {
|
||||
// 业务层:构造查询并经双通道执行,提取特定记录
|
||||
// ==========================================
|
||||
|
||||
// executeDoHQuery 构造标准 DNS 请求报文并经双通道执行。
|
||||
//
|
||||
// **不再把 Rcode 非 Success 当错误**:解析器明确应答(哪怕 NXDOMAIN / SERVFAIL)说明网络与
|
||||
// 解析链路是通的,属合法业务结果,由上层透出 Rcode;只有传输/网络层失败才返回 error。
|
||||
// 若在此处返回 error,上层 dnsQueryHandler 会回 500,前端把「域名不存在」显示成「节点故障」。
|
||||
func executeDoHQuery(domain string, qtype uint16) (*dns.Msg, float64, error) {
|
||||
// 1. 构造标准的 DNS 请求报文
|
||||
msg := new(dns.Msg)
|
||||
msg.SetQuestion(dns.Fqdn(domain), qtype)
|
||||
msg.RecursionDesired = true // 请求递归解析
|
||||
|
||||
// 2. 双通道查询(DoH 主 + UDP 备,或反之)
|
||||
responseMsg, duration, err := queryDNSMsg(msg)
|
||||
if err != nil {
|
||||
return nil, duration, err
|
||||
}
|
||||
|
||||
// 3. 检查 DNS 响应码 (Rcode)
|
||||
if responseMsg.Rcode != dns.RcodeSuccess {
|
||||
return responseMsg, duration, fmt.Errorf("DNS query failed with Rcode %d", responseMsg.Rcode)
|
||||
}
|
||||
|
||||
return responseMsg, duration, nil
|
||||
return queryDNSMsg(msg)
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// 业务层:调用底层函数并提取特定记录
|
||||
// ==========================================
|
||||
// DNSResult 统一的 DNS 查询结果格式。
|
||||
//
|
||||
// Rcode / RcodeText 与主线及各节点保持一致:解析器明确应答 NXDOMAIN 时,属于「域名不存在」
|
||||
// 这个业务结论,而不是节点故障 —— 前端据此区分两者,别把负响应误显示成拨测失败。
|
||||
type DNSResult struct {
|
||||
Domain string `json:"domain"`
|
||||
Duration float64 `json:"duration"`
|
||||
Record []string `json:"record"`
|
||||
TTL uint32 `json:"ttl"`
|
||||
Rcode int `json:"rcode"` // 解析器应答的 Rcode(0=Success, 3=NXDOMAIN)
|
||||
RcodeText string `json:"rcode_text"` // Rcode 可读名称,如 NXDOMAIN / SERVFAIL
|
||||
}
|
||||
|
||||
func ResolveARecord(domain string) (DNSResult, error) {
|
||||
// resolveTyped 通用记录查询:成功收到解析器应答(即便 Rcode 非 Success,如 NXDOMAIN/SERVFAIL)
|
||||
// 即视为一次有效查询,将 Rcode 透出并返回 200;仅在传输/网络层失败(超时、服务器不可达、
|
||||
// DoH 异常)时才返回 error(上层据此返回 500)。避免把合法的负响应误判为节点故障。
|
||||
// extract 从一个 RR 中抽取记录字符串(TXT 可能含多条),返回 (values, ttl, matched)。
|
||||
// servers 为请求级 DNS 覆盖:非空时用它(queryWithServers),为空则用配置 dns-server
|
||||
//(EO:配置列表也为空时回退 DoH/UDP 双通道互备,见 queryDNSMsg)。
|
||||
func resolveTyped(domain, name string, qtype uint16, servers []string, extract func(dns.RR) ([]string, uint32, bool)) (DNSResult, error) {
|
||||
msg := new(dns.Msg)
|
||||
msg.SetQuestion(dns.Fqdn(name), qtype)
|
||||
// EO 保留:主线不显式设 RD;EO 双通道历史上始终请求递归解析,改动会影响各边缘节点
|
||||
msg.RecursionDesired = true
|
||||
result := DNSResult{Domain: domain, Record: []string{}}
|
||||
responseMsg, duration, err := executeDoHQuery(domain, dns.TypeA)
|
||||
|
||||
// 请求级 servers 优先;未传(nil/空)走配置 dns-server。
|
||||
var response *dns.Msg
|
||||
var duration float64
|
||||
var err error
|
||||
if len(servers) > 0 {
|
||||
response, duration, err = queryWithServers(msg, servers)
|
||||
} else {
|
||||
response, duration, err = queryDNSMsg(msg)
|
||||
}
|
||||
result.Duration = duration
|
||||
if err != nil {
|
||||
slog.Warn("Failed to query A", "domain", domain, "err", err)
|
||||
slog.Warn("Failed to query DNS", "domain", domain, "qtype", qtype, "error", err)
|
||||
return result, err
|
||||
}
|
||||
for _, ans := range responseMsg.Answer {
|
||||
if aRecord, ok := ans.(*dns.A); ok {
|
||||
result.Record = append(result.Record, aRecord.A.String())
|
||||
|
||||
// 解析器已应答:无论 Rcode 是否为 Success,都属合法结果,不再当 error 返回
|
||||
result.Rcode = response.Rcode
|
||||
result.RcodeText = dns.RcodeToString[response.Rcode]
|
||||
for _, ans := range response.Answer {
|
||||
if values, ttl, ok := extract(ans); ok {
|
||||
result.Record = append(result.Record, values...)
|
||||
if result.TTL == 0 {
|
||||
result.TTL = aRecord.Header().Ttl
|
||||
result.TTL = ttl
|
||||
}
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func ResolveAAAARecord(domain string) (DNSResult, error) {
|
||||
result := DNSResult{Domain: domain, Record: []string{}}
|
||||
responseMsg, duration, err := executeDoHQuery(domain, dns.TypeAAAA)
|
||||
result.Duration = duration
|
||||
if err != nil {
|
||||
slog.Warn("Failed to query AAAA", "domain", domain, "err", err)
|
||||
return result, err
|
||||
}
|
||||
for _, ans := range responseMsg.Answer {
|
||||
if aRecord, ok := ans.(*dns.AAAA); ok {
|
||||
result.Record = append(result.Record, aRecord.AAAA.String())
|
||||
if result.TTL == 0 {
|
||||
result.TTL = aRecord.Header().Ttl
|
||||
}
|
||||
// ---- 记录解析:每类一个函数,末个参数 servers 为「请求级 DNS 覆盖」 ----
|
||||
//
|
||||
// servers 为空 → 走 resolveTyped 的 queryDNSMsg(配置 dns-server,EO 未配置时双通道互备);
|
||||
// 非空 → queryWithServers(请求级覆盖)。
|
||||
|
||||
func ResolveARecord(domain string, servers []string) (DNSResult, error) {
|
||||
return resolveTyped(domain, domain, dns.TypeA, servers, func(rr dns.RR) ([]string, uint32, bool) {
|
||||
if a, ok := rr.(*dns.A); ok {
|
||||
return []string{a.A.String()}, a.Header().Ttl, true
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
return nil, 0, false
|
||||
})
|
||||
}
|
||||
|
||||
func ResolveTXTRecord(domain string) (DNSResult, error) {
|
||||
result := DNSResult{Domain: domain, Record: []string{}}
|
||||
responseMsg, duration, err := executeDoHQuery(domain, dns.TypeTXT)
|
||||
result.Duration = duration
|
||||
if err != nil {
|
||||
slog.Warn("Failed to query TXT", "domain", domain, "err", err)
|
||||
return result, err
|
||||
}
|
||||
for _, ans := range responseMsg.Answer {
|
||||
if txtRecord, ok := ans.(*dns.TXT); ok {
|
||||
result.Record = append(result.Record, txtRecord.Txt...)
|
||||
if result.TTL == 0 {
|
||||
result.TTL = txtRecord.Header().Ttl
|
||||
}
|
||||
func ResolveAAAARecord(domain string, servers []string) (DNSResult, error) {
|
||||
return resolveTyped(domain, domain, dns.TypeAAAA, servers, func(rr dns.RR) ([]string, uint32, bool) {
|
||||
if a, ok := rr.(*dns.AAAA); ok {
|
||||
return []string{a.AAAA.String()}, a.Header().Ttl, true
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
return nil, 0, false
|
||||
})
|
||||
}
|
||||
|
||||
func ResolveNSRecord(domain string) (DNSResult, error) {
|
||||
result := DNSResult{Domain: domain, Record: []string{}}
|
||||
responseMsg, duration, err := executeDoHQuery(domain, dns.TypeNS)
|
||||
result.Duration = duration
|
||||
if err != nil {
|
||||
slog.Warn("Failed to query NS", "domain", domain, "err", err)
|
||||
return result, err
|
||||
}
|
||||
for _, ans := range responseMsg.Answer {
|
||||
if nsRecord, ok := ans.(*dns.NS); ok {
|
||||
result.Record = append(result.Record, nsRecord.Ns)
|
||||
if result.TTL == 0 {
|
||||
result.TTL = nsRecord.Header().Ttl
|
||||
}
|
||||
func ResolveTXTRecord(domain string, servers []string) (DNSResult, error) {
|
||||
return resolveTyped(domain, domain, dns.TypeTXT, servers, func(rr dns.RR) ([]string, uint32, bool) {
|
||||
if txt, ok := rr.(*dns.TXT); ok {
|
||||
// TXT 一条 RR 可能含多段字符串,保持原有「逐段单独成项」的行为
|
||||
return txt.Txt, txt.Header().Ttl, true
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
return nil, 0, false
|
||||
})
|
||||
}
|
||||
|
||||
func ResolveCNAMERecord(domain string) (DNSResult, error) {
|
||||
result := DNSResult{Domain: domain, Record: []string{}}
|
||||
responseMsg, duration, err := executeDoHQuery(domain, dns.TypeCNAME)
|
||||
result.Duration = duration
|
||||
if err != nil {
|
||||
slog.Warn("Failed to query CNAME", "domain", domain, "err", err)
|
||||
return result, err
|
||||
}
|
||||
for _, ans := range responseMsg.Answer {
|
||||
if cnameRecord, ok := ans.(*dns.CNAME); ok {
|
||||
result.Record = append(result.Record, cnameRecord.Target)
|
||||
if result.TTL == 0 {
|
||||
result.TTL = cnameRecord.Header().Ttl
|
||||
}
|
||||
func ResolveNSRecord(domain string, servers []string) (DNSResult, error) {
|
||||
return resolveTyped(domain, domain, dns.TypeNS, servers, func(rr dns.RR) ([]string, uint32, bool) {
|
||||
if ns, ok := rr.(*dns.NS); ok {
|
||||
return []string{ns.Ns}, ns.Header().Ttl, true
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
return nil, 0, false
|
||||
})
|
||||
}
|
||||
|
||||
func ResolveMXRecord(domain string) (DNSResult, error) {
|
||||
result := DNSResult{Domain: domain, Record: []string{}}
|
||||
responseMsg, duration, err := executeDoHQuery(domain, dns.TypeMX)
|
||||
result.Duration = duration
|
||||
if err != nil {
|
||||
slog.Warn("Failed to query MX", "domain", domain, "err", err)
|
||||
return result, err
|
||||
}
|
||||
for _, ans := range responseMsg.Answer {
|
||||
if mxRecord, ok := ans.(*dns.MX); ok {
|
||||
result.Record = append(result.Record, mxRecord.Mx)
|
||||
if result.TTL == 0 {
|
||||
result.TTL = mxRecord.Header().Ttl
|
||||
}
|
||||
func ResolveCNAMERecord(domain string, servers []string) (DNSResult, error) {
|
||||
return resolveTyped(domain, domain, dns.TypeCNAME, servers, func(rr dns.RR) ([]string, uint32, bool) {
|
||||
if cname, ok := rr.(*dns.CNAME); ok {
|
||||
return []string{cname.Target}, cname.Header().Ttl, true
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
return nil, 0, false
|
||||
})
|
||||
}
|
||||
|
||||
func ResolveSRVRecord(domain string) (DNSResult, error) {
|
||||
result := DNSResult{Domain: domain, Record: []string{}}
|
||||
responseMsg, duration, err := executeDoHQuery(domain, dns.TypeSRV)
|
||||
result.Duration = duration
|
||||
if err != nil {
|
||||
slog.Warn("Failed to query SRV", "domain", domain, "err", err)
|
||||
return result, err
|
||||
}
|
||||
for _, ans := range responseMsg.Answer {
|
||||
if srvRecord, ok := ans.(*dns.SRV); ok {
|
||||
result.Record = append(result.Record, srvRecord.Target)
|
||||
if result.TTL == 0 {
|
||||
result.TTL = srvRecord.Header().Ttl
|
||||
}
|
||||
func ResolveMXRecord(domain string, servers []string) (DNSResult, error) {
|
||||
return resolveTyped(domain, domain, dns.TypeMX, servers, func(rr dns.RR) ([]string, uint32, bool) {
|
||||
if mx, ok := rr.(*dns.MX); ok {
|
||||
return []string{mx.Mx}, mx.Header().Ttl, true
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
return nil, 0, false
|
||||
})
|
||||
}
|
||||
|
||||
func ResolvePTRRecord(ip string) (DNSResult, error) {
|
||||
result := DNSResult{Domain: ip, Record: []string{}}
|
||||
func ResolveSRVRecord(domain string, servers []string) (DNSResult, error) {
|
||||
return resolveTyped(domain, domain, dns.TypeSRV, servers, func(rr dns.RR) ([]string, uint32, bool) {
|
||||
if srv, ok := rr.(*dns.SRV); ok {
|
||||
return []string{srv.Target}, srv.Header().Ttl, true
|
||||
}
|
||||
return nil, 0, false
|
||||
})
|
||||
}
|
||||
|
||||
func ResolveCAARecord(domain string, servers []string) (DNSResult, error) {
|
||||
return resolveTyped(domain, domain, dns.TypeCAA, servers, func(rr dns.RR) ([]string, uint32, bool) {
|
||||
if caa, ok := rr.(*dns.CAA); ok {
|
||||
return []string{caa.Value}, caa.Header().Ttl, true
|
||||
}
|
||||
return nil, 0, false
|
||||
})
|
||||
}
|
||||
|
||||
// ResolvePTRRecord 反查 IP 的 PTR 记录(返回的 Domain 保持为原始 IP,便于前端直接展示)
|
||||
func ResolvePTRRecord(ip string, servers []string) (DNSResult, error) {
|
||||
ptrName, err := dns.ReverseAddr(ip)
|
||||
if err != nil {
|
||||
return result, fmt.Errorf("invalid IP: %v", err)
|
||||
slog.Warn("Invalid IP address for PTR query", "ip", ip, "error", err)
|
||||
return DNSResult{Domain: ip, Record: []string{}}, fmt.Errorf("invalid IP address: %v", err)
|
||||
}
|
||||
|
||||
responseMsg, duration, err := executeDoHQuery(ptrName, dns.TypePTR)
|
||||
result.Duration = duration
|
||||
result.Domain = ip // 保持返回的 Domain 为原始 IP
|
||||
|
||||
if err != nil {
|
||||
slog.Warn("Failed to query PTR", "ip", ip, "err", err)
|
||||
return result, err
|
||||
}
|
||||
for _, ans := range responseMsg.Answer {
|
||||
if ptrRecord, ok := ans.(*dns.PTR); ok {
|
||||
result.Record = append(result.Record, ptrRecord.Ptr)
|
||||
if result.TTL == 0 {
|
||||
result.TTL = ptrRecord.Header().Ttl
|
||||
}
|
||||
return resolveTyped(ip, ptrName, dns.TypePTR, servers, func(rr dns.RR) ([]string, uint32, bool) {
|
||||
if ptr, ok := rr.(*dns.PTR); ok {
|
||||
return []string{ptr.Ptr}, ptr.Header().Ttl, true
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
return nil, 0, false
|
||||
})
|
||||
}
|
||||
|
||||
func ResolveCAARecord(domain string) (DNSResult, error) {
|
||||
result := DNSResult{Domain: domain, Record: []string{}}
|
||||
responseMsg, duration, err := executeDoHQuery(domain, dns.TypeCAA)
|
||||
result.Duration = duration
|
||||
if err != nil {
|
||||
slog.Warn("Failed to query CAA", "domain", domain, "err", err)
|
||||
return result, err
|
||||
// ResolveByType 按记录类型名(a/aaaa/cname/mx/ns/txt/srv/ptr/caa)解析,servers 为请求级覆盖。
|
||||
// DNS 拨测的 HTTP 路由统一走这里,与主线保持同构,避免 handler 各维护一套 switch。
|
||||
func ResolveByType(domain, recodeType string, servers []string) (DNSResult, error) {
|
||||
switch recodeType {
|
||||
case "a":
|
||||
return ResolveARecord(domain, servers)
|
||||
case "aaaa":
|
||||
return ResolveAAAARecord(domain, servers)
|
||||
case "cname":
|
||||
return ResolveCNAMERecord(domain, servers)
|
||||
case "mx":
|
||||
return ResolveMXRecord(domain, servers)
|
||||
case "ns":
|
||||
return ResolveNSRecord(domain, servers)
|
||||
case "srv":
|
||||
return ResolveSRVRecord(domain, servers)
|
||||
case "txt":
|
||||
return ResolveTXTRecord(domain, servers)
|
||||
case "ptr":
|
||||
return ResolvePTRRecord(domain, servers)
|
||||
case "caa":
|
||||
return ResolveCAARecord(domain, servers)
|
||||
}
|
||||
for _, ans := range responseMsg.Answer {
|
||||
if caaRecord, ok := ans.(*dns.CAA); ok {
|
||||
result.Record = append(result.Record, caaRecord.Value)
|
||||
if result.TTL == 0 {
|
||||
result.TTL = caaRecord.Header().Ttl
|
||||
}
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ResolveIP 通过 DoH 解析域名,返回指定版本(v4/v6)的 IP 地址字符串
|
||||
func ResolveIP(host string, version string) (string, error) {
|
||||
if ip := net.ParseIP(host); ip != nil {
|
||||
if version == "v4" && ip.To4() != nil {
|
||||
return ip.String(), nil
|
||||
}
|
||||
if version == "v6" && ip.To4() == nil && ip.To16() != nil {
|
||||
return ip.String(), nil
|
||||
}
|
||||
return "", fmt.Errorf("no %s address found for %s", version, host)
|
||||
}
|
||||
|
||||
var qtype uint16
|
||||
switch version {
|
||||
case "v6":
|
||||
qtype = dns.TypeAAAA
|
||||
default:
|
||||
qtype = dns.TypeA
|
||||
}
|
||||
|
||||
responseMsg, _, err := executeDoHQuery(host, qtype)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
for _, ans := range responseMsg.Answer {
|
||||
switch v := ans.(type) {
|
||||
case *dns.A:
|
||||
if qtype == dns.TypeA {
|
||||
return v.A.String(), nil
|
||||
}
|
||||
case *dns.AAAA:
|
||||
if qtype == dns.TypeAAAA {
|
||||
return v.AAAA.String(), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "", fmt.Errorf("no %s record found for %s", version, host)
|
||||
return DNSResult{}, fmt.Errorf("unsupported record type: %s", recodeType)
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
@@ -451,19 +684,21 @@ type DNSFullResult struct {
|
||||
CAA DNSResult `json:"caa"`
|
||||
}
|
||||
|
||||
func ResolveARecordllDNSRecords(domain string) DNSFullResult {
|
||||
// ResolveARecordllDNSRecords 并行查询所有主流DNS记录类型(不包含PTR)。
|
||||
// servers 为请求级 DNS 覆盖(空则用配置 dns-server)。
|
||||
func ResolveARecordllDNSRecords(domain string, servers []string) DNSFullResult {
|
||||
result := DNSFullResult{Domain: domain}
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(8)
|
||||
|
||||
go func() { defer wg.Done(); result.A, _ = ResolveARecord(domain) }()
|
||||
go func() { defer wg.Done(); result.AAAA, _ = ResolveAAAARecord(domain) }()
|
||||
go func() { defer wg.Done(); result.CNAME, _ = ResolveCNAMERecord(domain) }()
|
||||
go func() { defer wg.Done(); result.MX, _ = ResolveMXRecord(domain) }()
|
||||
go func() { defer wg.Done(); result.NS, _ = ResolveNSRecord(domain) }()
|
||||
go func() { defer wg.Done(); result.TXT, _ = ResolveTXTRecord(domain) }()
|
||||
go func() { defer wg.Done(); result.SRV, _ = ResolveSRVRecord(domain) }()
|
||||
go func() { defer wg.Done(); result.CAA, _ = ResolveCAARecord(domain) }()
|
||||
go func() { defer wg.Done(); result.A, _ = ResolveARecord(domain, servers) }()
|
||||
go func() { defer wg.Done(); result.AAAA, _ = ResolveAAAARecord(domain, servers) }()
|
||||
go func() { defer wg.Done(); result.CNAME, _ = ResolveCNAMERecord(domain, servers) }()
|
||||
go func() { defer wg.Done(); result.MX, _ = ResolveMXRecord(domain, servers) }()
|
||||
go func() { defer wg.Done(); result.NS, _ = ResolveNSRecord(domain, servers) }()
|
||||
go func() { defer wg.Done(); result.TXT, _ = ResolveTXTRecord(domain, servers) }()
|
||||
go func() { defer wg.Done(); result.SRV, _ = ResolveSRVRecord(domain, servers) }()
|
||||
go func() { defer wg.Done(); result.CAA, _ = ResolveCAARecord(domain, servers) }()
|
||||
|
||||
wg.Wait()
|
||||
return result
|
||||
|
||||