Dawnline 0.20.0
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / Backend (Go: vet, tests, a real ubusd and uhttpd) (push) Blocked by required conditions
CI / Package files (push) Blocked by required conditions
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / Backend (Go: vet, tests, a real ubusd and uhttpd) (push) Blocked by required conditions
CI / Package files (push) Blocked by required conditions
- **Backend rewritten in Go.** One daemon, `dawnlined`, replaces the whole ucode backend: the rpcd plugin, the agent, the CLI and the updater. The package no longer depends on ucode. - **Per-architecture builds.** The release carries the backend for arm64, ARMv7, mips, mipsle and amd64; the router fetches its own after the package is installed and checks its sha256. Dawnline does not run on other architectures (older ARM, 32-bit x86, RISC-V). - **Faster on the router.** A firewall sync takes 0.06 s instead of 0.9 s; a full apply takes about 300 ms. The portal is served by the daemon itself, without a CGI process per request. - **Live pages.** The admin and the portal follow a live stream from the router instead of re-fetching the whole state every 30 seconds. - **Admin redesigned in the portal's style.** Three sections (Overview · Log · Settings); a server is a page of its own with People, Places and Settings; a device opens as a dialog over its person. - **Changes wait for «Apply».** Every setting, and a person's access, is staged in one dock before it reaches the router. - **Configuration rollout.** After a change that makes devices fetch their configuration again, the admin shows how many have fetched it and who has not. Every setting shows beforehand (⟳N) how many devices it will touch. - **Waiting for a decision.** Overview and People put first the people who need one (access ended, limit reached, a device that does not connect), each with its one action a tap away. - **Bulk actions on people.** «Select» (or a long press on a card) picks several people to extend by a month, pause or resume at once. - **Undo.** An action done from a card or a request is undone from its toast. - **Update dialogs redesigned.** An update is one view from its question to its result; Dawnline's own update runs in it like every other, and the page reloads itself once the new version answers. Other versions are a list, each with its notes and Install on a page of its own. - **Site to site: networks behind a router.** A router connected as a device can have networks behind it (up to eight, /16 to /30): the server routes them and applies the router's access to them. A network that shares addresses with a tunnel, the router's own networks or another site is refused by name. - **Routers from the portal.** People can add a router and name its networks on their own page; the admin accepts or declines with a reason, or lets them through without asking. - **Check access and Health know the networks behind routers.** - **Usage limits reworked.** A monthly limit no longer follows the calendar. A person's month starts with their first traffic and ends a month later; the next one starts only when they connect again, so time away uses up none of it. Before, everyone's limit reset on the 1st. - Extra data lasts until that person's month ends; «Reset usage» starts the month anew. - A limit is for a month or for the whole term; the admin and the portal show when it resets. - Charts that said «this month» show the last 30 days. - After the update nobody loses what was counted: the month that was running becomes the person's first and ends on the 1st. - **Access by time of day removed.** The Hours limit is gone from the admin, the portal and the backend; saved hours are dropped. - **Expiry simplified.** An end date always stops access, with a heads-up three days before; the per-person choice is gone. - **No false disconnects from sleeping phones.** A phone or a tablet stays online through ten minutes of silence. - **Mobile Safari fixes.** Pressing a control no longer sends the page to its top; tab tracks that do not fit scroll; switches animate after a press.
This commit is contained in:
1 parent
f8130e39a8
commit
ac90575b0b
788 files changed
+139244
-41720
No files matched your search
@@ -0,0 +1,171 @@
|
||||
// Package updater is Dawnline's background update worker (usr/libexec/dawnline/updater and the modules it
|
||||
// ran: dawnline.updates, upd_app, upd_awg, upd_pkgs, awg_builds), started detached by the backend and by
|
||||
// the minute's chores:
|
||||
//
|
||||
// updater check [app|amneziawg|packages]
|
||||
// updater install app | app@<tag> | app:reinstall | app:rollback
|
||||
// updater install amneziawg[:auto|slava|grey[:ru]] | amneziawg:rollback
|
||||
// updater install pkgs:<name,…>
|
||||
// updater auto (Settings → Updates: check, then install)
|
||||
//
|
||||
// One job at a time: the job holds the update lock until it exits. Progress: update-job.json; check
|
||||
// results: update-check.json. The Components tab reads both.
|
||||
package updater
|
||||
|
||||
import (
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/tickcount/luci-app-dawnline/backend/files"
|
||||
)
|
||||
|
||||
// Repo is where Dawnline's own releases are.
|
||||
const Repo = "tickcount/luci-app-dawnline"
|
||||
|
||||
// Targets is what a check looks at.
|
||||
var Targets = []string{"app", "amneziawg", "packages"}
|
||||
|
||||
// lock takes the update lock without waiting: the open file (kept for the whole job; the kernel releases
|
||||
// it when the process ends), or nil when another job holds it.
|
||||
func lock(run string) *os.File {
|
||||
os.MkdirAll(run, 0o755)
|
||||
f, err := os.OpenFile(run+"/update.lock", os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0o644)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if syscall.Flock(int(f.Fd()), syscall.LOCK_EX|syscall.LOCK_NB) != nil {
|
||||
f.Close()
|
||||
return nil
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
// historyAdd puts an entry at the head of the history (Components → Activity): newest first, the last 30
|
||||
// kept on flash.
|
||||
func historyAdd(data string, now int64, e map[string]any) {
|
||||
var h []map[string]any
|
||||
files.ReadJSON(data+"/update-history.json", &h)
|
||||
e["ts"] = now
|
||||
h = append([]map[string]any{e}, h...)
|
||||
if len(h) > 30 {
|
||||
h = h[:30]
|
||||
}
|
||||
os.MkdirAll(data, 0o700)
|
||||
files.WriteJSON(data+"/update-history.json", h, 0o600)
|
||||
}
|
||||
|
||||
var (
|
||||
versionShape = regexp.MustCompile(`^([0-9.]+)([-~]([0-9A-Za-z.]+))?`)
|
||||
preShape = regexp.MustCompile(`^([^0-9]*)([0-9]*)`)
|
||||
)
|
||||
|
||||
// VersionCmp compares Dawnline release versions (0.3.2, v0.4.0-rc1): -1, 0 or 1. Numbers compare as
|
||||
// numbers; a pre-release (-rc1, -beta) comes before its release.
|
||||
func VersionCmp(a, b string) int {
|
||||
type parsed struct {
|
||||
nums []int
|
||||
pre string
|
||||
hasPre bool
|
||||
}
|
||||
parse := func(v string) parsed {
|
||||
m := versionShape.FindStringSubmatch(strings.TrimPrefix(v, "v"))
|
||||
if m == nil {
|
||||
return parsed{[]int{0}, v, true}
|
||||
}
|
||||
var nums []int
|
||||
for _, x := range strings.Split(m[1], ".") {
|
||||
n, _ := strconv.Atoi(x)
|
||||
nums = append(nums, n)
|
||||
}
|
||||
return parsed{nums, m[3], m[2] != ""}
|
||||
}
|
||||
x, y := parse(a), parse(b)
|
||||
for i := 0; i < len(x.nums) || i < len(y.nums); i++ {
|
||||
p, r := 0, 0
|
||||
if i < len(x.nums) {
|
||||
p = x.nums[i]
|
||||
}
|
||||
if i < len(y.nums) {
|
||||
r = y.nums[i]
|
||||
}
|
||||
if p != r {
|
||||
if p < r {
|
||||
return -1
|
||||
}
|
||||
return 1
|
||||
}
|
||||
}
|
||||
switch {
|
||||
case x.hasPre == y.hasPre && x.pre == y.pre:
|
||||
return 0
|
||||
case !x.hasPre:
|
||||
return 1
|
||||
case !y.hasPre:
|
||||
return -1
|
||||
}
|
||||
// rc1 < rc2 < rc10: the number runs compare as numbers
|
||||
px, py := preShape.FindStringSubmatch(x.pre), preShape.FindStringSubmatch(y.pre)
|
||||
if px[1] != py[1] {
|
||||
if px[1] < py[1] {
|
||||
return -1
|
||||
}
|
||||
return 1
|
||||
}
|
||||
nx, _ := strconv.Atoi(px[2])
|
||||
ny, _ := strconv.Atoi(py[2])
|
||||
switch {
|
||||
case nx < ny:
|
||||
return -1
|
||||
case nx > ny:
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Kept is the version a component had before its last update (Keep the previous version).
|
||||
type Kept struct {
|
||||
Version string `json:"version"`
|
||||
Build any `json:"build"`
|
||||
Firmware any `json:"firmware"`
|
||||
Files []string `json:"files"`
|
||||
Saved int64 `json:"saved"`
|
||||
}
|
||||
|
||||
// kept is the kept version of a component, or nil (none, or its files are gone).
|
||||
func kept(data, component string) *Kept {
|
||||
var k Kept
|
||||
if !files.ReadJSON(data+"/keep/"+component+"/meta.json", &k) || k.Version == "" || len(k.Files) == 0 {
|
||||
return nil
|
||||
}
|
||||
for _, f := range k.Files {
|
||||
if _, err := os.Stat(f); err != nil {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return &k
|
||||
}
|
||||
|
||||
// keep replaces the kept version of a component with these files (copied in); all of them, or nothing.
|
||||
func keep(data, component, version string, paths []string, build, firmware any) {
|
||||
dir := data + "/keep/" + component
|
||||
os.RemoveAll(dir)
|
||||
os.MkdirAll(dir, 0o700)
|
||||
os.Chmod(data+"/keep", 0o700)
|
||||
var saved []string
|
||||
for _, f := range paths {
|
||||
raw, err := os.ReadFile(f)
|
||||
to := dir + "/" + f[strings.LastIndex(f, "/")+1:]
|
||||
if err != nil || os.WriteFile(to, raw, 0o600) != nil {
|
||||
os.RemoveAll(dir)
|
||||
return
|
||||
}
|
||||
saved = append(saved, to)
|
||||
}
|
||||
files.WriteJSON(dir+"/meta.json", Kept{Version: version, Build: build, Firmware: firmware, Files: saved, Saved: time.Now().Unix()}, 0o600)
|
||||
}
|
||||
|
||||
func forget(data, component string) { os.RemoveAll(data + "/keep/" + component) }
|
||||
Reference in new issue
Block a user