Dawnline 0.4.0
Build packages / Version (push) Waiting to run

- Components tab replaces Updates: Dawnline, the AmneziaWG build for this
  firmware (Slava-Shchipunov 2.0 or 2Grey 3.1, Russian translation) and
  the system packages Dawnline adds, each checked, installed, reinstalled
  or rolled back in place, with What's new, versions and an activity log
- Automatic updates: daily check, install at a set time or right away,
  per component; AmneziaWG is left out by default and an automatic run
  never switches its build or generation
- Downloads verified against GitHub's sha256; mirrors are used only when
  GitHub is unreachable and the hash is known
- New installer: checks firmware, clock, space and DNS, lets you pick a
  release, shows the plan and asks first; --dry-run
- New uninstaller removes everything Dawnline added (cron, nft, firewall,
  routing, interfaces, packages it installed); --dry-run
- Works without AmneziaWG on the router: Overview, the setup wizard,
  Health and Components say what is missing and offer to install it
- Overview shows failed health checks as notices with their fix
- People list no longer reads the config from the browser: private keys
  stay on the router; personal links are fetched on demand
- Config changes are serialized under one lock, the nft table loads
  atomically and fails closed, and Dawnline never touches network
  sections it did not create
- The portal never opens system ports, keeps disabled devices disabled,
  rate-limits per address and counts days by the router's clock
- Settings and Diagnostics load their heavy parts in the background
- Release notes are written from the commits since the previous release
- Backend and admin UI split into small single-purpose modules
This commit is contained in:
Aemeath committed 2026-10-16 02:14:15 +03:00
1 parent 70a932b8ea
commit 34293fb8e5
158 files changed
+17418 -10022

No files matched your search

