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

+78
View File
@@ -0,0 +1,78 @@
// Who is looking: producers of live state work only while a page shows it.
// A page that follows the stream says which topics it shows (with every
// question it asks, and a `watch` call for the ones it keeps open); each such
// word holds for a short while. Nothing asked, nobody subscribed: nothing is
// read from the tunnels for the pages, as before the stream existed.
package api
import (
"sync"
"time"
)
// Lease is how long a page's interest in a topic holds after it said so.
// Pages renew it at about a third of that.
const Lease = 30 * time.Second
// Audience remembers who looks at what.
type Audience struct {
mu sync.Mutex
until map[string]time.Time
stream bool
now func() time.Time
}
// NewAudience makes an empty audience.
func NewAudience() *Audience {
return &Audience{until: map[string]time.Time{}, now: time.Now}
}
// everything stands for a page that named no topic: it follows them all.
const everything = "*"
// Touch notes that someone looks at these topics now (none named: at all of
// them, which keeps the audience present but wakes no topic that must be
// asked for by name, like the meter).
func (a *Audience) Touch(topics []string) {
end := a.now().Add(Lease)
a.mu.Lock()
if len(topics) == 0 {
a.until[everything] = end
}
for _, t := range topics {
a.until[t] = end
}
a.mu.Unlock()
}
// Streaming notes whether the event stream has subscribers (ubusd tells).
func (a *Audience) Streaming(on bool) {
a.mu.Lock()
a.stream = on
a.mu.Unlock()
}
// Wants tells whether someone looked at the topic within the lease.
func (a *Audience) Wants(topic string) bool {
a.mu.Lock()
defer a.mu.Unlock()
return a.now().Before(a.until[topic])
}
// Present tells whether any page is there at all: one that follows the
// stream, or one that asked for anything within the lease.
func (a *Audience) Present() bool {
a.mu.Lock()
defer a.mu.Unlock()
if a.stream {
return true
}
now := a.now()
for t, end := range a.until {
if now.Before(end) {
return true
}
delete(a.until, t)
}
return false
}
+58
View File
@@ -0,0 +1,58 @@
// The stream side of the object: every event of the hub goes to the object's
// subscribers as a notification, in order, and a `ping` when nothing happened
// for a while (a page tells a dead connection from a quiet one by it; the
// ping carries the number the stream is at, so a page that missed the last
// event before a silence learns it).
package api
import (
"context"
"time"
"github.com/tickcount/luci-app-dawnline/backend/hub"
"github.com/tickcount/luci-app-dawnline/backend/ubus"
)
// PingEvery is the longest a stream stays silent.
const PingEvery = 15 * time.Second
// Notifier is the bus as the broadcast needs it.
type Notifier interface {
Notify(o *ubus.Object, kind string, data map[string]any) error
}
// Broadcast forwards the hub's events to the object's subscribers until ctx
// ends. A notification the bus did not take (ubusd away, an event over its
// size limit) is not retried: the next ping or event shows a page the gap,
// and it asks for what it missed with sync.
func Broadcast(ctx context.Context, h *hub.Hub, bus Notifier, o *ubus.Object) {
ping := time.NewTicker(PingEvery)
defer ping.Stop()
for ctx.Err() == nil {
sub := h.Follow()
follow(ctx, h, sub, bus, o, ping)
sub.Close()
}
}
// follow forwards one subscription's events; it returns when the hub let the
// subscription go (this side fell behind) or ctx ended.
func follow(ctx context.Context, h *hub.Hub, sub *hub.Sub, bus Notifier, o *ubus.Object, ping *time.Ticker) {
for {
select {
case <-ctx.Done():
return
case e, ok := <-sub.Events():
if !ok {
return
}
t := eventTable(e)
t["epoch"] = h.Epoch()
bus.Notify(o, "event", t)
ping.Reset(PingEvery)
case <-ping.C:
at := h.Sync(h.Epoch(), 0, func(string) bool { return false })
bus.Notify(o, "ping", map[string]any{"epoch": at.Epoch, "seq": at.Seq, "now": time.Now().Unix()})
}
}
}
+205
View File
@@ -0,0 +1,205 @@
// Package api is the admin's door to the live state: the ubus object
// `dawnline`, which LuCI reaches through uhttpd with rpcd's access lists in
// between (acl.d/luci-app-dawnline.json names every method here; a test holds
// the two together).
//
// hello where the stream is and how to follow it
// sync {epoch, seq, topics} a snapshot, or the events since seq
// wait {epoch, seq, topics, timeout}
// the same, held until there is an event (long poll)
// watch {topics} "these topics are on screen", renewed while they are
//
// and the notifications `event` (one change, hub.Event with the epoch) and
// `ping` to whoever subscribed (uhttpd: GET /ubus/subscribe/dawnline, an event
// stream). The two ways to follow give the same events with the same numbers;
// a page uses the stream where the web server can hold one and the long poll
// where it cannot (hello's `stream`).
//
// Arguments are checked here, once; the hub is trusted with what passes.
package api
import (
"context"
"time"
"github.com/tickcount/luci-app-dawnline/backend/hub"
"github.com/tickcount/luci-app-dawnline/backend/ubus"
)
// ObjectName is the backend's object on ubus. The ucode backend's is
// luci.dawnline; methods move from there to here as they are ported.
const ObjectName = "dawnline"
// The limits of what a caller may send.
const (
maxTopics = 32
maxTopicLen = 64
maxEpochLen = 32
// A held call must end before uhttpd gives up on it (script_timeout, 60 s).
maxWait = 50 * time.Second
defaultWait = 25 * time.Second
)
// Info is what hello tells besides the stream's position.
type Info struct {
// Version is the backend's.
Version string
// Stream is how a page should follow: "sse" (GET /ubus/subscribe/dawnline)
// or "poll" (the wait method).
Stream string
// Refresh has the topics read from the router now (the bridge's Look); nil when nothing needs it.
Refresh func(ctx context.Context)
// More is the questions the backend answers besides the stream's (package methods): hello names them,
// so a page asks them here and not of the ucode backend.
More []ubus.Method
}
// Object builds the ubus object over a hub. Who looks is noted in audience.
func Object(h *hub.Hub, audience *Audience, info Info) *ubus.Object {
more := []string{}
for _, m := range info.More {
more = append(more, m.Name)
}
return &ubus.Object{
Name: ObjectName,
Methods: append([]ubus.Method{
{Name: "hello", Handle: func(context.Context, map[string]any) (map[string]any, error) {
at := h.Sync(h.Epoch(), 0, func(string) bool { return false })
return map[string]any{
"version": info.Version, "stream": info.Stream,
"epoch": at.Epoch, "seq": at.Seq, "lease": int(Lease / time.Second),
"now": time.Now().Unix(), "methods": more,
}, nil
}},
{Name: "sync", Params: map[string]ubus.Kind{"epoch": ubus.String, "seq": ubus.Int, "topics": ubus.Array},
Handle: func(_ context.Context, args map[string]any) (map[string]any, error) {
q, err := parse(args)
if err != nil {
return nil, err
}
audience.Touch(q.topics)
return answer(h.Sync(q.epoch, q.seq, q.want())), nil
}},
{Name: "wait", Waits: true,
Params: map[string]ubus.Kind{"epoch": ubus.String, "seq": ubus.Int, "topics": ubus.Array, "timeout": ubus.Int},
Handle: func(ctx context.Context, args map[string]any) (map[string]any, error) {
q, err := parse(args)
if err != nil {
return nil, err
}
audience.Touch(q.topics)
ctx, cancel := context.WithTimeout(ctx, q.timeout)
defer cancel()
a := h.Wait(ctx, q.epoch, q.seq, q.want())
// Still looking after the wait: the next call renews it again.
audience.Touch(q.topics)
return answer(a), nil
}},
// After its own edit a page reads what it wrote: the topics are brought to what is on disk, and
// the answer is where the stream stands then. The page catches up to it (sync).
{Name: "refresh", Waits: true, Handle: func(ctx context.Context, _ map[string]any) (map[string]any, error) {
audience.Touch(nil)
if info.Refresh != nil {
ctx, cancel := context.WithTimeout(ctx, defaultWait)
defer cancel()
info.Refresh(ctx)
}
at := h.Sync(h.Epoch(), 0, func(string) bool { return false })
return map[string]any{"epoch": at.Epoch, "seq": at.Seq}, nil
}},
{Name: "watch", Params: map[string]ubus.Kind{"topics": ubus.Array},
Handle: func(_ context.Context, args map[string]any) (map[string]any, error) {
q, err := parse(args)
if err != nil {
return nil, err
}
audience.Touch(q.topics)
return map[string]any{"lease": int(Lease / time.Second)}, nil
}},
}, info.More...),
Watched: audience.Streaming,
}
}
// query is a caller's arguments, checked.
type query struct {
epoch string
seq uint64
topics []string
timeout time.Duration
}
// want is the topics the caller named; none named means all of them.
func (q query) want() func(string) bool {
if len(q.topics) == 0 {
return nil
}
set := make(map[string]bool, len(q.topics))
for _, t := range q.topics {
set[t] = true
}
return func(topic string) bool { return set[topic] }
}
func parse(args map[string]any) (query, error) {
q := query{timeout: defaultWait}
if v, ok := args["epoch"]; ok {
s, isString := v.(string)
if !isString || len(s) > maxEpochLen {
return q, ubus.StatusInvalidArgument
}
q.epoch = s
}
if v, ok := args["seq"]; ok {
n, isInt := v.(int64)
if !isInt || n < 0 {
return q, ubus.StatusInvalidArgument
}
q.seq = uint64(n)
}
if v, ok := args["timeout"]; ok {
n, isInt := v.(int64)
if !isInt || n < 1 {
return q, ubus.StatusInvalidArgument
}
q.timeout = min(time.Duration(n)*time.Second, maxWait)
}
if v, ok := args["topics"]; ok {
list, isList := v.([]any)
if !isList || len(list) > maxTopics {
return q, ubus.StatusInvalidArgument
}
for _, e := range list {
s, isString := e.(string)
if !isString || s == "" || len(s) > maxTopicLen {
return q, ubus.StatusInvalidArgument
}
q.topics = append(q.topics, s)
}
}
return q, nil
}
// answer is a hub.Answer as a ubus table.
func answer(a hub.Answer) map[string]any {
out := map[string]any{"epoch": a.Epoch, "seq": a.Seq}
if a.Docs != nil {
out["docs"] = a.Docs
}
if a.Events != nil {
events := make([]any, len(a.Events))
for i, e := range a.Events {
events[i] = eventTable(e)
}
out["events"] = events
}
return out
}
func eventTable(e hub.Event) map[string]any {
t := map[string]any{"seq": e.Seq, "topic": e.Topic, "op": e.Op}
if e.Data != nil {
t["data"] = e.Data
}
return t
}