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

- **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:
Aemeath committed 2026-11-13 09:43:50 +03:00
1 parent f8130e39a8
commit ac90575b0b
788 files changed
+139244 -41720

No files matched your search

+186
View File
@@ -0,0 +1,186 @@
package methods
import (
"encoding/json"
"os"
"reflect"
"strings"
"testing"
"unicode"
"unicode/utf8"
"github.com/tickcount/luci-app-dawnline/backend/netview"
"github.com/tickcount/luci-app-dawnline/backend/store"
"github.com/tickcount/luci-app-dawnline/backend/uci"
"github.com/tickcount/luci-app-dawnline/backend/view"
)
// sitesStand is access's household on the golden's router (which has 192.168.50.0/24 and 192.168.77.0/24
// itself) with Boris's and Kira's devices made routers, and how often the full apply and the sync were
// asked for.
func sitesStand(t *testing.T) (d Deps, st *store.Store, dir string, applied, synced *int) {
t.Helper()
dir = t.TempDir()
text, _ := os.ReadFile("../access/testdata/access.uci")
c, err := uci.Parse(string(text))
if err != nil {
t.Fatal(err)
}
c.Set("bphone", "kind", "router")
c.Set("kphone", "kind", "router")
c.Set("lev", "device_limit", "10")
os.WriteFile(dir+"/dawnline", []byte(c.Format()), 0o600)
raw, err := os.ReadFile("../netview/testdata/trace.json")
if err != nil {
t.Fatal(err)
}
var router struct {
Routes json.RawMessage `json:"routes"`
Addrs json.RawMessage `json:"addrs"`
Links map[string]netview.Link `json:"links"`
}
if err := json.Unmarshal(raw, &router); err != nil {
t.Fatal(err)
}
applied, synced = new(int), new(int)
st = &store.Store{Config: dir + "/dawnline", RunDir: dir}
d = Deps{World: func() *view.World { return &view.World{} }, Store: st, Config: dir + "/dawnline", RunDir: dir, DataDir: dir + "/data",
Snapshot: func() *netview.Snapshot {
return netview.Take(netview.Sources{Routes: func() []byte { return router.Routes }, Addrs: func() []byte { return router.Addrs },
Links: func() map[string]netview.Link { return router.Links }})
},
AWG: func() map[string]any { return map[string]any{"tools": true, "kmod": true} },
Apply: func(string) map[string]any { *applied++; return map[string]any{"warning": nil} },
Sync: func(string) any { *synced++; return nil }}
// keys and ids as a row of made-up ones, each its own
keys, hex := newKeys, randHex
t.Cleanup(func() { newKeys, randHex = keys, hex })
n := 0
newKeys = func() Keys {
n++
k := func(c byte) string { return strings.Repeat(string(c), 41) + string(rune('A'+n)) + "A=" }
return Keys{Private: k('P'), Public: k('Q'), Preshared: k('R')}
}
made := 0
randHex = func(int) string { made++; return "0a0b0c0" + string(rune('0'+made)) }
return d, st, dir, applied, synced
}
// The networks behind a router, as the admin sets them: access's household on the golden's router (which
// has 192.168.50.0/24 and 192.168.77.0/24 itself), every refusal in its words, and the full apply asked
// for only when something changed.
func TestNetworksBehindARouter(t *testing.T) {
d, st, dir, ap, sy := sitesStand(t)
behind := func(id string) []string {
_, m, err := st.Read()
if err != nil {
t.Fatal(err)
}
return m.Devices[id].Behind
}
set := func(id string, nets ...any) map[string]any {
return ask(t, d, "device_networks", map[string]any{"id": id, "networks": nets})
}
// two networks, each told from its first address, the one written twice once
res := set("bphone", " 192.168.2.9/24 ", "172.20.0.0/16", "192.168.2.0/24", "")
if res["error"] != nil || !reflect.DeepEqual(behind("bphone"), []string{"192.168.2.0/24", "172.20.0.0/16"}) || *ap != 1 || *sy != 0 {
t.Fatalf("set: %v, %v, applied %d, synced %d", res, behind("bphone"), *ap, *sy)
}
if !reflect.DeepEqual(res["networks"], []string{"192.168.2.0/24", "172.20.0.0/16"}) {
t.Errorf("answered %v", res["networks"])
}
// the same again: nothing written, nothing applied
if res = set("bphone", "192.168.2.0/24", "172.20.0.0/16"); res["error"] != nil || *ap != 1 {
t.Errorf("the same list: %v, applied %d", res, *ap)
}
for _, r := range []struct {
id string
nets []any
want string
}{
{"bphone", []any{"192.168.2.0"}, "Network 192.168.2.0 is not written like 192.168.2.0/24."},
{"bphone", []any{"10.0.0.0/8"}, "Network 10.0.0.0/8 is too wide: /16 at the most."},
{"bphone", []any{"8.8.8.0/24"}, "Network 8.8.8.0/24 is not private (10.x, 172.16-31.x, 192.168.x)."},
{"bphone", []any{"192.168.4.0/24", "192.168.4.128/25"}, "Networks 192.168.4.0/24 and 192.168.4.128/25 share addresses."},
{"bphone", []any{"10.77.0.0/16"}, "Network 10.77.0.0/16 is taken: 10.77.0.0/24 is the tunnel network of Home. The two ends of a tunnel need different addresses."},
{"bphone", []any{"192.168.50.0/25"}, "Network 192.168.50.0/25 is taken: the router has 192.168.50.0/24 itself. The two ends of a tunnel need different addresses."},
{"kphone", []any{"172.20.5.0/24"}, "Network 172.20.5.0/24 is taken: 172.20.0.0/16 is behind Bphone (Boris). Two sites need different addresses."},
{"phone", []any{"192.168.9.0/24"}, "Only a router has networks behind it."},
{"nobody", []any{"192.168.9.0/24"}, "Unknown device."},
{"bphone", []any{"192.168.10.0/24", "192.168.11.0/24", "192.168.12.0/24", "192.168.13.0/24", "192.168.14.0/24", "192.168.15.0/24",
"192.168.16.0/24", "192.168.17.0/24", "192.168.18.0/24"}, "A router has 8 networks behind it at the most."},
} {
if res := set(r.id, r.nets...); res["error"] != r.want {
t.Errorf("%s %v: %v, want %q", r.id, r.nets, res["error"], r.want)
}
// the page shows a refusal as it came only when it begins as a sentence does (web/src/admin/failure.ts):
// one that began with the network's address would be read as a program's error
if first, _ := utf8.DecodeRuneInString(r.want); !unicode.IsUpper(first) {
t.Errorf("%q does not begin with a capital letter", r.want)
}
}
if *ap != 1 || !reflect.DeepEqual(behind("bphone"), []string{"192.168.2.0/24", "172.20.0.0/16"}) {
t.Errorf("a refusal wrote or applied: %d, %v", *ap, behind("bphone"))
}
// the names in a refusal are the settings' own
_, m, _ := st.Read()
if m.Servers["home"].Name != "Home" || m.Devices["bphone"].Name != "Bphone" || m.People["boris"].Name != "Boris" {
t.Fatalf("the household's names moved: %q, %q, %q", m.Servers["home"].Name, m.Devices["bphone"].Name, m.People["boris"].Name)
}
// none: the option goes, and the routes with it
if res = set("bphone"); res["error"] != nil || behind("bphone") != nil || *ap != 2 {
t.Errorf("none: %v, %v, applied %d", res, behind("bphone"), *ap)
}
if file, _ := os.ReadFile(dir + "/dawnline"); strings.Contains(string(file), "behind_net") {
t.Error("the option is still in the file")
}
// a router added with its networks is applied in full; another device is loaded by the sync, as before
res = ask(t, d, "device_create", map[string]any{"person": "lev", "name": "Dacha", "kind": "router", "networks": []any{"192.168.88.1/24"}})
if res["error"] != nil || res["id"] != "d_0a0b0c01" || !reflect.DeepEqual(behind("d_0a0b0c01"), []string{"192.168.88.0/24"}) || *ap != 3 || *sy != 0 {
t.Fatalf("a router with its network: %v, applied %d, synced %d", res["error"], *ap, *sy)
}
if res = ask(t, d, "device_create", map[string]any{"person": "lev", "name": "Tablet", "kind": "tablet", "networks": []any{"192.168.89.0/24"}}); res["error"] != "Only a router has networks behind it." {
t.Errorf("a tablet with a network: %v", res["error"])
}
if res = ask(t, d, "device_create", map[string]any{"person": "lev", "name": "Second", "kind": "router", "networks": []any{"192.168.88.128/25"}}); res["error"] !=
"Network 192.168.88.128/25 is taken: 192.168.88.0/24 is behind Dacha (Lev). Two sites need different addresses." {
t.Errorf("a second router on the first one's addresses: %v", res["error"])
}
if *ap != 3 || *sy != 0 {
t.Errorf("refusals applied: %d, %d", *ap, *sy)
}
// set up again as a phone: what is no router has nothing behind it
if res = ask(t, d, "device_rotate", map[string]any{"id": "d_0a0b0c01", "kind": "phone"}); res["error"] != nil || behind("d_0a0b0c01") != nil || *ap != 4 {
t.Errorf("a router made a phone: %v, %v, applied %d", res["error"], behind("d_0a0b0c01"), *ap)
}
// and the log has each change in its words
var details []string
for _, e := range journalOf(t, dir) {
if e["type"] == "device_changed" {
details = append(details, e["detail"].(string))
}
}
want := []string{"networks=192.168.2.0/24 172.20.0.0/16", "networks=none", "networks=192.168.88.0/24", "kind=phone, networks=none"}
if !reflect.DeepEqual(details, want) {
t.Errorf("logged %v, want %v", details, want)
}
}
// journalOf is the activity log a test's methods wrote, the oldest first.
func journalOf(t *testing.T, dir string) []map[string]any {
t.Helper()
var list []map[string]any
raw, err := os.ReadFile(dir + "/events.json")
if err != nil {
t.Fatal(err)
}
if err := json.Unmarshal(raw, &list); err != nil {
t.Fatal(err)
}
if len(list) > 1 && list[0]["ts"].(float64) > list[len(list)-1]["ts"].(float64) {
for i, j := 0, len(list)-1; i < j; i, j = i+1, j-1 {
list[i], list[j] = list[j], list[i]
}
}
return list
}