+5 -3
View File
@@ -16,9 +16,11 @@ ssh "$HOST" sh <<'REMOTE'
rm -rf /tmp/dlc && mkdir -p /tmp/dlc && tar -xzf /tmp/dl-check.tgz -C /tmp/dlc && rm /tmp/dl-check.tgz
cd /tmp/dlc
rc=0
for f in usr/share/ucode/dawnline/*.uc; do
n=$(basename "$f" .uc)
out=$(ucode -L '/tmp/dlc/usr/share/ucode/*.uc' -e "import * as x from 'dawnline.$n';" 2>&1) || { echo "FAIL $f"; echo "$out" | head -8; rc=1; }
# Modules by their import name: dawnline/x.uc is dawnline.x, dawnline/rpc/x.uc dawnline.rpc.x.
for f in usr/share/ucode/dawnline/*.uc usr/share/ucode/dawnline/rpc/*.uc; do
[ -f "$f" ] || continue
n=$(echo "${f#usr/share/ucode/}" | sed 's/\.uc$//; s#/#.#g')
out=$(ucode -L '/tmp/dlc/usr/share/ucode/*.uc' -e "import * as x from '$n';" 2>&1) || { echo "FAIL $f"; echo "$out" | head -8; rc=1; }
done
for f in usr/share/rpcd/ucode/luci.dawnline usr/libexec/dawnline/agent usr/libexec/dawnline/updater usr/bin/dawnline usr/share/dawnline/portal/www/cgi-bin/portal; do
[ -f "$f" ] || continue
+92 -12
View File
@@ -3,35 +3,56 @@
ucode resolves names where they are used: calling a function that is declared
further down the same file fails at runtime ("access to undeclared variable").
Also: calls and named imports must match what a Dawnline module exports, and
the rpcd methods (dawnline.rpc.*) must match the plugin and its ACL.
Run: scripts/lint-ucode.py [package root]
"""
import glob
import json
import os
import re
import sys
root = sys.argv[1] if len(sys.argv) > 1 else os.path.join(os.path.dirname(__file__), '..', 'package', 'luci-app-dawnline', 'root')
files = glob.glob(f"{root}/usr/share/ucode/dawnline/*.uc") + [
f"{root}/usr/share/rpcd/ucode/luci.dawnline",
MODDIR = f"{root}/usr/share/ucode/dawnline"
PLUGIN = f"{root}/usr/share/rpcd/ucode/luci.dawnline"
ACL = f"{root}/usr/share/rpcd/acl.d/luci-app-dawnline.json"
modules = sorted(glob.glob(f"{MODDIR}/*.uc") + glob.glob(f"{MODDIR}/rpc/*.uc"))
files = modules + [
PLUGIN,
f"{root}/usr/libexec/dawnline/agent",
f"{root}/usr/libexec/dawnline/updater",
f"{root}/usr/libexec/dawnline/resolver",
f"{root}/usr/bin/dawnline",
f"{root}/usr/share/dawnline/portal/www/cgi-bin/portal",
]
files = [f for f in files if os.path.exists(f)]
bad = 0
checked = 0
def problem(msg):
global bad
print(msg)
bad = 1
def strip_comments(text):
return re.sub(r'//[^\n]*|/\*.*?\*/', '', text, flags=re.S)
def modname(path):
"""dawnline/rpc/people.uc → 'rpc.people' (as in import … from 'dawnline.rpc.people')."""
rel = os.path.relpath(path, MODDIR)[:-3]
return rel.replace(os.sep, '.')
for f in files:
if not os.path.exists(f):
continue
checked += 1
code = re.sub(r'//[^\n]*|/\*.*?\*/', '', open(f, encoding='utf-8').read(), flags=re.S)
code = strip_comments(open(f, encoding='utf-8').read())
defs = {m.group(1): m.start() for m in re.finditer(r'^(?:export )?function (\w+)\(', code, re.M)}
for name, pos in defs.items():
for m in re.finditer(r'(?<![\w.\'"`])' + name + r'\(', code[:pos]):
line = code[: m.start()].count('\n') + 1
print(f"{f}:{line}: {name}() is used before its definition")
bad = 1
problem(f"{f}:{line}: {name}() is used before its definition")
# In a module an exported function is an expression statement: its closing
# brace needs a semicolon ("Expecting ';'" breaks the whole module).
lines = open(f, encoding='utf-8').read().split('\n')
@@ -41,8 +62,67 @@ for f in files:
inside = n
elif inside is not None and re.match(r'^}', text):
if not text.startswith('};'):
print(f"{f}:{n}: exported function from line {inside} must end with '}};'")
bad = 1
problem(f"{f}:{n}: exported function from line {inside} must end with '}};'")
inside = None
print(f"lint-ucode: {checked} files checked" + (", problems found" if bad else ", ok"))
# ucode regexes are POSIX: a (?: group fails when the line runs ("Repetition
# not preceded by valid expression"), and let [a, b] = … does not compile.
if re.search(r'/[^/\n]*\(\?[:=!][^/\n]*/', text):
problem(f"{f}:{n}: ucode regexes are POSIX: no (?: (?= (?! groups")
if re.match(r'\s*(let|const)\s*[\[{]', text):
problem(f"{f}:{n}: ucode has no destructuring")
# Calls into another Dawnline module (alias.fn(...)) and named imports must name
# something it exports: one removed from a module but still used elsewhere only
# fails at runtime.
exports = {}
for f in modules:
text = open(f, encoding='utf-8').read()
exports[modname(f)] = set(re.findall(r'^export (?:function|const|let) (\w+)', text, re.M))
for f in files:
code = strip_comments(open(f, encoding='utf-8').read())
for alias, mod in re.findall(r"import \* as (\w+) from 'dawnline\.([\w.]+)'", code):
if mod not in exports:
problem(f"{f}: imports dawnline.{mod}, which does not exist")
continue
# Calls, and constants (upper case: a lower-case "geo.json" in a string is no access).
for m in re.finditer(r'(?<![\w.])' + alias + r'\.(\w+\(|[A-Z][A-Z0-9_]*\b)', code):
name = m.group(1).rstrip('(')
if name not in exports[mod]:
line = code[: m.start()].count('\n') + 1
problem(f"{f}:{line}: {alias}.{name} is not exported by dawnline.{mod}")
for names, mod in re.findall(r"import \{([^}]*)\} from 'dawnline\.([\w.]+)'", code):
if mod not in exports:
problem(f"{f}: imports dawnline.{mod}, which does not exist")
continue
for name in re.split(r'\s*,\s*', names.strip()):
name = re.split(r'\s+as\s+', name)[0].strip()
if name and name not in exports[mod]:
problem(f"{f}: {name} is not exported by dawnline.{mod}")
# rpcd methods: every rpc module's `methods` is merged by the plugin, no name is
# defined twice (the later one would silently win), and the ACL's read list
# names methods that exist.
methods = {}
for f in glob.glob(f"{MODDIR}/rpc/*.uc"):
text = strip_comments(open(f, encoding='utf-8').read())
m = re.search(r'^export const methods = \{\n(.*?)^\};', text, re.M | re.S)
if not m:
continue
mod = modname(f)
if os.path.exists(PLUGIN) and f"from 'dawnline.{mod}'" not in open(PLUGIN, encoding='utf-8').read():
problem(f"{PLUGIN}: does not import dawnline.{mod}, whose methods would be missing")
for name in re.findall(r"^\t'?(\w+)'?: \{", m.group(1), re.M):
if name in methods:
problem(f"{f}: method {name} is also defined in dawnline.{methods[name]}")
methods[name] = mod
if methods and os.path.exists(ACL):
acl = json.load(open(ACL, encoding='utf-8'))['luci-app-dawnline']
for kind in ('read', 'write'):
for name in acl.get(kind, {}).get('ubus', {}).get('luci.dawnline', []):
if name != '*' and name not in methods:
problem(f"{ACL}: {kind} lists {name}, which no dawnline.rpc module defines")
if 'uci' in acl.get(kind, {}) and 'dawnline' in acl[kind]['uci']:
problem(f"{ACL}: {kind} grants uci 'dawnline' (private keys, no validation): use the rpc methods")
print(f"lint-ucode: {len(files)} files checked" + (", problems found" if bad else ", ok"))
sys.exit(bad)
+72
View File
@@ -0,0 +1,72 @@
#!/bin/sh
# shellcheck shell=dash
#
# Release notes for a tag, from the commits since the previous tag:
# scripts/release-notes.sh v0.3.1 [repository]
# PREV_TAG=v0.1.1 scripts/release-notes.sh v0.3.0 (compare with another tag)
#
# Release commits ("Dawnline 0.3.1") list their changes as "- " lines in the
# body: those become the points. Other commits add their title; merges are
# skipped. Wrapped points are joined into one line, so the Components tab
# (and anything else reading the release) gets one change per line.
set -eu
TAG="${1:?usage: release-notes.sh <tag> [owner/repo]}"
REPO="${2:-tickcount/luci-app-dawnline}"
git rev-parse -q --verify "$TAG^{commit}" >/dev/null || {
echo "release-notes: no tag $TAG" >&2
exit 1
}
# The previous release: the nearest older tag, or PREV_TAG when a tag was never published.
PREV="${PREV_TAG:-$(git describe --tags --abbrev=0 --match 'v[0-9]*' "$TAG^" 2>/dev/null || true)}"
if [ -n "$PREV" ] && ! git rev-parse -q --verify "$PREV^{commit}" >/dev/null; then
echo "release-notes: no tag $PREV" >&2
exit 1
fi
RANGE="$TAG"
[ -n "$PREV" ] && RANGE="$PREV..$TAG"
# git log runs alone first: a failure must stop the script, not vanish into the pipe.
git log --no-merges --format='%s' "$RANGE" >/dev/null
# One record per commit, newest first: the subject, then the body; records end with RS (\036).
points="$(git log --no-merges --format='%s%n%b%x1e' "$RANGE" | awk '
BEGIN { RS = "\036" }
{
n = split($0, line, "\n")
title = ""
for (i = 1; i <= n; i++) if (line[i] != "") { title = line[i]; start = i + 1; break }
if (title == "") next
got = 0; cur = ""
for (i = start; i <= n; i++) {
if (line[i] ~ /^[ \t]*[-*][ \t]+/) {
if (cur != "") { print "- " cur; got = 1 }
cur = line[i]; sub(/^[ \t]*[-*][ \t]+/, "", cur)
} else if (cur != "" && line[i] ~ /^[ \t]+[^ \t]/) {
l = line[i]; sub(/^[ \t]+/, "", l); cur = cur " " l
} else if (cur != "") { print "- " cur; got = 1; cur = "" }
}
if (cur != "") { print "- " cur; got = 1 }
# A release commit without a list says nothing new; any other commit is its title.
if (!got && title !~ /^(Dawnline )?v?[0-9]+\.[0-9]+(\.[0-9]+)?$/) print "- " title
}')"
if [ -n "$points" ]; then
printf "## What’s new\n\n%s\n\n" "$points"
fi
cat <<EOF
## Install
Install or upgrade on the router (OpenWrt 24.10 with opkg, or 25.12 with apk):
\`\`\`sh
sh -c "\$(wget -qO- https://raw.githubusercontent.com/$REPO/main/install.sh)"
\`\`\`
Or update from LuCI → Network → Dawnline → Components.
EOF
if [ -n "$PREV" ]; then
printf '\n**Full Changelog**: https://github.com/%s/compare/%s...%s\n' "$REPO" "$PREV" "$TAG"
else
printf '\n**Full Changelog**: https://github.com/%s/commits/%s\n' "$REPO" "$TAG"
fi