Files
drouter/_dev/probe-opensoho2.sh
liuzhuohua 64df3cf331 feat: Drouter 1.0.0 —— Debian 13 软路由管理系统
一套跑在 Debian 13 (trixie) 上的软路由管理系统,提供 43 个功能页面的
Web 管理面板:WAN 接入、PPPoE 多拨、DHCP/DNS、IPv6、防火墙、QoS 限速、
访问控制、DDNS、文件共享、Docker 管理等。

核心设计原则:不重新实现任何协议
  PPPoE 交给 ppp,DHCP 交给 dnsmasq,IPv6 RA 交给 radvd,NAT 交给 nftables。
  Web 面板只做三件事:渲染原生配置文件 → 语法预检 → 原子写入并 reload。
  面板删掉后,系统仍是一台配置完好的 Debian 路由器。

安全默认值
  · 安装后不接管网络:不改默认路由、不开 IP 转发、不启动 DHCP 服务
  · 所有改网络的动作都需要用户在面板上亲手点「应用」
  · 避开 5900 端口,不触碰 VNC / X 会话
  · 配置写入前先做语法预检,失败则回滚

架构
  · backend/  Python 3 标准库,零第三方依赖(9 个模块)
  · web/      原生 JS/CSS,无构建步骤
  · 常驻 helper 通过 Unix socket 提供 75 个动作,socket 不可用时回退 subprocess
  · 鉴权走 X-Token 请求头

打包
  · packaging/build-deb.sh            → drouter_1.0.0_all.deb(含 6 个 systemd 单元)
  · scripts/make-offline-deps.sh      → 236 个依赖 .deb + 本地仓库索引
  · packaging/build-offline-bundle.sh → 自包含离线包,目标机零外网可装
  · packaging/build-docker.sh         → 容器镜像(体验用)

测试
  40 套单元测试 + 3 个前端检查脚本(菜单映射 / 离线渲染 / 手机适配),
  全部挂在 devtools/sync.sh 的预检链里。

许可:MIT
2026-09-30 19:26:24 +08:00

79 lines
3.0 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# OpenSOHO 探测第 2 轮:带 secret 跑 superuser,拿 token,列真实集合名
set -u
SECRET='probe-secret-probe-secret-probe-32'
BIN=/tmp/opensoho
DIR=/tmp/oh-probe2
LOG=/tmp/oh-probe2.log
PORT=8099
export OPENSOHO_SHARED_SECRET="$SECRET"
echo "=== 0. 检查上轮是否污染了 home 目录 ==="
ls -ld /home/ajeef/pb_data 2>&1 || echo "(无 pb_data,--dir 生效了)"
echo
echo "=== 1. --help(带 secret) ==="
"$BIN" --help 2>&1 | head -40
echo
echo "=== 2. --dir 是否真生效(对比两处 pb_data) ==="
rm -rf "$DIR" "$LOG" /tmp/oh-nodir; mkdir -p "$DIR"
OPENSOHO_SHARED_SECRET="$SECRET" nohup "$BIN" serve --http 127.0.0.1:$PORT --dir "$DIR" > "$LOG" 2>&1 &
for i in $(seq 1 30); do curl -sf -o /dev/null "http://127.0.0.1:$PORT/api/health" && break; sleep 1; done
echo "-- $DIR 下 --"; ls "$DIR" 2>&1 | head
echo "-- /home/ajeef/pb_data --"; ls /home/ajeef/pb_data 2>&1 | head -3
echo
echo "=== 3. superuser upsert(带 secret) ==="
"$BIN" superuser upsert probe@drouter.local 'ProbePass12345' --dir "$DIR" 2>&1 | head -20
echo "退出码=$?"
echo "-- 再跑一次(幂等?) --"
"$BIN" superuser upsert probe@drouter.local 'ProbePass12345' --dir "$DIR" 2>&1 | head -10
echo "退出码=$?"
echo
echo "=== 4. 登录取 token ==="
RESP=$(curl -s -X POST "http://127.0.0.1:$PORT/api/collections/_superusers/auth-with-password" \
-H 'Content-type: application/json' \
-d '{"identity":"probe@drouter.local","password":"ProbePass12345"}')
echo "响应前 200 字:${RESP:0:200}"
TOK=$(echo "$RESP" | python3 -c 'import sys,json;print(json.load(sys.stdin).get("token",""))' 2>/dev/null)
echo "token 长度=${#TOK}"
echo
echo "=== 5. 列出所有集合名 ==="
curl -s -H "Authorization: $TOK" "http://127.0.0.1:$PORT/api/collections?perPage=200" \
| python3 -c 'import sys,json
try:
d=json.load(sys.stdin)
except Exception as e:
print("解析失败", e); raise SystemExit
items=d.get("items",[])
print("共", d.get("totalItems"), "个集合")
for c in items:
sch=c.get("schema") or {}
print(" -", c.get("name"), "| type=", c.get("type"), "| fields=", ",".join((sch.get("schema") if isinstance(sch,dict) and "schema" in sch else sch).keys())[:160] if isinstance(sch,dict) else "")
' 2>&1 | head -40
echo
echo "=== 6. settings 集合(superuser 后) ==="
curl -s -H "Authorization: $TOK" "http://127.0.0.1:$PORT/api/collections/settings/records?perPage=50" | head -c 800; echo
echo
echo "=== 7. devicestatus v1(带 token) ==="
curl -s -w '\nHTTP=%{http_code}\n' -H "Authorization: $TOK" "http://127.0.0.1:$PORT/api/v1/devicestatus/00:11:22:33:44:55"
echo
echo "=== 8. 根目录有哪些 v1 路由(盲探几个) ==="
for p in /api/v1/devicestatus /api/v1/devices /api/v1/status /api/v1/device/00:11:22:33:44:55; do
printf '%-40s ' "$p"
curl -s -o /dev/null -w '%{http_code}\n' -H "Authorization: $TOK" "http://127.0.0.1:$PORT$p"
done
echo
echo "=== 9. 清理 ==="
pkill -f "$BIN serve"; sleep 2
rm -rf "$DIR" "$LOG" /home/ajeef/pb_data /tmp/oh-nodir
ss -lntp 2>/dev/null | grep -E ':(8099|8090)\b' || echo "端口已释放"
echo "DONE"