From 0d7bea4996cc8eb9bc0d1e05fb3ba4901d3f30a7 Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sat, 28 Nov 2026 11:12:39 -0500 Subject: [PATCH 01/12] docs: claim max_slots and poll_interval, poller pollIntervalMinutes --- docs/api-contract.md | 17 ++++++++++++----- docs/repeater-polling.md | 7 ++++--- docs/telemetry-requests.md | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/docs/api-contract.md b/docs/api-contract.md index b29497f..c63b1ac 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -562,6 +562,7 @@ The other side of [Node polling](#node-polling): what an observer that polls say "receivedAt": 1795800000000, "live": true, "acceptsRequests": true, + "pollIntervalMinutes": 60, "slots": { "max": 8, "used": 5, "own": 3, "requested": 2, "free": 3 } }, "readings24h": 212, @@ -592,7 +593,8 @@ The other side of [Node polling](#node-polling): what an observer that polls say | `claim.receivedAt` | When Beacon received it, epoch ms. | | `claim.live` | True while the claim is under 65 minutes old. A claim is kept for about a day after that, so `false` means the observer has stopped claiming. `isPoller` on the node does not check this. | | `claim.acceptsRequests` | The observer takes repeaters handed out by [telemetry requests](#telemetry-requests). | -| `claim.slots` | `max` is the most repeaters one observer holds (8). `used` is how many the claim lists, split into `own` (set up by the observer's owner) and `requested`. `free` is how many more requested repeaters Beacon could hand it now: the free seats the claim reported, never more than `max` minus `used`, less any seats Beacon has handed out that the claim does not list yet. It is `0` when the claim is not live or does not accept requests. `used` plus `free` can be less than `max`. | +| `claim.pollIntervalMinutes` | How often the observer polls each repeater, in minutes, from the claim's `poll_interval`. `null` when its firmware does not report it. | +| `claim.slots` | `max` is the most repeaters this observer holds: the claim's `max_slots`, or 8 when its firmware does not report one. `used` is how many the claim lists, split into `own` (set up by the observer's owner) and `requested`. `free` is how many more requested repeaters Beacon could hand it now: the free seats the claim reported, never more than `max` minus `used`, less any seats Beacon has handed out that the claim does not list yet. It is `0` when the claim is not live or does not accept requests. `used` plus `free` can be less than `max`. | | `readings24h` | Readings Beacon received from this observer in the last 24 hours, trusted or not. | | `targets` | One entry for each repeater in the claim. Assigned ones first in rank order, then the rest; within a tie by name, with unnamed ones last. An empty array when there are none. | @@ -1824,7 +1826,7 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p ```json {"v": 2, "origin": "Name", "origin_id": "", "timestamp": "2026-11-13T22:13:20Z", "plugin": "meshcore.observer_fw/", "policy_version": "a1b2", "community": true, - "accepts_requests": true, "request_slots": 3, + "accepts_requests": true, "request_slots": 3, "max_slots": 8, "poll_interval": 60, "nodes": [{"node_id": "", "reply_hops": 0, "via": null, "key": "own", "snr": 6.5, "state": "ok", "misses": 2, "last_attempt": "2026-11-13T22:11:40Z", "last_ok": "2026-11-13T22:12:30Z"}]} @@ -1838,23 +1840,28 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p below healthy observers with the same kind of evidence. An observer with advert evidence ranks above one without, failing or not. - `accepts_requests` says the observer takes requested repeaters, and `request_slots` is how many - free seats it has (clamped to 8). A node entry with `"requested": true` is one the observer was + free seats it has (clamped to the observer's limit). A node entry with `"requested": true` is one the observer was given by a request. A report of `admin_stop` or `login_failed` for a requested repeater counts only from the observer that was assigned it. A `login_failed` report does not count while that observer has a trusted reading of the repeater stored after the current option became active and within the last 4 hours (the default; four times `polling.direct_window`, at most 48 hours). A claim and the state reports in it are stored in one transaction, so a report that fails to store rolls the claim back and the device's next claim repeats it. +- `max_slots` is how many repeaters the observer can hold, set on the device. Beacon uses it as the + observer's limit when it hands out requested repeaters, and never believes more than 32. Without + it the limit is 8. `poll_interval` is how often the observer polls each repeater, in minutes; + zero or a negative number counts as absent. Both are absent from firmware that does not report + them. - `accepts_requests`, `request_slots`, `requested`, `state`, `misses`, `last_attempt` and `last_ok` are absent from claims sent by clients without request support. Those still send `"v": 2`; there is no v1 claim. -- At most 32 repeaters per claim; a longer claim is dropped whole. The firmware sends up to 8. +- At most 32 repeaters per claim; a longer claim is dropped whole. The firmware sends up to its `max_slots`. - A claim is ignored when its `timestamp` is not newer than the stored one or is more than 10 minutes ahead of Beacon's clock. It is live for 65 minutes after Beacon receives it. - A claim that arrives less than 30 seconds after Beacon received the observer's last one is dropped. The check is made where the claim is stored, so two claims arriving together cannot both pass it. The firmware claims at most once a minute. -- `misses` and `request_slots` are clamped (0 to 255, 0 to 8). A number too large for a 64-bit +- `misses`, `request_slots` and `max_slots` are clamped (0 to 255, 0 to the observer's limit, 0 to 32). A number too large for a 64-bit integer counts as absent. - The whole claim is also dropped when it is over 16384 bytes, `v` is not `2`, a node's `reply_hops` is not `0` or `1`, its `snr` is not a finite number, or its `last_attempt` or diff --git a/docs/repeater-polling.md b/docs/repeater-polling.md index 53ad20e..7f0b8ec 100644 --- a/docs/repeater-polling.md +++ b/docs/repeater-polling.md @@ -13,7 +13,7 @@ for where the readings show up. ## How it works 1. The owner sets a repeater as a target on the observer. The observer can poll direct - neighbours only, up to 8 targets. + neighbours only, up to the observer's target limit (8 unless changed on the device). 2. The observer asks Beacon for its policy (`GET /api/guest-polling/policy`) and its owners answer (`GET /api/guest-polling/owners`). Until it has a policy it neither polls nor reports. 3. The observer publishes a claim to the MQTT broker, listing its targets and how its last @@ -186,9 +186,10 @@ A Poller tag means a stored claim exists for that observer, whether or not it is An observer with the Poller tag also has a Poller view on its node, beside Node and Observer, in Beacon Web and the mobile app. It shows: -- how many of its 8 slots are used, split into its owner's repeaters and requested ones, and how +- how many of its slots are used, split into its owner's repeaters and requested ones, and how many are free -- when Beacon last received its claim +- when Beacon last received its claim, and how often it polls each repeater when its firmware + reports that - one row for each repeater: poller, standby or not assigned, the state it reports, its last reply and SNR, and how many of the repeater's adverts Beacon heard through it diff --git a/docs/telemetry-requests.md b/docs/telemetry-requests.md index 35f0f32..61dcbc9 100644 --- a/docs/telemetry-requests.md +++ b/docs/telemetry-requests.md @@ -116,7 +116,7 @@ Until an observer that hears the repeater has done this, every request for it st with `no_observer`. A claim from a device that accepts requests carries `accepts_requests`, -`request_slots` (free seats, at most 8) and `requested` on each node. Firmware without request +`request_slots` (free seats, at most the device's `max_slots`, 8 when it reports none) and `requested` on each node. Firmware without request support, or with requests off, never reaches this path and its observer simply polls its own targets. The envelope format and the claim fields are in the [API contract](api-contract.md#firmware-polling). Beacon never sends a password to an observer in clear: only the envelope, which only that observer's key opens. From 8d7dda31b096dca2544d7032520930a7416de43d Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sat, 28 Nov 2026 13:45:10 -0500 Subject: [PATCH 02/12] docs: note 2.3.1 for the claim limit fields --- docs/api-contract.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/api-contract.md b/docs/api-contract.md index c63b1ac..806ea03 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -593,8 +593,8 @@ The other side of [Node polling](#node-polling): what an observer that polls say | `claim.receivedAt` | When Beacon received it, epoch ms. | | `claim.live` | True while the claim is under 65 minutes old. A claim is kept for about a day after that, so `false` means the observer has stopped claiming. `isPoller` on the node does not check this. | | `claim.acceptsRequests` | The observer takes repeaters handed out by [telemetry requests](#telemetry-requests). | -| `claim.pollIntervalMinutes` | How often the observer polls each repeater, in minutes, from the claim's `poll_interval`. `null` when its firmware does not report it. | -| `claim.slots` | `max` is the most repeaters this observer holds: the claim's `max_slots`, or 8 when its firmware does not report one. `used` is how many the claim lists, split into `own` (set up by the observer's owner) and `requested`. `free` is how many more requested repeaters Beacon could hand it now: the free seats the claim reported, never more than `max` minus `used`, less any seats Beacon has handed out that the claim does not list yet. It is `0` when the claim is not live or does not accept requests. `used` plus `free` can be less than `max`. | +| `claim.pollIntervalMinutes` | How often the observer polls each repeater, in minutes, from the claim's `poll_interval`. `null` when its firmware does not report it. From 2.3.1; an older server leaves the field out. | +| `claim.slots` | `max` is the most repeaters this observer holds: the claim's `max_slots`, or 8 when its firmware does not report one (always 8 before 2.3.1). `used` is how many the claim lists, split into `own` (set up by the observer's owner) and `requested`. `free` is how many more requested repeaters Beacon could hand it now: the free seats the claim reported, never more than `max` minus `used`, less any seats Beacon has handed out that the claim does not list yet. It is `0` when the claim is not live or does not accept requests. `used` plus `free` can be less than `max`. | | `readings24h` | Readings Beacon received from this observer in the last 24 hours, trusted or not. | | `targets` | One entry for each repeater in the claim. Assigned ones first in rank order, then the rest; within a tie by name, with unnamed ones last. An empty array when there are none. | @@ -1847,7 +1847,8 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p last 4 hours (the default; four times `polling.direct_window`, at most 48 hours). A claim and the state reports in it are stored in one transaction, so a report that fails to store rolls the claim back and the device's next claim repeats it. -- `max_slots` is how many repeaters the observer can hold, set on the device. Beacon uses it as the +- `max_slots` and `poll_interval` are read from 2.3.1; an older server ignores them and holds every + observer to 8. `max_slots` is how many repeaters the observer can hold, set on the device. Beacon uses it as the observer's limit when it hands out requested repeaters, and never believes more than 32. Without it the limit is 8. `poll_interval` is how often the observer polls each repeater, in minutes; zero or a negative number counts as absent. Both are absent from firmware that does not report From 3493d4c33a19686e60765f9ec2856177a039a84c Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sat, 28 Nov 2026 16:19:10 -0500 Subject: [PATCH 03/12] docs: foreign polling claims, poll_url and polling.public_hosts --- app_config/config.yaml.example | 1 + docs/api-contract.md | 33 +++++++++++++++++++++++++++++++++ docs/configuration.md | 1 + docs/repeater-polling.md | 14 ++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/app_config/config.yaml.example b/app_config/config.yaml.example index 693ec18..ec2255c 100644 --- a/app_config/config.yaml.example +++ b/app_config/config.yaml.example @@ -444,6 +444,7 @@ cache: #polling: # enabled: false # turn repeater polling on; needs mqtt_hosts # mqtt_hosts: [] # brokers your observers publish to: plain hostnames, no port, up to 4 +# public_hosts: [] # hosts observers reach this server at (their poll.url), no scheme or port, up to 4 # direct_window: 1h # poll a repeater again once its newest reading is this old; 30m to 24h # grace: 30m # extra wait for each standby before it steps in for the poller; 10m to 2h # max_requests: 2 # poll attempts per repeater in each window; 1 to 3 diff --git a/docs/api-contract.md b/docs/api-contract.md index 806ea03..7d0a762 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -562,6 +562,8 @@ The other side of [Node polling](#node-polling): what an observer that polls say "receivedAt": 1795800000000, "live": true, "acceptsRequests": true, + "foreign": false, + "pollHost": "beacon.example.com", "pollIntervalMinutes": 60, "slots": { "max": 8, "used": 5, "own": 3, "requested": 2, "free": 3 } }, @@ -593,6 +595,8 @@ The other side of [Node polling](#node-polling): what an observer that polls say | `claim.receivedAt` | When Beacon received it, epoch ms. | | `claim.live` | True while the claim is under 65 minutes old. A claim is kept for about a day after that, so `false` means the observer has stopped claiming. `isPoller` on the node does not check this. | | `claim.acceptsRequests` | The observer takes repeaters handed out by [telemetry requests](#telemetry-requests). | +| `claim.foreign` | `true` when the observer follows another server (see [Foreign claims](#foreign-claims)). From 2.3.1; an older server leaves the field out. | +| `claim.pollHost` | The host of the claim's `poll_url`, lowercase. `null` when its firmware does not send one. From 2.3.1; an older server leaves the field out. | | `claim.pollIntervalMinutes` | How often the observer polls each repeater, in minutes, from the claim's `poll_interval`. `null` when its firmware does not report it. From 2.3.1; an older server leaves the field out. | | `claim.slots` | `max` is the most repeaters this observer holds: the claim's `max_slots`, or 8 when its firmware does not report one (always 8 before 2.3.1). `used` is how many the claim lists, split into `own` (set up by the observer's owner) and `requested`. `free` is how many more requested repeaters Beacon could hand it now: the free seats the claim reported, never more than `max` minus `used`, less any seats Beacon has handed out that the claim does not list yet. It is `0` when the claim is not live or does not accept requests. `used` plus `free` can be less than `max`. | | `readings24h` | Readings Beacon received from this observer in the last 24 hours, trusted or not. | @@ -1827,6 +1831,7 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p {"v": 2, "origin": "Name", "origin_id": "", "timestamp": "2026-11-13T22:13:20Z", "plugin": "meshcore.observer_fw/", "policy_version": "a1b2", "community": true, "accepts_requests": true, "request_slots": 3, "max_slots": 8, "poll_interval": 60, + "poll_url": "https://beacon.example.com", "nodes": [{"node_id": "", "reply_hops": 0, "via": null, "key": "own", "snr": 6.5, "state": "ok", "misses": 2, "last_attempt": "2026-11-13T22:11:40Z", "last_ok": "2026-11-13T22:12:30Z"}]} @@ -1853,6 +1858,10 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p it the limit is 8. `poll_interval` is how often the observer polls each repeater, in minutes; zero or a negative number counts as absent. Both are absent from firmware that does not report them. +- `poll_url` is read from 2.3.1; an older server ignores it. It is the device's `poll.url`: the + server it asks for its policy. Beacon keeps only the host, lowercased, and accepts a bare host + too. A value that is not a host name of letters, digits, dots and hyphens counts as absent. + - `accepts_requests`, `request_slots`, `requested`, `state`, `misses`, `last_attempt` and `last_ok` are absent from claims sent by clients without request support. Those still send `"v": 2`; there is no v1 claim. @@ -1868,6 +1877,30 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p `reply_hops` is not `0` or `1`, its `snr` is not a finite number, or its `last_attempt` or `last_ok` is not a valid time. +### Foreign claims + +A claim can reach a server the observer does not follow: two servers that read the same broker, or +a broker that forwards from others. From 2.3.1 Beacon marks such a claim foreign. A claim is the +server's own when either holds: + +- its `poll_url` host is one of `polling.public_hosts` (the host of `accounts.public_url` counts + as one), or +- the observer asked this server for its policy or owners answer in the last 6 hours. + +Otherwise it is foreign. A foreign observer: + +- ranks behind every observer that follows this server, whatever its evidence, so it is the + poller only for a repeater nobody else claims, +- is never given a requested repeater, +- has its readings stored and counted under the same advert evidence rule as any other ranked + observer. + +An ask is recorded only for a key that is already an observer here, about once in 10 minutes +for each observer. A server with `server.read_only` records none, so observers must send their +policy and owners requests to the writable server, or name it in `poll_url`. Asking clears the mark on the stored claim at once; the next election, within a +minute, ranks the observer as the server's own. When an upgrade to 2.3.1 runs, every observer with +a stored claim counts as having just asked. + ### Reading message Published to `.../telemetry` (`"v": 2`) or `.../battery` (`"v": 1`), same topic prefix, QoS 1, diff --git a/docs/configuration.md b/docs/configuration.md index edcfdcb..5db87de 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -328,6 +328,7 @@ the key. |---|---|---|---| | `enabled` | `false` | | Turns polling on. Needs `mqtt_hosts`. | | `mqtt_hosts` | none | 1 to 4 hosts when enabled | Broker hosts observers publish to. Plain hostnames of 1 to 63 letters, digits, dots or hyphens, no port. Sent to observers so they pick the matching MQTT slot. | +| `public_hosts` | none | up to 4 hosts | The hosts observers reach this server at, as in their `poll.url`. Plain hostnames, no scheme or port. The host of `accounts.public_url` is added on its own. A claim that names one of them is this server's own; see [Foreign claims](api-contract.md#foreign-claims). | | `direct_window` | `1h` | `30m` to `24h` | How old the newest reading may get before the poller asks again. | | `grace` | `30m` | `10m` to `2h` | The extra wait for each standby rank. | | `max_requests` | `2` | 1 to 3 | Poll starts per repeater per window, sent to observers. | diff --git a/docs/repeater-polling.md b/docs/repeater-polling.md index 7f0b8ec..c5ad699 100644 --- a/docs/repeater-polling.md +++ b/docs/repeater-polling.md @@ -38,6 +38,20 @@ healthy observer with evidence beats it by 3 dB. So a poller that stops getting to another observer Beacon has heard the repeater through, and takes the job back once it recovers and is the stronger signal. An observer without evidence never takes the job from one with it. +### Observers that follow another server + +A claim can arrive from an observer that takes its policy from a different Beacon, for example +when two servers read the same broker. Beacon calls that claim foreign. It tells them apart by the +`poll_url` in the claim, or, for firmware that does not send one, by whether the observer asked +this server for its policy in the last 6 hours. + +A foreign observer ranks behind every observer of your own, so it never takes a repeater from one +of them, and it is never given a requested repeater. Its readings are still stored and shown under +the usual evidence rule. If your observers reach Beacon at a host other than +`accounts.public_url`, list it in `polling.public_hosts`. A read-only server cannot record who +asks it, so point `poll.url` at the writable one. The exact rule is in the +[API contract](api-contract.md#foreign-claims). + ## What Beacon needs Set `polling` in `config.yaml`. See [Configuration](configuration.md#repeater-polling) for every key. From fbb5b665d9f1d24c07d4e7bf9780aba269dde989 Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sat, 28 Nov 2026 16:55:08 -0500 Subject: [PATCH 04/12] docs: revert foreign polling claims, until the design is settled --- app_config/config.yaml.example | 1 - docs/api-contract.md | 33 --------------------------------- docs/configuration.md | 1 - docs/repeater-polling.md | 14 -------------- 4 files changed, 49 deletions(-) diff --git a/app_config/config.yaml.example b/app_config/config.yaml.example index ec2255c..693ec18 100644 --- a/app_config/config.yaml.example +++ b/app_config/config.yaml.example @@ -444,7 +444,6 @@ cache: #polling: # enabled: false # turn repeater polling on; needs mqtt_hosts # mqtt_hosts: [] # brokers your observers publish to: plain hostnames, no port, up to 4 -# public_hosts: [] # hosts observers reach this server at (their poll.url), no scheme or port, up to 4 # direct_window: 1h # poll a repeater again once its newest reading is this old; 30m to 24h # grace: 30m # extra wait for each standby before it steps in for the poller; 10m to 2h # max_requests: 2 # poll attempts per repeater in each window; 1 to 3 diff --git a/docs/api-contract.md b/docs/api-contract.md index 7d0a762..806ea03 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -562,8 +562,6 @@ The other side of [Node polling](#node-polling): what an observer that polls say "receivedAt": 1795800000000, "live": true, "acceptsRequests": true, - "foreign": false, - "pollHost": "beacon.example.com", "pollIntervalMinutes": 60, "slots": { "max": 8, "used": 5, "own": 3, "requested": 2, "free": 3 } }, @@ -595,8 +593,6 @@ The other side of [Node polling](#node-polling): what an observer that polls say | `claim.receivedAt` | When Beacon received it, epoch ms. | | `claim.live` | True while the claim is under 65 minutes old. A claim is kept for about a day after that, so `false` means the observer has stopped claiming. `isPoller` on the node does not check this. | | `claim.acceptsRequests` | The observer takes repeaters handed out by [telemetry requests](#telemetry-requests). | -| `claim.foreign` | `true` when the observer follows another server (see [Foreign claims](#foreign-claims)). From 2.3.1; an older server leaves the field out. | -| `claim.pollHost` | The host of the claim's `poll_url`, lowercase. `null` when its firmware does not send one. From 2.3.1; an older server leaves the field out. | | `claim.pollIntervalMinutes` | How often the observer polls each repeater, in minutes, from the claim's `poll_interval`. `null` when its firmware does not report it. From 2.3.1; an older server leaves the field out. | | `claim.slots` | `max` is the most repeaters this observer holds: the claim's `max_slots`, or 8 when its firmware does not report one (always 8 before 2.3.1). `used` is how many the claim lists, split into `own` (set up by the observer's owner) and `requested`. `free` is how many more requested repeaters Beacon could hand it now: the free seats the claim reported, never more than `max` minus `used`, less any seats Beacon has handed out that the claim does not list yet. It is `0` when the claim is not live or does not accept requests. `used` plus `free` can be less than `max`. | | `readings24h` | Readings Beacon received from this observer in the last 24 hours, trusted or not. | @@ -1831,7 +1827,6 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p {"v": 2, "origin": "Name", "origin_id": "", "timestamp": "2026-11-13T22:13:20Z", "plugin": "meshcore.observer_fw/", "policy_version": "a1b2", "community": true, "accepts_requests": true, "request_slots": 3, "max_slots": 8, "poll_interval": 60, - "poll_url": "https://beacon.example.com", "nodes": [{"node_id": "", "reply_hops": 0, "via": null, "key": "own", "snr": 6.5, "state": "ok", "misses": 2, "last_attempt": "2026-11-13T22:11:40Z", "last_ok": "2026-11-13T22:12:30Z"}]} @@ -1858,10 +1853,6 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p it the limit is 8. `poll_interval` is how often the observer polls each repeater, in minutes; zero or a negative number counts as absent. Both are absent from firmware that does not report them. -- `poll_url` is read from 2.3.1; an older server ignores it. It is the device's `poll.url`: the - server it asks for its policy. Beacon keeps only the host, lowercased, and accepts a bare host - too. A value that is not a host name of letters, digits, dots and hyphens counts as absent. - - `accepts_requests`, `request_slots`, `requested`, `state`, `misses`, `last_attempt` and `last_ok` are absent from claims sent by clients without request support. Those still send `"v": 2`; there is no v1 claim. @@ -1877,30 +1868,6 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p `reply_hops` is not `0` or `1`, its `snr` is not a finite number, or its `last_attempt` or `last_ok` is not a valid time. -### Foreign claims - -A claim can reach a server the observer does not follow: two servers that read the same broker, or -a broker that forwards from others. From 2.3.1 Beacon marks such a claim foreign. A claim is the -server's own when either holds: - -- its `poll_url` host is one of `polling.public_hosts` (the host of `accounts.public_url` counts - as one), or -- the observer asked this server for its policy or owners answer in the last 6 hours. - -Otherwise it is foreign. A foreign observer: - -- ranks behind every observer that follows this server, whatever its evidence, so it is the - poller only for a repeater nobody else claims, -- is never given a requested repeater, -- has its readings stored and counted under the same advert evidence rule as any other ranked - observer. - -An ask is recorded only for a key that is already an observer here, about once in 10 minutes -for each observer. A server with `server.read_only` records none, so observers must send their -policy and owners requests to the writable server, or name it in `poll_url`. Asking clears the mark on the stored claim at once; the next election, within a -minute, ranks the observer as the server's own. When an upgrade to 2.3.1 runs, every observer with -a stored claim counts as having just asked. - ### Reading message Published to `.../telemetry` (`"v": 2`) or `.../battery` (`"v": 1`), same topic prefix, QoS 1, diff --git a/docs/configuration.md b/docs/configuration.md index 5db87de..edcfdcb 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -328,7 +328,6 @@ the key. |---|---|---|---| | `enabled` | `false` | | Turns polling on. Needs `mqtt_hosts`. | | `mqtt_hosts` | none | 1 to 4 hosts when enabled | Broker hosts observers publish to. Plain hostnames of 1 to 63 letters, digits, dots or hyphens, no port. Sent to observers so they pick the matching MQTT slot. | -| `public_hosts` | none | up to 4 hosts | The hosts observers reach this server at, as in their `poll.url`. Plain hostnames, no scheme or port. The host of `accounts.public_url` is added on its own. A claim that names one of them is this server's own; see [Foreign claims](api-contract.md#foreign-claims). | | `direct_window` | `1h` | `30m` to `24h` | How old the newest reading may get before the poller asks again. | | `grace` | `30m` | `10m` to `2h` | The extra wait for each standby rank. | | `max_requests` | `2` | 1 to 3 | Poll starts per repeater per window, sent to observers. | diff --git a/docs/repeater-polling.md b/docs/repeater-polling.md index c5ad699..7f0b8ec 100644 --- a/docs/repeater-polling.md +++ b/docs/repeater-polling.md @@ -38,20 +38,6 @@ healthy observer with evidence beats it by 3 dB. So a poller that stops getting to another observer Beacon has heard the repeater through, and takes the job back once it recovers and is the stronger signal. An observer without evidence never takes the job from one with it. -### Observers that follow another server - -A claim can arrive from an observer that takes its policy from a different Beacon, for example -when two servers read the same broker. Beacon calls that claim foreign. It tells them apart by the -`poll_url` in the claim, or, for firmware that does not send one, by whether the observer asked -this server for its policy in the last 6 hours. - -A foreign observer ranks behind every observer of your own, so it never takes a repeater from one -of them, and it is never given a requested repeater. Its readings are still stored and shown under -the usual evidence rule. If your observers reach Beacon at a host other than -`accounts.public_url`, list it in `polling.public_hosts`. A read-only server cannot record who -asks it, so point `poll.url` at the writable one. The exact rule is in the -[API contract](api-contract.md#foreign-claims). - ## What Beacon needs Set `polling` in `config.yaml`. See [Configuration](configuration.md#repeater-polling) for every key. From 0f69e6847e423ab4b5fa7dae9dea3c2146393367 Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sat, 28 Nov 2026 20:49:54 -0500 Subject: [PATCH 05/12] docs: rebroadcaster source brokers, foreign observers, DOMAIN replaces accounts.public_url Covers MQTT_BROKER_n_REBROADCAST and the source-broker / source-host properties, polling.foreign_claims, the claim signature, the new API fields and GET /brokers/sources, and the upgrade notes for removing accounts.public_url. --- app_config/.env.example | 19 ++++- app_config/config.yaml.example | 10 ++- docs/accounts.md | 15 ++-- docs/alerts.md | 2 +- docs/api-contract.md | 144 ++++++++++++++++++++++++++++++--- docs/configuration.md | 53 ++++++++++-- docs/getting-packets-in.md | 4 + docs/repeater-polling.md | 48 +++++++++++ docs/security.md | 4 +- docs/troubleshooting.md | 2 +- docs/upgrading.md | 46 ++++++++++- 11 files changed, 316 insertions(+), 31 deletions(-) diff --git a/app_config/.env.example b/app_config/.env.example index a2ff255..0470c1d 100644 --- a/app_config/.env.example +++ b/app_config/.env.example @@ -58,12 +58,25 @@ MQTT_BROKER_2_URL=wss://mqtt2.meshcore.ca:443 MQTT_BROKER_2_USERNAME=CHANGE_NAME MQTT_BROKER_2_PASSWORD=CHANGE_PASS -# ---- Public domain / TLS (service: caddy) ------------------- -# Site address + automatic Let's Encrypt certificate. +# Set for a broker that is a rebroadcaster: it forwards messages from other MeshCore brokers and tags each one +# with the broker it originally came from. Beacon then connects with MQTT 5 and reads the tags. +# observers -> MeshCore broker -> rebroadcaster <- Beacon subscribes here +# The rebroadcaster must leave topic and payload unchanged and set two MQTT 5 user properties on every message: +# source-broker short name of the source broker: a-z, 0-9, _ or -, up to 64 characters (e.g. letsmesh) +# source-host host the message arrived on, lowercase, no port (e.g. mqtt.example.net) +# Only the rebroadcaster should be able to publish to it. A message without the tags is still accepted and +# shows this connection's own name. Leave unset for a MeshCore broker that observers publish to directly. +# MQTT_BROKER_1_REBROADCAST=true +# MQTT_BROKER_2_REBROADCAST=true + +# ---- Public domain / TLS (services: caddy, app) ------------- +# Site address + automatic Let's Encrypt certificate. The server reads it too, as its own public +# address: for the links in account mail and for polling.foreign_claims. DOMAIN=beacon.example.com # Type 2 server host only: the web frontend's hostname. Caddy redirects everything that is -# not /api/*, /ws or /.well-known/beacon-push there. Not used by the all-in-one stack. +# not /api/*, /ws or /.well-known/beacon-push there, and the server uses it for the links in account +# mail. Not used by the all-in-one stack. # WEB_DOMAIN=beacon.example.com # ---- Frontend URLs (service: web) --------------------------- diff --git a/app_config/config.yaml.example b/app_config/config.yaml.example index 693ec18..ba4dfe7 100644 --- a/app_config/config.yaml.example +++ b/app_config/config.yaml.example @@ -449,6 +449,13 @@ cache: # max_requests: 2 # poll attempts per repeater in each window; 1 to 3 # reading_retention: 744h # how long readings are kept; at least 1h (default 31 days) # min_client_version: "" # oldest observer firmware allowed to poll, as X.Y.Z; empty allows all +# foreign_claims: off # off: every polling claim is treated as this server's own. +# # check: a claim is this server's own only when its signed poll_url names this +# # server's DOMAIN (from .env). Older observer firmware sends no poll_url; its +# # claim is judged by the broker it came through, which needs +# # MQTT_BROKER_n_REBROADCAST=true in .env on a rebroadcaster, and is its own +# # when that broker is in mqtt_hosts. A claim with neither is dropped. +# # Readings from other observers are kept and shown as foreign. # excluded_nodes: [] # repeaters that are never polled; up to 16 public keys, 64 hex characters each # paused: false # true tells every observer to stop polling, without turning the feature off # authority: evidence # who can be chosen to poll. evidence: any observer, ranked by how well Beacon @@ -479,9 +486,10 @@ cache: # no account route is served. Mode local sends mail through the mail block above. # A web app on another origin than the API also needs cors.allowed_methods, cors.allowed_headers # (with X-Beacon-CSRF) and cors.allow_credentials; same origin needs nothing. +# The links in mail use the server's public address, taken from DOMAIN in .env (WEB_DOMAIN when the web +# app is on another host). The old public_url key is no longer read. #accounts: # mode: off # off, or local for sign-up with username, email and password -# public_url: "" # https URL of the web app, no path; used in mailed links # registration: open # open: anyone can sign up. closed: no new sign-ups, existing users still sign in # Alerts: tell users when a radio on their Atlas needs attention. Needs accounts. Off by default. diff --git a/docs/accounts.md b/docs/accounts.md index d36087d..c735421 100644 --- a/docs/accounts.md +++ b/docs/accounts.md @@ -29,10 +29,13 @@ mail: accounts: mode: local - public_url: https://beacon.example.org registration: open ``` +The server also needs to know its public address, for the links it mails. It takes it from the +environment: `https://` and `WEB_DOMAIN`, or `DOMAIN` when the web app and the API share a host. +The Docker stacks already set `DOMAIN` in `.env`. Outside them, set it yourself. + Put the SMTP password in the environment, never in the file: ``` @@ -44,7 +47,6 @@ In the Docker stacks that is the `.env` of the host that runs the server. Then r | Key | Default | What it does | |---|---|---| | `mode` | `off` | `off` or `local` (`portal` is for the project's own instance, see [Configuration](configuration.md#user-accounts)). Anything else stops startup. The rest of the block is not checked while this is `off`. | -| `public_url` | none | Required when `mode` is `local`. The address people use for the web app: `http` or `https`, no path, query, fragment or credentials. Plain `http` is allowed only for `localhost` and `127.0.0.1`. Every link in a mail is built from it, never from a request header. | | `registration` | `open` | `open` or `closed`. When closed, `POST /auth/register` answers `403 registration_closed` and `features.registration` is `false`. People who already have an account keep signing in. | | `mail.host` | none | Required. | | `mail.port` | `587` | 1 to 65535. | @@ -68,11 +70,12 @@ this). Unset, blank or `BEACON` gives `Beacon`. When `mail.from` is a bare addre sender's display name; an explicit display name in `mail.from` is kept as it is. Alert mail uses the same name in its subject. -The mailed links are `/?view=verify#token=...` and `/?view=reset#token=...` +The mailed links are `/?view=verify#token=...` and `/?view=reset#token=...` (an email-change link is a verify link). The token is in the URL fragment, which a browser never sends to a server, so no proxy or access log sees a live token. Links mailed before this change used -`?token=...` and Beacon Web still accepts them. The links open the web app, so `public_url` must be -where Beacon Web is served. +`?token=...` and Beacon Web still accepts them. The links open the web app, so the public address +must be where Beacon Web is served: set `WEB_DOMAIN` when that is not `DOMAIN`. Every link is built +from it, never from a request header. Plain `http` is used only for `localhost` and `127.0.0.1`. On a read-only server (`server.read_only`) every account write answers `503 read_only`, sign-in included. The hourly cleanup and the operator user routes are off. @@ -80,7 +83,7 @@ included. The hourly cleanup and the operator user routes are off. ## Same site, and a web app on another origin The session cookie is `beacon_session`. It is `HttpOnly`, `SameSite=Lax`, `Path=/`, has no `Domain` -and is `Secure` unless `public_url` is `http://localhost...` or `http://127.0.0.1...`. A browser sends +and is `Secure` unless the public address is `http://localhost...` or `http://127.0.0.1...`. A browser sends it only to the host that set it, and `SameSite=Lax` means only from a page on the same site. - **Same origin** (deployment type 1: the web app at `/` and the API at `/api/*` on one host): diff --git a/docs/alerts.md b/docs/alerts.md index 6bcee52..04f458b 100644 --- a/docs/alerts.md +++ b/docs/alerts.md @@ -113,7 +113,7 @@ clients can translate it. The codes are listed in the [API contract](api-contrac ## Email One message per user for each evaluation pass: subject "Beacon: 1 alert" or "Beacon: n alerts", -one plain sentence per alert, and a link to `/?tab=Atlas`. The alert sender sends it +one plain sentence per alert, and a link to `/?tab=Atlas`. The alert sender sends it directly, not through the account mail queue, with a 30 second timeout for each message. A notice counts as mailed only once the SMTP server accepted it, and a mail that went out is never sent again, even when the push of the same notice is retried. A failed send is retried on the email channel's diff --git a/docs/api-contract.md b/docs/api-contract.md index 806ea03..b8087c9 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -276,6 +276,7 @@ GET /api/v1/packets/{packetHash} | `firstHeardAt`, `lastHeardAt` | number | Epoch ms | | `firstToLastMs` | number | Spread between first and last observation | | `observationCount` | number | Observations across all observers | +| `brokers` | array of strings | The MQTT brokers the packet arrived through, by name. Behind a [rebroadcaster](configuration.md#behind-a-rebroadcaster) these are the brokers it was first published to; otherwise the server's own connections (`mqtt1`, `mqtt2`). Empty for a packet stored before 2.3.1. A broker that delivers the packet after the first can take one presence flush (a few seconds) to appear. From 2.3.1; an older server leaves the field out. | | `resolvedRoute` | array | TRACE only: the probed route, resolved hop by hop | | `observations` | array | One entry per observer hearing | @@ -293,7 +294,7 @@ Each observation: | `rssi`, `snr` | number | dBm / dB, each omitted when the observer did not report a usable value. A usable RSSI is -164 to -1 dBm and a usable SNR is -32 to 32 dB. An SNR of 0 is a real reading when it comes with a usable RSSI; 0 with no RSSI is how observers write "unknown" and is omitted. A missing value is never sent as 0 and never counted in an average. | | `propagationTimeMs` | number | Milliseconds after the packet's first observation (0 for the first) | | `radio` | object | `freqMhz`, `spreadFactor`, `bandwidthKhz`, `codingRate`, copied from the observer | -| `sourceBroker` | string | Name of the MQTT broker it arrived through | +| `sourceBroker` | string | The broker that delivered this observation first. The same observation usually arrives through every broker its observer publishes to, so this is not the full list: use the packet's `brokers` for where the packet came from, and the observer's `brokers` for where the observer publishes. | | `resolvedPath` | array | Per-hop resolution | | `resolvedSource`, `resolvedDestination` | object | The packet's endpoints, for types that carry them (ADVERT by full key; REQUEST, RESPONSE, TEXT_MESSAGE, PATH and ANON_REQ by 1-byte hash) | @@ -438,6 +439,7 @@ Any other value of `range`, `interval` or `include`, or a `nodeId` that is not a "interval": "6h", "polled": true, "untrustedReadings": 0, + "foreign": "none", "points": [ { "t": 1794700800000, "readings": 3, @@ -455,6 +457,7 @@ Any other value of `range`, `interval` or `include`, or a `nodeId` that is not a | `range`, `interval` | The values used, defaults filled in. | | `polled` | True when Beacon has ever stored a reading for this node, trusted or not. It does not depend on `range` or `include`. | | `untrustedReadings` | Readings inside `range` that were left out because `include=untrusted` was not sent. Always 0 when it was sent. | +| `foreign` | `none`, `some` or `all`: how many of the readings behind `points` came from [foreign observers](#foreign-observers). Counts the readings in `range` that were returned, so untrusted ones only with `include=untrusted`. `none` when there are no points. From 2.3.1. | | `points` | Ascending by `t`. A bucket with no readings is not sent, so a gap between points is a gap in polling. | | `t` | Bucket start, epoch ms, aligned to UTC. | | `readings` | How many readings fell in the bucket. | @@ -535,7 +538,9 @@ Who polls this node right now. A `400` for a `nodeId` that is not a UUID and a ` "polled": true, "latestReadingAt": 1794702630000, "poller": { "observerId": "8f0c6a52-0d56-4a47-9c36-3e8f1c2f4b11", "name": "HOWL V4.2" }, - "standbys": [ { "observerId": "5b1d0f1e-7c3a-4d0e-8a56-9f2b6c1d7a20", "name": "Ridge West", "rank": 1 } ] + "standbys": [ { "observerId": "5b1d0f1e-7c3a-4d0e-8a56-9f2b6c1d7a20", "name": "Ridge West", "rank": 1 } ], + "foreign": [ { "observerId": "0c9e2f6b-1d34-4b7e-9a11-6f3d2c8b5e40", "name": "Lakeside", "pollHost": "other.example.org", + "signed": true, "claimed": true, "latestReadingAt": 1794702000000 } ] } ``` @@ -546,6 +551,8 @@ Who polls this node right now. A `400` for a `nodeId` that is not a UUID and a ` | `poller` | The observer ranked first: `observerId` and `name`. `null` when nobody is assigned. | | `standbys` | The other assigned observers, in rank order, each with `observerId`, `name` and `rank` (1, 2, ...). An empty array when there are none. The poller has no `rank` field. | +| `foreign` | [Foreign observers](#foreign-observers) that check the node: a live foreign claim names it, or one delivered a reading of it in the last 24 hours. Each has `observerId`, `name`, `pollHost` (the server it says it follows, or `null`), `signed` (its claim's signature checked out), `claimed` (`false` for one that only sends readings) and `latestReadingAt` (its newest reading of the node, epoch ms or `null`). By name. They are never the poller or a standby. An empty array when there are none, which is always the case with `polling.foreign_claims: off`. From 2.3.1. | + `name` is the observer's display name, or the first 8 hex characters of its public key when it has none. #### Node poller @@ -562,10 +569,14 @@ The other side of [Node polling](#node-polling): what an observer that polls say "receivedAt": 1795800000000, "live": true, "acceptsRequests": true, + "signed": true, + "foreign": false, + "pollHost": "beacon.example.org", "pollIntervalMinutes": 60, "slots": { "max": 8, "used": 5, "own": 3, "requested": 2, "free": 3 } }, "readings24h": 212, + "foreignReadings24h": 0, "targets": [ { "nodeId": "3d0a8a8e-1c55-4c0b-9f0e-6a1f0b7f2c11", @@ -593,9 +604,13 @@ The other side of [Node polling](#node-polling): what an observer that polls say | `claim.receivedAt` | When Beacon received it, epoch ms. | | `claim.live` | True while the claim is under 65 minutes old. A claim is kept for about a day after that, so `false` means the observer has stopped claiming. `isPoller` on the node does not check this. | | `claim.acceptsRequests` | The observer takes repeaters handed out by [telemetry requests](#telemetry-requests). | +| `claim.signed` | True when the claim carried a [signature](#claim-signature) made with the observer's own key and it checked out: the claim came from this observer and was not changed on the way. `false` for firmware that does not sign. From 2.3.1. | +| `claim.foreign` | True for a [foreign observer](#foreign-observers). Its `targets` then all have `role` `unassigned`, `acceptsRequests` is `false`, and `slots` only counts `used` and `own`. From 2.3.1. | +| `claim.pollHost` | The host of the claim's `poll_url`: the server the observer says it follows. `null` when its firmware does not send one. From 2.3.1. | | `claim.pollIntervalMinutes` | How often the observer polls each repeater, in minutes, from the claim's `poll_interval`. `null` when its firmware does not report it. From 2.3.1; an older server leaves the field out. | | `claim.slots` | `max` is the most repeaters this observer holds: the claim's `max_slots`, or 8 when its firmware does not report one (always 8 before 2.3.1). `used` is how many the claim lists, split into `own` (set up by the observer's owner) and `requested`. `free` is how many more requested repeaters Beacon could hand it now: the free seats the claim reported, never more than `max` minus `used`, less any seats Beacon has handed out that the claim does not list yet. It is `0` when the claim is not live or does not accept requests. `used` plus `free` can be less than `max`. | | `readings24h` | Readings Beacon received from this observer in the last 24 hours, trusted or not. | +| `foreignReadings24h` | How many of those were stored as foreign. An observer that sends readings and no claim, as one in the firmware's local mode does, has these and a `null` `claim`. From 2.3.1. | | `targets` | One entry for each repeater in the claim. Assigned ones first in rank order, then the rest; within a tie by name, with unnamed ones last. An empty array when there are none. | Each target: @@ -683,6 +698,10 @@ edges spanning more than 180 degrees are rejected. | `GET /observers/{observerId}/activity?range=24h&interval=15m` | What the observer heard, bucketed. | | `GET /observers/{observerId}/adverts` | Page of adverts the observer heard. Cursor is the observation ID. | +An observer's `brokers` are the brokers it was seen on in the last 30 days, and the `broker` filter +of `/observers` and `/observers/directory` matches only within those 30 days (both from 2.3.1; before, +neither had a time limit). Take the filter's values from `GET /brokers/sources`. + `/observers` pages by each observer's last-seen time, which the summary does not include. Since 2.1.0 `nextCursor` is that time for the last row and is present whenever `hasMore` is true. Before, it came from the last status message and was missing when the last row had none, so a @@ -828,7 +847,8 @@ Channel keys come from the server config file and, optionally, MeshMapper. | `GET /regions/{regionId}` | One region with its IATAs. `400` for a non-numeric ID, `404` if unknown. | | `GET /scopes` | Array of scope names. Location filters narrow it to manual scopes configured for a matching region and imported scopes whose MeshMapper catalogue includes a matching IATA. | | `GET /scopes/{name}` | Scope detail (`%23bc` for `#bc`). | -| `GET /brokers` | `[{ "name", "connected" }]` per MQTT broker. | +| `GET /brokers` | `[{ "name", "connected" }]` per MQTT connection the server has (`mqtt1`, `mqtt2`). | +| `GET /brokers/sources` | `[{ "name" }]`: the brokers any observer was seen on in the last 30 days, by name. These are the values for the `broker` filter of the observer lists. Behind a [rebroadcaster](configuration.md#behind-a-rebroadcaster) they are the source brokers, which `GET /brokers` does not list. From 2.3.1. | Regions, IATA names and scopes are managed in the server config file (or imported from MeshMapper), not through the API. @@ -1221,7 +1241,7 @@ These are separate from the operator records at `/admin/accounts`. A session is the `beacon_session` cookie or `Authorization: Bearer `. A request that sends a bearer header never falls back to the cookie. The cookie is `HttpOnly`, `SameSite=Lax`, `Path=/`, and -`Secure` unless the `accounts.public_url` is `http://localhost...` or `http://127.0.0.1...`. +`Secure` unless the server's [public address](configuration.md#user-accounts) is `http://localhost...` or `http://127.0.0.1...`. Rules for every route here: @@ -1230,7 +1250,7 @@ Rules for every route here: - Answers carry `Cache-Control: no-store`. On a read-only server every write answers `503` with code `read_only`. - **Forgery check.** A `POST`, `PUT`, `PATCH` or `DELETE` authenticated by the cookie must send - `X-Beacon-CSRF: 1`, and an `Origin` header, if there is one, must be the origin of `public_url` or + `X-Beacon-CSRF: 1`, and an `Origin` header, if there is one, must be the origin of the public address or one of `cors.allowed_origins` (`*` never counts), else `403 csrf_rejected`. Bearer requests and signed-out requests skip it. - A web client on another origin needs `cors.allowed_methods`, `cors.allowed_headers` (with @@ -1303,7 +1323,7 @@ Notes: checks for 15 minutes: `429 too_many_attempts` with `Retry-After`. A password reset clears it. - **Reset confirm** ends every session of the user. A password the policy refuses does not use up the link. -- **Links** in mail are `/?view=verify#token=...` and `/?view=reset#token=...` +- **Links** in mail are `/?view=verify#token=...` and `/?view=reset#token=...` (an email-change link is a verify link). The token is in the URL fragment so that a browser never sends it to a server and no proxy or access log sees it. The web app also still accepts `?token=...`, for links mailed before the change. Verify and email-change links last 24 hours, @@ -1327,8 +1347,8 @@ Notes: `confirmUsername` (their own username) instead of a password; a wrong one, or a `currentPassword`, is `422 invalid_input`. - **Portal mode.** `start` stores a state for 10 minutes against the `beacon_portal` cookie and - redirects to the portal; `callback` always redirects, to `` with - `beacon_session` set, or to `/?view=signin&error=portal` on any failure including a + redirects to the portal; `callback` always redirects, to `` with + `beacon_session` set, or to `/?view=signin&error=portal` on any failure including a cancel. Both answer `503 read_only` on a read-only server. In portal mode `register`, `verify`, `verify/resend`, `login`, `reset/request`, `reset/confirm`, `/me/password` and `/me/email` answer `404 portal_managed`. @@ -1498,19 +1518,28 @@ for a live claim). The same `poller` object is in the create and update answers. ``` POST /api/v1/me/telemetry-requests -{ "nodeId": "uuid", "password": "optional" } +{ "nodeId": "uuid", "password": "optional", "acknowledgeForeign": true } ``` `password` is optional, 1 to 15 bytes with no zero byte, and must be a guest password, never an admin password. Absent, `null` or empty means the blank or hello login. Body at most 4 KiB. Answers `201` with the single request object. +`acknowledgeForeign` is only needed when a [foreign observer](#foreign-observers) already checks +the repeater (the node's polling view lists one under `foreign`). A request then has a second +observer poll it, so the first attempt without the field answers `409 foreign_poller`; show the user +that and send it again with `acknowledgeForeign: true` if they agree. Leave the field out otherwise: +a server before 2.3.1 refuses a body with a field it does not know. + ``` PATCH /api/v1/me/telemetry-requests/{id} { "password": "new" } or { "password": null } or { "enabled": true } +{ "enabled": true, "acknowledgeForeign": true } ``` -At least one field. `enabled` can only be `true`, and restarts a `disabled` request. On a +At least one field. `enabled` can only be `true`, and restarts a `disabled` request. Restarting one +for a repeater a foreign observer checks needs `acknowledgeForeign`, as creating one does, and +answers `409 foreign_poller` without it. On a `login_failed` or `admin_stopped` request it changes nothing: only a new password restarts those, and they keep their status and reason code even while nobody hears the repeater. `null` removes the password (a blank or hello login); on an `admin_stopped` request it is refused with @@ -1528,6 +1557,7 @@ DELETE /api/v1/me/telemetry-requests/{id} | Status | Code | When | |---|---|---| | 404 | `requests_disabled` | Requests are off. | +| 409 | `foreign_poller` | A foreign observer already checks the repeater and `acknowledgeForeign` was not sent. From 2.3.1. | | 404 | `not_found` | Unknown node, or an unknown or foreign request id. | | 409 | `already_requested` | The user already has a request for this repeater (wins over the limit). | | 409 | `request_limit` | The user holds `limit` requests. | @@ -1827,6 +1857,7 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p {"v": 2, "origin": "Name", "origin_id": "", "timestamp": "2026-11-13T22:13:20Z", "plugin": "meshcore.observer_fw/", "policy_version": "a1b2", "community": true, "accepts_requests": true, "request_slots": 3, "max_slots": 8, "poll_interval": 60, + "poll_url": "beacon.example.org", "sig": "<128 hex>", "nodes": [{"node_id": "", "reply_hops": 0, "via": null, "key": "own", "snr": 6.5, "state": "ok", "misses": 2, "last_attempt": "2026-11-13T22:11:40Z", "last_ok": "2026-11-13T22:12:30Z"}]} @@ -1853,6 +1884,8 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p it the limit is 8. `poll_interval` is how often the observer polls each repeater, in minutes; zero or a negative number counts as absent. Both are absent from firmware that does not report them. +- `poll_url` and `sig` are read from 2.3.1; an older server ignores them. See + [Claim signature](#claim-signature). - `accepts_requests`, `request_slots`, `requested`, `state`, `misses`, `last_attempt` and `last_ok` are absent from claims sent by clients without request support. Those still send `"v": 2`; there is no v1 claim. @@ -1868,6 +1901,93 @@ not retained, and refreshes it about every 30 minutes. Each claim replaces the p `reply_hops` is not `0` or `1`, its `snr` is not a finite number, or its `last_attempt` or `last_ok` is not a valid time. +### Claim signature + +Observer firmware that knows its server sends two more fields in a claim: `poll_url`, the host of +the server it takes its policy from (lowercase, with a port when it has one, for example +`beacon.example.org` or `beacon.example.org:8443`), and `sig`, an Ed25519 signature made with the +observer's own key, as 128 hex characters. The signed message is one line built from the claim's +fields: + +```text +corescope-claim/v1|||||||| +``` + +- `origin_id` in lowercase hex; `poll_url` and `timestamp` exactly as sent; the two booleans as + `true` or `false`; the two counts as plain integers. +- `targets` is each node as `:::`, with `node_id` in lowercase + hex and `requested` as `1` or `0`, sorted and joined with commas. No nodes gives an empty string. +- Because it is built from fields, a claim that a relay re-encodes or reorders still verifies. + Everything else in the claim (`policy_version`, `poll_interval`, each node's `key`, `snr`, + `last_attempt`, `last_ok`, `reply_hops`, `via`) is outside the signature. + +From 2.3.1 Beacon checks it, whatever `polling.foreign_claims` is set to: + +- A claim with neither field is unsigned. It is handled as before. +- A claim with `sig` that does not verify is dropped. So is one with only one of the two fields, + either of them `null`, a `poll_url` that is not a host, a `sig` that is not 128 hex characters, a + missing `request_slots`, `max_slots` or node `misses`, or the same node listed twice. +- A signature proves the claim came from the observer and names that server. It does not prove the + server accepted the observer. + +### Foreign observers + +A claim or reading can reach a server the observer does not follow: two servers that read the same +broker, a [rebroadcaster](configuration.md#behind-a-rebroadcaster) that forwards from many, or an +observer in the firmware's local mode that follows none. With `polling.foreign_claims: off`, the +default, the server takes every claim as its own, as it always has. With `check` it decides for +each claim, in this order: + +1. **A signed claim** is the server's own when the host of its `poll_url` is the server's `DOMAIN` + (ports are not compared). Naming any other host makes it foreign. A signed claim whose + `timestamp` is more than 65 minutes old is dropped. +2. **An unsigned claim** has no `poll_url`, so it goes by the broker it arrived on, which only a + rebroadcaster reports (`source-host`). It is the server's own when that host is in + `polling.mqtt_hosts`, and foreign when it is another host. +3. **An unsigned claim with no `source-host`** cannot be placed and is dropped. So is an unsigned + claim from an observer whose stored claim is signed and under 65 minutes old: an observer that + signs does not stop, so the fields were taken off on the way. + +A dropped claim is logged as a warning, at most once every 10 minutes for each observer. + +A foreign observer: + +- is never a poller or a standby, gets an empty owners answer, and is never given a requested + repeater. Nothing its claim reports (state, misses, admin stop) is acted on. +- has its readings stored and marked foreign. Each is trusted, and so shown, when Beacon has heard + that observer receive the repeater's zero-hop adverts within `polling.evidence_window`: the same + evidence an election counts. With `polling.authority: approved` the observer must also be + approved, as a poller must. +- never moves a repeater's `latest_ts` in the owners answer, so its readings do not hold this + server's own poller back. A repeater checked by both is polled by both. + +Other rules: + +- **A reading with no claim behind it** is stored as foreign instead of being dropped. That covers an + observer in local mode, which sends readings and no claim, and an observer of this server whose + claim has lapsed. The exception is an observer the server has assigned the repeater: a requested + repeater is assigned before the device's claim names it, and a reading it sends meanwhile is its + own. The 5 minute spacing and the 120 an hour limit apply as to any reading. +- **The same unsigned claim by two brokers** is the server's own if either copy arrived on one of + `polling.mqtt_hosts`, whichever came first. +- **Order and spacing hold across both kinds.** A claim is taken only when it is newer than the one + the observer has stored, own or foreign, so a copy that arrives late cannot undo a newer claim. + The 30 second spacing between claims counts both kinds too. +- **Changing sides.** An observer whose claim turns foreign leaves every line-up in the same step, + including a requested repeater its claim did not name yet; those repeaters are elected again and + their requests go to another observer or back to waiting. A later claim of the server's own puts + it back. +- **Turning `check` on, or changing `DOMAIN` or `polling.mqtt_hosts` with it on.** Claims already + stored were never placed under the new settings, so the server drops them at startup, before it + answers any observer. Each observer is placed again by its next claim, at most 30 minutes later. + Until then its repeaters have no poller here and its readings are stored as foreign. +- Without `MQTT_BROKER_n_REBROADCAST` on any broker there is no `source-host`, so every unsigned + claim is dropped. Startup logs a warning for that. +- `check` needs `DOMAIN` in the server's environment and stops startup without it. + +This is not the `possiblyForeign` flag on a repeater, which is about a position outside the +configured borders (see [Foreign repeater indication](#foreign-repeater-indication)). + ### Reading message Published to `.../telemetry` (`"v": 2`) or `.../battery` (`"v": 1`), same topic prefix, QoS 1, @@ -1905,7 +2025,9 @@ malformed reading (no `node_id`, an unknown `method`, a missing or unreadable `s 64-bit for the large ones) is stored as absent, never wrapped. - A reading is stored only when `origin_id` equals the topic key, the observer has a live claim listing `node_id`, the observer is not blocked, and `sampled_at` is not more than a minute in - the future or more than 2 hours old. Other readings in the message are skipped one by one. + the future or more than 2 hours old. Other readings in the message are skipped one by one. With + `polling.foreign_claims: check` a reading needs no claim: one without is stored as foreign (see + [Foreign observers](#foreign-observers)). - `packet_hash` lets Beacon count how many other observers heard the repeater's reply. It is never required. It must be 16 hex characters (8 bytes); any other value is ignored and the reading is kept without it. diff --git a/docs/configuration.md b/docs/configuration.md index edcfdcb..9b4896f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -22,6 +22,9 @@ to open). | `MQTT_BROKER_1_USERNAME` | unset | Subscriber username for broker 1. See [Getting packets in](getting-packets-in.md) for the account type you need. | | `MQTT_BROKER_1_PASSWORD` | unset | Subscriber password for broker 1. | | `MQTT_BROKER_2_URL`, `_USERNAME`, `_PASSWORD` | unset | The same for an optional second broker. A packet heard through both brokers is stored once. | +| `MQTT_BROKER_1_REBROADCAST`, `MQTT_BROKER_2_REBROADCAST` | unset | `true` when that broker is a rebroadcaster. Beacon then connects to it with MQTT 5 and reads the source of each message. Anything but `true` or `false` stops startup. See [Behind a rebroadcaster](#behind-a-rebroadcaster). | +| `DOMAIN` | unset | The host observers and browsers reach the server at. The Docker stacks already set it for Caddy; the server reads the same value. Needed for [user accounts](#user-accounts) and for `polling.foreign_claims: check`. A scheme or trailing slash left on it is dropped. | +| `WEB_DOMAIN` | unset | The web app's host when it is not `DOMAIN` (deployment type 2). Used for the links in mail. | | `BEACON_API_KEY` | unset | Bearer key for `/api/v1/admin/*`. When set, even to an empty string, it replaces `auth.api_key` from the config file. See [Admin API key](#admin-api-key). | | `MESHMAPPER_API_KEY` | unset | Regional or grouped-region key for enabled MeshMapper imports. When set, even to an empty string, it replaces `meshmapper.api_key`. Missing keys leave imports unconfigured while Beacon keeps running. See [MeshMapper API key](#meshmapper-api-key). | | `BEACON_SECRET_KEY` | unset | 32 random bytes in base64. Seals the guest passwords of [telemetry requests](telemetry-requests.md). See [BEACON_SECRET_KEY](#beacon_secret_key). | @@ -51,12 +54,13 @@ Visitors get the new values on their next page load. Any characters are fine in ## Deployment variables -These are read by `docker-compose.yml` and Caddy, not by Beacon itself. +These are read by `docker-compose.yml` and Caddy. The server reads `DOMAIN` and `WEB_DOMAIN` too +(see above); the rest it does not. | Variable | Used by | What it does | |---|---|---| -| `DOMAIN` | Caddy, both deployments | The public hostname Caddy serves and requests a certificate for. | -| `WEB_DOMAIN` | Caddy, type 2 server host only | The web frontend's hostname. Anything that is not `/api/*`, `/ws` or `/.well-known/beacon-push` is redirected there. | +| `DOMAIN` | Caddy and the server, both deployments | The public hostname Caddy serves and requests a certificate for. | +| `WEB_DOMAIN` | Caddy and the server, type 2 server host only | The web frontend's hostname. Anything that is not `/api/*`, `/ws` or `/.well-known/beacon-push` is redirected there. | | `BEACON_WEB_IMAGE` | type 2 web host | The image to run, for example `ghcr.io/meshcore-beacon/beacon-web:2.0`. Keep its `X.Y` equal to the server's. | | `POSTGRES_PASSWORD` | the `db` service | Set in `docker-compose.yml`, not `.env`. It must match the password inside `POSTGRES_DSN`. | @@ -318,6 +322,40 @@ value out of range stops the server at startup with an error naming the key. The line `config: loaded` shows the values in force (`fillDuty`, `fillMinPause`, `fillPacketSitesSlice`, `fillCmiBatch`). See [Pacing the backfills](operations.md#pacing-the-backfills). +## Behind a rebroadcaster + +A rebroadcaster is a broker that forwards messages from other MeshCore brokers and tags each one +with the broker it originally came from: + +```text +observers -> MeshCore broker -> rebroadcaster <- Beacon subscribes here +``` + +Set `MQTT_BROKER_1_REBROADCAST=true` (or `_2_`) for such a broker. Leave it unset for a MeshCore +broker that observers publish to directly; nothing about that connection changes. + +- With it set, Beacon connects to that broker with MQTT 5, the only version that carries the tags. + A broker that refuses MQTT 5 is logged as an error and retried. Beacon does not fall back to the + older protocol, because it would then lose the source of every message without saying so. +- The rebroadcaster must leave topic and payload unchanged and set two MQTT 5 user properties on + every message it forwards: + + | Property | Value | + |---|---| + | `source-broker` | A short name for the source broker: `a-z`, `0-9`, `_` or `-`, up to 64 characters. For example `letsmesh`. | + | `source-host` | The host the message arrived on, lowercase, no port. For example `mqtt.example.net`. | + +- `source-broker` becomes the broker name shown for packets and observers, in place of this + connection's own name (`mqtt1`, `mqtt2`). `source-host` is what + [`polling.foreign_claims: check`](#repeater-polling) compares with `polling.mqtt_hosts` for a + claim from older observer firmware. +- A message without the properties is still accepted and shows the connection's own name. A value + that does not fit is ignored. If a property appears twice the first one counts. +- Only the rebroadcaster should be able to publish to that broker. Anyone who can publish to it can + set the properties. +- One server process accepts at most 256 different `source-broker` names. Past that, new names are + recorded under the connection's own name and an error is logged once. + ## Repeater polling The `polling` block turns on [Repeater polling](repeater-polling.md). It is off by default. @@ -339,6 +377,7 @@ the key. | `evidence_window` | `168h` | `24h` to `720h` | How far back a repeater's zero-hop adverts count as advert evidence that an observer hears it. Adverts older than `packets.retention` are gone, so a longer window adds nothing. Raise both if your repeaters advert less than weekly. | | `requests_per_user` | `6` | 0 to 20 | How many [telemetry requests](telemetry-requests.md) one user may hold. `0` turns requests off. | | `offline_disable_days` | `7` | 1 to 365 | Days no observer hears a repeater before its requests are turned off. | +| `foreign_claims` | `off` | `off` or `check` | Whether claims can come from observers this server does not manage. `off`: every claim is taken as this server's own. `check`: see [Foreign observers](repeater-polling.md#foreign-observers). Needs `DOMAIN`. | | `request_observers` | `all` | `all` or `approved` | Which observers may be handed a requested repeater and its guest password. `all`: any observer with advert evidence for the repeater. `approved`: only observers you approved. Advert evidence is required in both modes. Set `approved` if you want to vet observers first. See [Approve observers](telemetry-requests.md#approve-observers). | The number of repeaters one observer polls is not a setting: the firmware holds 8. See @@ -370,9 +409,14 @@ except a leftover `smtp` block, which always stops startup (it moved to the top- | Key | Default | What it does | |---|---|---| | `mode` | `off` | `off` or `local`. | -| `public_url` | none | Required with `local`. The web app's address, `https` (plain `http` only for `localhost` and `127.0.0.1`), no path. Used for mailed links and the cookie's `Secure` flag. | | `registration` | `open` | `open` or `closed`. | +Accounts need the server's public address, for the links in mail and the cookie's `Secure` flag. It +is `https://` followed by `WEB_DOMAIN` from the environment, or `DOMAIN` when `WEB_DOMAIN` is not +set (plain `http` for `localhost` and `127.0.0.1`). The Docker stacks already set `DOMAIN`. With +neither set, `mode: local` stops startup with an error naming `DOMAIN`. The old `accounts.public_url` +key is no longer read; a leftover one is ignored with a warning at startup. + A third mode, `portal`, exists for the project's own MeshMapper instance. It is not supported for other deployments. @@ -398,7 +442,6 @@ mail: accounts: mode: local - public_url: https://beacon.example.org ``` A web app on another origin than the API also needs `cors.allowed_methods`, `cors.allowed_headers` diff --git a/docs/getting-packets-in.md b/docs/getting-packets-in.md index a29440f..b484268 100644 --- a/docs/getting-packets-in.md +++ b/docs/getting-packets-in.md @@ -27,6 +27,10 @@ and an ESP32 verifies an RSA certificate chain much faster than an ECDSA one. Th for the Beacon site when observers poll repeaters, where it was measured, see [An RSA certificate for the devices](repeater-polling.md#an-rsa-certificate-for-the-devices). +A broker can also be a rebroadcaster: one that forwards what other MeshCore brokers carry. Beacon +reads it like any other, and with `MQTT_BROKER_n_REBROADCAST=true` it also learns which broker each +message first arrived on. See [Behind a rebroadcaster](configuration.md#behind-a-rebroadcaster). + ## The account Beacon needs The broker defines three subscriber roles: diff --git a/docs/repeater-polling.md b/docs/repeater-polling.md index 7f0b8ec..1129a58 100644 --- a/docs/repeater-polling.md +++ b/docs/repeater-polling.md @@ -38,6 +38,54 @@ healthy observer with evidence beats it by 3 dB. So a poller that stops getting to another observer Beacon has heard the repeater through, and takes the job back once it recovers and is the stronger signal. An observer without evidence never takes the job from one with it. +## Foreign observers + +By default Beacon treats every observer that sends it a claim as one of its own. That is right when +only your observers publish to your broker. It is wrong when claims from observers that follow +another server reach yours: when two servers read the same broker, or when your server reads a +[rebroadcaster](configuration.md#behind-a-rebroadcaster) that forwards from many brokers. Beacon +would rank those observers, make one the poller, and hand it requests it never hears about. + +`polling.foreign_claims: check` makes Beacon tell them apart: + +```yaml +polling: + enabled: true + mqtt_hosts: [mqtt1.example.com] + foreign_claims: check +``` + +- An observer is yours when its claim names your server. Current observer firmware puts the host of + its `poll.url` in the claim and signs it; Beacon compares that with `DOMAIN` from the server's + environment. +- Older firmware does not say. Its claim is yours when it arrived on one of `mqtt_hosts`, which + Beacon only knows behind a rebroadcaster (`MQTT_BROKER_n_REBROADCAST=true`). Without one, a claim + from older firmware is dropped. +- Everything else is foreign: an observer that names another server, one that came in through + another broker, and one that sends readings and no claim at all, as the firmware's local mode + does. + +A foreign observer is never the poller or a standby and is never given a requested repeater, because +your server cannot tell it what to do. Its readings are still stored and shown, marked as foreign, +when Beacon has heard it receive the repeater directly. A repeater that one of your observers and a +foreign one both check is polled by both: a foreign reading does not make your poller skip its turn. +When someone requests telemetry for a repeater a foreign observer already checks, the apps ask them +to confirm first. + +Before turning it on: + +- Set `DOMAIN` to the host your observers have in `poll.url`. Startup stops without it. +- If you read a rebroadcaster, set `MQTT_BROKER_n_REBROADCAST=true` for it, or every claim from + older firmware is dropped. Startup logs a warning when `check` is on and no broker has it. +- Expect a short changeover. At the first start with `check` on, and after a change to `DOMAIN` or + `mqtt_hosts`, Beacon drops the claims it already had, because it cannot tell whose they were. Each + observer is placed again by its next claim, at most 30 minutes later. Until then its repeaters + show no poller and its readings arrive marked foreign. +- With `authority: approved`, a foreign observer's readings are shown only once you approve it. + +The exact rules, the signature and the fields the API adds are in the +[API contract](api-contract.md#foreign-observers). + ## What Beacon needs Set `polling` in `config.yaml`. See [Configuration](configuration.md#repeater-polling) for every key. diff --git a/docs/security.md b/docs/security.md index cf530ce..60829d9 100644 --- a/docs/security.md +++ b/docs/security.md @@ -56,12 +56,12 @@ Accounts are off by default; see [User accounts](accounts.md). When they are on: - Session tokens, mailed links and app codes are random and stored only as SHA-256 hashes. None of them, and no request body on `/auth` or `/me`, is logged. -- The session cookie is `HttpOnly`, `SameSite=Lax` and `Secure` (except for a localhost `public_url`). +- The session cookie is `HttpOnly`, `SameSite=Lax` and `Secure` (except for a localhost public address). Sessions end on logout, a password change (every other session; the one that made it stays), a password reset (every session), disabling the user, and expiry. - A request authenticated by the cookie that writes (`POST`, `PUT`, `PATCH`, `DELETE`) must send `X-Beacon-CSRF: 1`, and if it has an `Origin` header that must be the origin of - `accounts.public_url` or one of `cors.allowed_origins` (never `*`). Otherwise it gets `403 + the server's public address (`WEB_DOMAIN`, else `DOMAIN`) or one of `cors.allowed_origins` (never `*`). Otherwise it gets `403 csrf_rejected`. Requests with a bearer token skip this check; only a cookie lets a foreign page act for the user. - Mailed links carry their token in the URL fragment (`/?view=reset#token=...`). A browser does not diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index eae7bc0..db0900c 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -66,7 +66,7 @@ Beacon refuses to run with a setting it cannot honour. The message names the key | `log level must be debug, info, warn or error` | Check `log.level` and `LOG_LEVEL`. `log format must be text or json` is the same for format. | | `auth.api_key / BEACON_API_KEY must be at least 16 characters` | Use a longer key, with no whitespace inside it. | | `invalid polling configuration`, for example `polling.mqtt_hosts: required when polling.enabled is true` | Fix the key the error names. See [Repeater polling](configuration.md#repeater-polling). | -| `invalid accounts configuration`, for example `mail.host: required when accounts.mode is local` or `accounts.public_url: required when accounts.mode is local` | Fix the key the error names. See [User accounts](configuration.md#user-accounts). | +| `invalid accounts configuration`, for example `mail.host: required when accounts.mode is local` or `DOMAIN: required when accounts.mode is local` | Fix the key the error names. See [User accounts](configuration.md#user-accounts). | | `accounts.smtp has moved: put those settings in a top-level mail block` | Move the block. It stops startup even with `accounts.mode: off`. | | `invalid alerts configuration`, for example `alerts.push.id: required when alerts.push.enabled is true` | Fix the key the error names. See [Alerts](alerts.md#turn-them-on). | | `alerts.delivery has been replaced: set alerts.email.enabled and alerts.push.enabled instead` | Replace the old key with the two switches. | diff --git a/docs/upgrading.md b/docs/upgrading.md index d1dff7d..b12f89f 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -154,6 +154,50 @@ shows how to check it. If you enforce the [fail2ban jails](../app_config/fail2ba add `protocol="tcp,udp"` to the ban action as shown there: the default bans TCP only, so a banned address could still reach the site over HTTP/3. +## Upgrading to 2.3.1 from 2.3.0 + +**`accounts.public_url` is removed.** The server now takes its public address from the environment: +`https://` and `WEB_DOMAIN`, or `DOMAIN` when `WEB_DOMAIN` is not set. Check this before you upgrade +if accounts are on: + +- **Docker stacks:** `DOMAIN` is already in `.env`, so nothing is needed when it is the host people + open the web app at. On the split stack that host is `WEB_DOMAIN`, which the server host's `.env` + also has. Delete `public_url` from `config.yaml` when you like; a leftover one is ignored and + logs a warning at startup. +- **If your `public_url` was a different host** from `DOMAIN` (and `WEB_DOMAIN`), the links in + verification, reset and alert mail change to the `DOMAIN` host on upgrade. Set `WEB_DOMAIN` to + the old host to keep them. +- **Running the server outside the stacks:** set `DOMAIN` in its environment. With accounts on and + no `DOMAIN`, startup stops with `DOMAIN: required when accounts.mode is local`. +- Local development on `localhost` or `127.0.0.1` still gets a plain `http` address: + `DOMAIN=localhost:5173`. + +Migrations `090` to `093` run at startup. `091` adds one column to `packets` and `092` one to +`repeater_readings`, both with a constant default, so neither rewrites its table; the rest of `092` +is new, empty tables and three small columns on `polling_claims`. `093` builds a partial index on +`repeater_readings` with `CONCURRENTLY`; it covers foreign readings only, so on an upgrade it is +empty and builds at once. + +Three changes apply to every server, with no setting: + +- Packet detail lists the brokers a packet arrived through (`brokers`). Packets stored before the + upgrade have an empty list. +- An observer's broker list, and the broker filter of the observer lists, only cover the last 30 + days. A broker an observer stopped using drops off after that. +- A polling claim that carries a signature is checked, and dropped when the signature is wrong. Only + current observer firmware signs. + +Two new settings are off unless you set them: + +| Setting | What it is for | +|---|---| +| `MQTT_BROKER_n_REBROADCAST=true` in `.env` | A broker that forwards from other brokers and tags each message with its source. See [Behind a rebroadcaster](configuration.md#behind-a-rebroadcaster). | +| `polling.foreign_claims: check` | Tell your own observers from ones that follow another server. See [Foreign observers](repeater-polling.md#foreign-observers). | + +Web and mobile builds from before 2.3.1 keep working against a 2.3.1 server. The one exception is on +a server with `foreign_claims: check`: asking for telemetry on a repeater a foreign observer already +checks answers `409 foreign_poller`, which an older build shows as a failed request. + ## Upgrading to 2.3.0 from 2.2.0 This release adds migrations `064` to `087` and `089`; there is no `088`. They cover polling, user @@ -183,7 +227,7 @@ as before: | Feature | Turn it on with | Secret | |---|---|---| | Repeater polling | `polling.enabled: true` and `polling.mqtt_hosts` | none | -| Accounts | `accounts.mode: local` (needs `accounts.public_url` and `mail.host` and `mail.from`) | `BEACON_SMTP_PASSWORD` if the mail server wants a login | +| Accounts | `accounts.mode: local` (needs `mail.host` and `mail.from`, and `DOMAIN` in the server's environment) | `BEACON_SMTP_PASSWORD` if the mail server wants a login | | Telemetry requests | polling and accounts on, and `polling.requests_per_user` not `0` (default `6`) | `BEACON_SECRET_KEY` | | Alerts | `alerts.email.enabled` and/or `alerts.push.enabled` with `alerts.push.id`, with accounts on (email needs `local` mode) | `BEACON_PUSH_SECRET` for push | From b9dcb88949d4588de10de24732c8f30b0081037e Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sat, 28 Nov 2026 21:05:21 -0500 Subject: [PATCH 06/12] docs: a signed claim's state must be a plain word --- docs/api-contract.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/api-contract.md b/docs/api-contract.md index b8087c9..94540af 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -1926,7 +1926,9 @@ From 2.3.1 Beacon checks it, whatever `polling.foreign_claims` is set to: - A claim with neither field is unsigned. It is handled as before. - A claim with `sig` that does not verify is dropped. So is one with only one of the two fields, either of them `null`, a `poll_url` that is not a host, a `sig` that is not 128 hex characters, a - missing `request_slots`, `max_slots` or node `misses`, or the same node listed twice. + missing `request_slots`, `max_slots` or node `misses`, the same node listed twice, or a node + `state` that is not 1 to 32 lowercase letters or underscores. The last keeps the separators out of + a field, so the signed line can be read only one way. - A signature proves the claim came from the observer and names that server. It does not prove the server accepted the observer. From 2279638cca32146aad9c61ba9c9e11cea7ee1754 Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sat, 28 Nov 2026 22:28:57 -0500 Subject: [PATCH 07/12] docs: MQTT_BROKER_n_NAME --- app_config/.env.example | 5 +++++ docs/api-contract.md | 4 ++-- docs/configuration.md | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app_config/.env.example b/app_config/.env.example index 0470c1d..a123b36 100644 --- a/app_config/.env.example +++ b/app_config/.env.example @@ -58,6 +58,11 @@ MQTT_BROKER_2_URL=wss://mqtt2.meshcore.ca:443 MQTT_BROKER_2_USERNAME=CHANGE_NAME MQTT_BROKER_2_PASSWORD=CHANGE_PASS +# A name for each broker, shown on packets and observers instead of mqtt1 / mqtt2: 1 to 64 characters of +# a-z, 0-9, _ or -, and the two must differ. Data received before a change keeps the name it was stored under. +# MQTT_BROKER_1_NAME=mqtt1 +# MQTT_BROKER_2_NAME=mqtt2 + # Set for a broker that is a rebroadcaster: it forwards messages from other MeshCore brokers and tags each one # with the broker it originally came from. Beacon then connects with MQTT 5 and reads the tags. # observers -> MeshCore broker -> rebroadcaster <- Beacon subscribes here diff --git a/docs/api-contract.md b/docs/api-contract.md index 94540af..4a10e39 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -276,7 +276,7 @@ GET /api/v1/packets/{packetHash} | `firstHeardAt`, `lastHeardAt` | number | Epoch ms | | `firstToLastMs` | number | Spread between first and last observation | | `observationCount` | number | Observations across all observers | -| `brokers` | array of strings | The MQTT brokers the packet arrived through, by name. Behind a [rebroadcaster](configuration.md#behind-a-rebroadcaster) these are the brokers it was first published to; otherwise the server's own connections (`mqtt1`, `mqtt2`). Empty for a packet stored before 2.3.1. A broker that delivers the packet after the first can take one presence flush (a few seconds) to appear. From 2.3.1; an older server leaves the field out. | +| `brokers` | array of strings | The MQTT brokers the packet arrived through, by name. Behind a [rebroadcaster](configuration.md#behind-a-rebroadcaster) these are the brokers it was first published to; otherwise the server's own connections (`mqtt1` and `mqtt2`, or the names the operator gave them). Empty for a packet stored before 2.3.1. A broker that delivers the packet after the first can take one presence flush (a few seconds) to appear. From 2.3.1; an older server leaves the field out. | | `resolvedRoute` | array | TRACE only: the probed route, resolved hop by hop | | `observations` | array | One entry per observer hearing | @@ -847,7 +847,7 @@ Channel keys come from the server config file and, optionally, MeshMapper. | `GET /regions/{regionId}` | One region with its IATAs. `400` for a non-numeric ID, `404` if unknown. | | `GET /scopes` | Array of scope names. Location filters narrow it to manual scopes configured for a matching region and imported scopes whose MeshMapper catalogue includes a matching IATA. | | `GET /scopes/{name}` | Scope detail (`%23bc` for `#bc`). | -| `GET /brokers` | `[{ "name", "connected" }]` per MQTT connection the server has (`mqtt1`, `mqtt2`). | +| `GET /brokers` | `[{ "name", "connected" }]` per MQTT connection the server has: `mqtt1` and `mqtt2`, or the names set with `MQTT_BROKER_n_NAME`. | | `GET /brokers/sources` | `[{ "name" }]`: the brokers any observer was seen on in the last 30 days, by name. These are the values for the `broker` filter of the observer lists. Behind a [rebroadcaster](configuration.md#behind-a-rebroadcaster) they are the source brokers, which `GET /brokers` does not list. From 2.3.1. | Regions, IATA names and scopes are managed in the server config file (or imported from MeshMapper), not through the API. diff --git a/docs/configuration.md b/docs/configuration.md index 9b4896f..a91e916 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -22,6 +22,7 @@ to open). | `MQTT_BROKER_1_USERNAME` | unset | Subscriber username for broker 1. See [Getting packets in](getting-packets-in.md) for the account type you need. | | `MQTT_BROKER_1_PASSWORD` | unset | Subscriber password for broker 1. | | `MQTT_BROKER_2_URL`, `_USERNAME`, `_PASSWORD` | unset | The same for an optional second broker. A packet heard through both brokers is stored once. | +| `MQTT_BROKER_1_NAME`, `MQTT_BROKER_2_NAME` | `mqtt1`, `mqtt2` | The name each broker is stored and shown under: on a packet's brokers, an observer's brokers, the broker filter and `GET /brokers`. 1 to 64 characters of `a-z`, `0-9`, `_` or `-`; the two must differ. Anything else stops startup. Data received before a change keeps its old name: a packet for good, an observer's broker list until the old name is 30 days unseen. | | `MQTT_BROKER_1_REBROADCAST`, `MQTT_BROKER_2_REBROADCAST` | unset | `true` when that broker is a rebroadcaster. Beacon then connects to it with MQTT 5 and reads the source of each message. Anything but `true` or `false` stops startup. See [Behind a rebroadcaster](#behind-a-rebroadcaster). | | `DOMAIN` | unset | The host observers and browsers reach the server at. The Docker stacks already set it for Caddy; the server reads the same value. Needed for [user accounts](#user-accounts) and for `polling.foreign_claims: check`. A scheme or trailing slash left on it is dropped. | | `WEB_DOMAIN` | unset | The web app's host when it is not `DOMAIN` (deployment type 2). Used for the links in mail. | @@ -346,7 +347,7 @@ broker that observers publish to directly; nothing about that connection changes | `source-host` | The host the message arrived on, lowercase, no port. For example `mqtt.example.net`. | - `source-broker` becomes the broker name shown for packets and observers, in place of this - connection's own name (`mqtt1`, `mqtt2`). `source-host` is what + connection's own name (`mqtt1`, `mqtt2`, or its `MQTT_BROKER_n_NAME`). `source-host` is what [`polling.foreign_claims: check`](#repeater-polling) compares with `polling.mqtt_hosts` for a claim from older observer firmware. - A message without the properties is still accepted and shows the connection's own name. A value From ce18f0e64680a11930fb7e0ec2a1795e021d2db0 Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sat, 28 Nov 2026 23:13:59 -0500 Subject: [PATCH 08/12] docs: reading signature and reply rssi --- docs/api-contract.md | 38 ++++++++++++++++++++++++++++++++++---- docs/upgrading.md | 9 +++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/docs/api-contract.md b/docs/api-contract.md index 4a10e39..80a0353 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -1926,9 +1926,9 @@ From 2.3.1 Beacon checks it, whatever `polling.foreign_claims` is set to: - A claim with neither field is unsigned. It is handled as before. - A claim with `sig` that does not verify is dropped. So is one with only one of the two fields, either of them `null`, a `poll_url` that is not a host, a `sig` that is not 128 hex characters, a - missing `request_slots`, `max_slots` or node `misses`, the same node listed twice, or a node - `state` that is not 1 to 32 lowercase letters or underscores. The last keeps the separators out of - a field, so the signed line can be read only one way. + missing `request_slots`, `max_slots` or node `misses`, the same node listed twice, a node + `state` that is not 1 to 32 lowercase letters or underscores, or any key named twice in the JSON. + The state rule keeps the separators out of a field, so the signed line can be read only one way. - A signature proves the claim came from the observer and names that server. It does not prove the server accepted the observer. @@ -2002,7 +2002,7 @@ malformed reading (no `node_id`, an unknown `method`, a missing or unreadable `s {"v":2,"origin":"Name","origin_id":"","timestamp":"2026-11-13T22:13:23Z", "plugin":"meshcore.observer_fw/","readings":[{"node_id":"","battery_mv":4038, "source":"poll","reply_hops":0,"method":"status","sampled_at":"2026-11-13T22:13:20Z","snr":6.5, - "stats":{"uptime_secs":788089,"noise_floor":-116,"last_rssi":-114,"last_snr":1.25,"tx_queue":0, + "rssi":-101,"stats":{"uptime_secs":788089,"noise_floor":-116,"last_rssi":-114,"last_snr":1.25,"tx_queue":0, "packets_recv":81234,"packets_sent":20276,"recv_flood":76198,"recv_direct":5012, "sent_flood":19211,"sent_direct":1065,"tx_air_secs":18301,"rx_air_secs":73835, "flood_dups":56298,"direct_dups":36,"recv_errors":28074,"err_events":2}, @@ -2033,6 +2033,36 @@ malformed reading (no `node_id`, an unknown `method`, a missing or unreadable `s - `packet_hash` lets Beacon count how many other observers heard the repeater's reply. It is never required. It must be 16 hex characters (8 bytes); any other value is ignored and the reading is kept without it. +- `rssi` is the signal strength of the repeater's reply at the observer, a whole number in dBm + (from 2.3.1). Beacon stores it when it is between -200 and 0 and ignores any other value. It is + not returned by the API yet. + +#### Reading signature + +Observer firmware that signs its claims also signs each reading message: a top-level `sig`, an +Ed25519 signature made with the observer's own key, as 128 hex characters. A signed message holds +exactly one reading. The signed message is one line built from the fields: + +```text +corescope-reading/v1||||||||||||||| +``` + +- `origin_id`, `node_id`, `packet_hash` and `lpp` in lowercase hex; `timestamp` and `sampled_at` + exactly as sent, in the form `2026-11-13T22:13:20.000000+00:00`. +- Numbers as plain integers: `temperature_c` and `snr` times 10, the rest as sent. +- `stats` is each field as `=`, sorted by name and joined with commas, with `last_snr` + times 100. +- A field the reading does not carry is an empty string. `origin`, `plugin` and `source` are + outside the signature. + +From 2.3.1 Beacon checks it: + +- A message with no `sig` is unsigned. It is handled as before. +- A message with `sig` that does not verify is dropped and logged as a warning. So is one with more + or fewer than one reading, a `sig` that is `null` or not 128 hex characters, a time in another + form, a `temperature_c` or `snr` finer than one decimal, a `last_snr` finer than two, a `stats` + field not in the list above, a v1 message with no `battery_mv`, a `null` in a signed field, or + any key named twice in the JSON. --- diff --git a/docs/upgrading.md b/docs/upgrading.md index b12f89f..613b2f8 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -172,11 +172,12 @@ if accounts are on: - Local development on `localhost` or `127.0.0.1` still gets a plain `http` address: `DOMAIN=localhost:5173`. -Migrations `090` to `093` run at startup. `091` adds one column to `packets` and `092` one to +Migrations `090` to `094` run at startup. `091` adds one column to `packets` and `092` one to `repeater_readings`, both with a constant default, so neither rewrites its table; the rest of `092` is new, empty tables and three small columns on `polling_claims`. `093` builds a partial index on `repeater_readings` with `CONCURRENTLY`; it covers foreign readings only, so on an upgrade it is -empty and builds at once. +empty and builds at once. `094` adds two more columns to `repeater_readings`, again without a +rewrite. Three changes apply to every server, with no setting: @@ -184,8 +185,8 @@ Three changes apply to every server, with no setting: upgrade have an empty list. - An observer's broker list, and the broker filter of the observer lists, only cover the last 30 days. A broker an observer stopped using drops off after that. -- A polling claim that carries a signature is checked, and dropped when the signature is wrong. Only - current observer firmware signs. +- A polling claim or reading that carries a signature is checked, and dropped when the signature is + wrong. Only current observer firmware signs. Two new settings are off unless you set them: From 96229a4fbf024f82e45cfb8a34bad54d6cc23a58 Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sat, 28 Nov 2026 23:17:48 -0500 Subject: [PATCH 09/12] docs: signed messages take lowercase keys only --- docs/api-contract.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-contract.md b/docs/api-contract.md index 80a0353..cf772e0 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -1927,7 +1927,7 @@ From 2.3.1 Beacon checks it, whatever `polling.foreign_claims` is set to: - A claim with `sig` that does not verify is dropped. So is one with only one of the two fields, either of them `null`, a `poll_url` that is not a host, a `sig` that is not 128 hex characters, a missing `request_slots`, `max_slots` or node `misses`, the same node listed twice, a node - `state` that is not 1 to 32 lowercase letters or underscores, or any key named twice in the JSON. + `state` that is not 1 to 32 lowercase letters or underscores, or any key named twice or not in plain lowercase. The state rule keeps the separators out of a field, so the signed line can be read only one way. - A signature proves the claim came from the observer and names that server. It does not prove the server accepted the observer. @@ -2062,7 +2062,7 @@ From 2.3.1 Beacon checks it: or fewer than one reading, a `sig` that is `null` or not 128 hex characters, a time in another form, a `temperature_c` or `snr` finer than one decimal, a `last_snr` finer than two, a `stats` field not in the list above, a v1 message with no `battery_mv`, a `null` in a signed field, or - any key named twice in the JSON. + any key named twice or not in plain lowercase. --- From 03de9600db302b02a8c556b6c92b9f91243c9771 Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sun, 29 Nov 2026 05:56:30 -0500 Subject: [PATCH 10/12] docs: poller view latest reading rssi and signed --- docs/api-contract.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/api-contract.md b/docs/api-contract.md index cf772e0..35aa630 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -592,7 +592,9 @@ The other side of [Node polling](#node-polling): what an observer that polls say "claimedSnr": 9.5, "evidenceSnr": 8.1, "evidenceCount": 14, - "latestReadingAt": 1795799000000 + "latestReadingAt": 1795799000000, + "latestReadingRssi": -87, + "latestReadingSigned": true } ] } @@ -627,6 +629,8 @@ Each target: | `claimedSnr` | The SNR the observer reports for the repeater, or `null`. | | `evidenceSnr`, `evidenceCount` | Zero-hop adverts of the repeater that Beacon saw through this observer within `polling.evidence_window` (7 days by default) before the last election: their mean SNR and how many. `null` and `0` for an unassigned repeater or one with no such adverts. | | `latestReadingAt` | `sampledAt` of the newest reading this observer delivered for the repeater, trusted or not. `null` when it has delivered none. | +| `latestReadingRssi` | How strongly the observer heard the repeater's reply for that reading, in dBm. `null` when there is no reading or its firmware does not report it. From 2.3.1. | +| `latestReadingSigned` | `true` when that reading carried the observer's signature and it checked out (see [Reading signature](#reading-signature)). From 2.3.1. | #### MeshMapper repeater details @@ -2034,8 +2038,8 @@ malformed reading (no `node_id`, an unknown `method`, a missing or unreadable `s never required. It must be 16 hex characters (8 bytes); any other value is ignored and the reading is kept without it. - `rssi` is the signal strength of the repeater's reply at the observer, a whole number in dBm - (from 2.3.1). Beacon stores it when it is between -200 and 0 and ignores any other value. It is - not returned by the API yet. + (from 2.3.1). Beacon stores it when it is between -200 and 0 and ignores any other value. The + poller view returns the newest one as `latestReadingRssi`. #### Reading signature From 62582ea1267123a269ea9c0518a979ed3d65db9d Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sun, 29 Nov 2026 09:02:05 -0500 Subject: [PATCH 11/12] docs: foreign pollers are tagged pollers --- docs/api-contract.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/api-contract.md b/docs/api-contract.md index 35aa630..3045fba 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -365,7 +365,7 @@ Adverts with a bad signature are not decoded and have no `parsedPayload`. | `GET /nodes/{nodeId}/polling` | Which observer polls the node and when it last got a trusted reading. See [Node polling](#node-polling). | | `GET /nodes/{nodeId}/poller` | For a node that is a poller: how many of its slots are used and the repeaters it polls. See [Node poller](#node-poller). | -`/nodes` params: `type` (1 companion, 2 repeater, 3 room server, 4 sensor) or `typeName`, the location filters, `name` (partial, case-insensitive), `scope`, `pubkey` (exact hex), `pubkeyPrefix`, `supportsMultibytePaths`, `supportsMultibyteTraces`, `poller` (`true` keeps only nodes with a stored polling claim, `false` drops them, omit for no filter; a value that is not a boolean answers `400`), `neighbors` (adds `neighborIds`), `sort`, `order`, `cursor`, `pageCursor`, `limit`. Summaries include `lastSeen` (when the node was last heard, epoch ms; list rows carry it from 2.1.1, node detail always has), `stale` (not seen within `nodes.stale_threshold`), `isPoller` (`true` when the node's public key has a stored polling claim, so it is an observer running polling firmware, assigned to a repeater or not; see [repeater polling](repeater-polling.md#seeing-the-readings)), `defaultScope` (the transport scope last matched from the node's adverts, omitted when none; list rows carry it from 2.1.0, node detail always has) and, when `nodes.mark_foreign` is on, `possiblyForeign`. To list one scope's nodes, send `scope` rather than filtering rows: a server before 2.1.0 leaves `defaultScope` off list rows. +`/nodes` params: `type` (1 companion, 2 repeater, 3 room server, 4 sensor) or `typeName`, the location filters, `name` (partial, case-insensitive), `scope`, `pubkey` (exact hex), `pubkeyPrefix`, `supportsMultibytePaths`, `supportsMultibyteTraces`, `poller` (`true` keeps only nodes with a stored polling claim, the server's own or a [foreign](#foreign-observers) one, `false` drops them, omit for no filter; a value that is not a boolean answers `400`), `neighbors` (adds `neighborIds`), `sort`, `order`, `cursor`, `pageCursor`, `limit`. Summaries include `lastSeen` (when the node was last heard, epoch ms; list rows carry it from 2.1.1, node detail always has), `stale` (not seen within `nodes.stale_threshold`), `isPoller` (`true` when the node's public key has a stored polling claim, so it is an observer running polling firmware, assigned to a repeater or not; see [repeater polling](repeater-polling.md#seeing-the-readings)), `defaultScope` (the transport scope last matched from the node's adverts, omitted when none; list rows carry it from 2.1.0, node detail always has) and, when `nodes.mark_foreign` is on, `possiblyForeign`. To list one scope's nodes, send `scope` rather than filtering rows: a server before 2.1.0 leaves `defaultScope` off list rows. Sorted node lists (2.1.0): `sort` is `lastSeen` (the default), `name`, `type` or `neighbors`, and `order` is `asc` (the default) or `desc`. `lastSeen` defaults to `desc`, the newest-first list; from 2.1.1 it also takes `asc`, oldest heard first, which is a sorted list like the others (a server before 2.1.1 answers it with a `400`). Every page says which order it is in with `sort` and `order` (`lastSeen` and `desc` by default). The orders match what the web's node table shows: @@ -1960,6 +1960,9 @@ A foreign observer: - is never a poller or a standby, gets an empty owners answer, and is never given a requested repeater. Nothing its claim reports (state, misses, admin stop) is acted on. +- is still tagged a poller: its node has `isPoller` `true` and, from 2.3.1, `isForeignPoller` `true`, + and the `poller` filter of `/nodes` keeps it. An observer that sends readings and no claim has + neither. A client must treat a missing `isForeignPoller`, as sent by an older server, as `false`. - has its readings stored and marked foreign. Each is trusted, and so shown, when Beacon has heard that observer receive the repeater's zero-hop adverts within `polling.evidence_window`: the same evidence an election counts. With `polling.authority: approved` the observer must also be @@ -2264,7 +2267,7 @@ Connections with `includeRepeats` also get repeats, which have `packet.isRepeat: } ``` -`lat`/`lng` omitted means the advert had no position (keep the one you have); `null` means the advert cleared it. `iatas` holds only the IATA that heard this advert, so merge it into what you have. `isPoller` is `true` when the node has a stored polling claim. `possiblyForeign` is only sent when `nodes.mark_foreign` is on, and is omitted for a repeater advert with no position (keep the value you have). `defaultScope` and `radio` are omitted when unknown. +`lat`/`lng` omitted means the advert had no position (keep the one you have); `null` means the advert cleared it. `iatas` holds only the IATA that heard this advert, so merge it into what you have. `isPoller` is `true` when the node has a stored polling claim, the server's own or a foreign one. `possiblyForeign` is only sent when `nodes.mark_foreign` is on, and is omitted for a repeater advert with no position (keep the value you have). `defaultScope` and `radio` are omitted when unknown. **`channelMessage`**: a group text was decrypted into a new message. The `data` is the same shape as a REST message (see [Channels and messages](#channels-and-messages)) plus `channelId`, without `observationCount`. From bbce4d2ebb50c983ab4fdecf5e9643b1510620aa Mon Sep 17 00:00:00 2001 From: MrAlders0n Date: Sun, 29 Nov 2026 10:54:59 -0500 Subject: [PATCH 12/12] docs: mail.tls_skip_verify, per-claim slot limits and the gaps a 2.3.1 check found --- README.md | 4 ++-- app_config/config.yaml.example | 3 +++ docs/accounts.md | 5 +++-- docs/api-contract.md | 30 ++++++++++++++++++------------ docs/configuration.md | 10 ++++++---- docs/repeater-polling.md | 31 +++++++++++++++++++++++-------- docs/telemetry-requests.md | 6 ++++++ docs/troubleshooting.md | 4 ++++ docs/upgrading.md | 22 +++++++++++++++------- 9 files changed, 80 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 90ecaf5..d07bad3 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Set every `CHANGE_*` value. The ones you cannot skip: |---|---| | `POSTGRES_DSN` | The database connection string. Change `CHANGE_DB_PASS` to a strong password. **The same password must go in `POSTGRES_PASSWORD` in `docker-compose.yml`.** | | `MQTT_BROKER_1_URL`, `_USERNAME`, `_PASSWORD` | Your MeshCore MQTT broker and the subscriber account on it. The template also lists a second broker; if you have only one, clear `MQTT_BROKER_2_URL` (an empty URL disables that worker). | -| `DOMAIN` | Your public hostname, for example `beacon.example.com`. Caddy requests a Let's Encrypt certificate for it. | +| `DOMAIN` | Your public hostname, for example `beacon.example.com`. Caddy requests a Let's Encrypt certificate for it. The server reads it too, for the links in account mail. | | `VITE_API_BASE` | `https:///api/v1`. The browser calls this, so it must be the public domain, never `localhost`. | | `VITE_WS_URL` | `wss:///ws` | @@ -154,7 +154,7 @@ gone private; see [Troubleshooting](docs/troubleshooting.md#docker-compose-up-fa - [Reverse proxy](docs/reverse-proxy.md): Caddy, nginx, Apache, rate limits, split origins, and an RSA certificate for observers. - [Securing a deployment](docs/security.md): the admin key, the listener, origins, bans. - [Day-to-day operations](docs/operations.md): health, logs, retention, backup and restore. -- [Upgrading](docs/upgrading.md): 2.0.0 from 1.x, 2.1, 2.3.0 from 2.2.0, and routine upgrades. +- [Upgrading](docs/upgrading.md): 2.0.0 from 1.x, 2.1, 2.3.0 from 2.2.0, 2.3.1 from 2.3.0, and routine upgrades. - [Troubleshooting](docs/troubleshooting.md): symptom, cause, fix. - [Releases and versioning](docs/releases.md): image tags and how releases are cut. diff --git a/app_config/config.yaml.example b/app_config/config.yaml.example index ba4dfe7..1d09e3b 100644 --- a/app_config/config.yaml.example +++ b/app_config/config.yaml.example @@ -481,6 +481,9 @@ cache: # username: "" # SMTP login; empty sends without signing in # from: "" # the sender people see, e.g. "Beacon " # starttls: true # require an encrypted connection; the send fails if the server lacks STARTTLS +# tls_skip_verify: false # true accepts a certificate that cannot be verified (self-signed, private CA), +# # for a mail server you host yourself. The link stays encrypted but the server +# # is not checked, so use it only on a network you trust. # User accounts: sign-in for the web app and the mobile app. Off by default; with it off # no account route is served. Mode local sends mail through the mail block above. diff --git a/docs/accounts.md b/docs/accounts.md index c735421..7adf63d 100644 --- a/docs/accounts.md +++ b/docs/accounts.md @@ -32,8 +32,8 @@ accounts: registration: open ``` -The server also needs to know its public address, for the links it mails. It takes it from the -environment: `https://` and `WEB_DOMAIN`, or `DOMAIN` when the web app and the API share a host. +The server also needs to know its public address, for the links it mails. It builds it from the +environment: `https://` plus `WEB_DOMAIN`, or plus `DOMAIN` when `WEB_DOMAIN` is not set. The Docker stacks already set `DOMAIN` in `.env`. Outside them, set it yourself. Put the SMTP password in the environment, never in the file: @@ -53,6 +53,7 @@ In the Docker stacks that is the `.env` of the host that runs the server. Then r | `mail.username` | empty | Empty means no authentication. When set, Beacon uses AUTH PLAIN, and the server must offer AUTH. | | `mail.from` | none | Required, one address, for example `"Beacon "`. | | `mail.starttls` | `true` | When true the send fails if the server does not offer STARTTLS; Beacon never falls back to plain text. Set `false` only for a trusted local relay. | +| `mail.tls_skip_verify` | `false` | `true` accepts a mail server certificate that cannot be verified (self-signed, private CA, wrong name). The connection is still encrypted, but the server is not checked, so use it only for a mail server you run yourself on a network you trust. Applies to account mail and alert mail. Startup logs a warning while it is on. No effect with `starttls: false`. | `BEACON_SMTP_PASSWORD` is the only account secret that comes from the environment. A mistake in the block stops startup with an error naming the key. An `smtp` block left under `accounts` stops startup diff --git a/docs/api-contract.md b/docs/api-contract.md index 3045fba..7f26dda 100644 --- a/docs/api-contract.md +++ b/docs/api-contract.md @@ -365,7 +365,7 @@ Adverts with a bad signature are not decoded and have no `parsedPayload`. | `GET /nodes/{nodeId}/polling` | Which observer polls the node and when it last got a trusted reading. See [Node polling](#node-polling). | | `GET /nodes/{nodeId}/poller` | For a node that is a poller: how many of its slots are used and the repeaters it polls. See [Node poller](#node-poller). | -`/nodes` params: `type` (1 companion, 2 repeater, 3 room server, 4 sensor) or `typeName`, the location filters, `name` (partial, case-insensitive), `scope`, `pubkey` (exact hex), `pubkeyPrefix`, `supportsMultibytePaths`, `supportsMultibyteTraces`, `poller` (`true` keeps only nodes with a stored polling claim, the server's own or a [foreign](#foreign-observers) one, `false` drops them, omit for no filter; a value that is not a boolean answers `400`), `neighbors` (adds `neighborIds`), `sort`, `order`, `cursor`, `pageCursor`, `limit`. Summaries include `lastSeen` (when the node was last heard, epoch ms; list rows carry it from 2.1.1, node detail always has), `stale` (not seen within `nodes.stale_threshold`), `isPoller` (`true` when the node's public key has a stored polling claim, so it is an observer running polling firmware, assigned to a repeater or not; see [repeater polling](repeater-polling.md#seeing-the-readings)), `defaultScope` (the transport scope last matched from the node's adverts, omitted when none; list rows carry it from 2.1.0, node detail always has) and, when `nodes.mark_foreign` is on, `possiblyForeign`. To list one scope's nodes, send `scope` rather than filtering rows: a server before 2.1.0 leaves `defaultScope` off list rows. +`/nodes` params: `type` (1 companion, 2 repeater, 3 room server, 4 sensor) or `typeName`, the location filters, `name` (partial, case-insensitive), `scope`, `pubkey` (exact hex), `pubkeyPrefix`, `supportsMultibytePaths`, `supportsMultibyteTraces`, `poller` (`true` keeps only nodes with a stored polling claim, the server's own or a [foreign](#foreign-observers) one, `false` drops them, omit for no filter; a value that is not a boolean answers `400`), `neighbors` (adds `neighborIds`), `sort`, `order`, `cursor`, `pageCursor`, `limit`. Summaries include `lastSeen` (when the node was last heard, epoch ms; list rows carry it from 2.1.1, node detail always has), `stale` (not seen within `nodes.stale_threshold`), `isPoller` (`true` when the node's public key has a stored polling claim, so it is an observer running polling firmware, assigned to a repeater or not; see [repeater polling](repeater-polling.md#seeing-the-readings)), `isForeignPoller` (`true` when that claim is a [foreign](#foreign-observers) one; from 2.3.1, treat a missing field as `false`), `defaultScope` (the transport scope last matched from the node's adverts, omitted when none; list rows carry it from 2.1.0, node detail always has) and, when `nodes.mark_foreign` is on, `possiblyForeign`. To list one scope's nodes, send `scope` rather than filtering rows: a server before 2.1.0 leaves `defaultScope` off list rows. Sorted node lists (2.1.0): `sort` is `lastSeen` (the default), `name`, `type` or `neighbors`, and `order` is `asc` (the default) or `desc`. `lastSeen` defaults to `desc`, the newest-first list; from 2.1.1 it also takes `asc`, oldest heard first, which is a sorted list like the others (a server before 2.1.1 answers it with a `400`). Every page says which order it is in with `sort` and `order` (`lastSeen` and `desc` by default). The orders match what the web's node table shows: @@ -550,7 +550,6 @@ Who polls this node right now. A `400` for a `nodeId` that is not a UUID and a ` | `latestReadingAt` | Time of the newest trusted reading, epoch ms. `null` when there is none, even if untrusted readings exist. | | `poller` | The observer ranked first: `observerId` and `name`. `null` when nobody is assigned. | | `standbys` | The other assigned observers, in rank order, each with `observerId`, `name` and `rank` (1, 2, ...). An empty array when there are none. The poller has no `rank` field. | - | `foreign` | [Foreign observers](#foreign-observers) that check the node: a live foreign claim names it, or one delivered a reading of it in the last 24 hours. Each has `observerId`, `name`, `pollHost` (the server it says it follows, or `null`), `signed` (its claim's signature checked out), `claimed` (`false` for one that only sends readings) and `latestReadingAt` (its newest reading of the node, epoch ms or `null`). By name. They are never the poller or a standby. An empty array when there are none, which is always the case with `polling.foreign_claims: off`. From 2.3.1. | `name` is the observer's display name, or the first 8 hex characters of its public key when it has none. @@ -607,7 +606,7 @@ The other side of [Node polling](#node-polling): what an observer that polls say | `claim.live` | True while the claim is under 65 minutes old. A claim is kept for about a day after that, so `false` means the observer has stopped claiming. `isPoller` on the node does not check this. | | `claim.acceptsRequests` | The observer takes repeaters handed out by [telemetry requests](#telemetry-requests). | | `claim.signed` | True when the claim carried a [signature](#claim-signature) made with the observer's own key and it checked out: the claim came from this observer and was not changed on the way. `false` for firmware that does not sign. From 2.3.1. | -| `claim.foreign` | True for a [foreign observer](#foreign-observers). Its `targets` then all have `role` `unassigned`, `acceptsRequests` is `false`, and `slots` only counts `used` and `own`. From 2.3.1. | +| `claim.foreign` | True for a [foreign observer](#foreign-observers). Its `targets` then all have `role` `unassigned`, `acceptsRequests` is `false`, and `slots` only counts `used` and `own`. `slots.max` is then 8 and `pollIntervalMinutes` is `null` whatever the claim said, and each target has only `state`, `misses` and the latest reading fields; `requested` is `false` and `lastAttempt`, `lastOk` and `claimedSnr` are `null`. From 2.3.1. | | `claim.pollHost` | The host of the claim's `poll_url`: the server the observer says it follows. `null` when its firmware does not send one. From 2.3.1. | | `claim.pollIntervalMinutes` | How often the observer polls each repeater, in minutes, from the claim's `poll_interval`. `null` when its firmware does not report it. From 2.3.1; an older server leaves the field out. | | `claim.slots` | `max` is the most repeaters this observer holds: the claim's `max_slots`, or 8 when its firmware does not report one (always 8 before 2.3.1). `used` is how many the claim lists, split into `own` (set up by the observer's owner) and `requested`. `free` is how many more requested repeaters Beacon could hand it now: the free seats the claim reported, never more than `max` minus `used`, less any seats Beacon has handed out that the claim does not list yet. It is `0` when the claim is not live or does not accept requests. `used` plus `free` can be less than `max`. | @@ -1483,7 +1482,9 @@ GET /api/v1/me/telemetry-requests Oldest first. `poller` and `latestReadingAt` are `null` when there is none; `latestReadingAt` is the newest trusted reading. `statusReasonDays` (integer) is present only with the `offline` code. A -password is never returned, only `hasPassword`. +password is never returned, only `hasPassword`. `updatedAt` is when the request last changed: an +edit by the user, or a change of `status` or `statusReasonCode` made by the server (from 2.3.1; +before, a status change that followed an election or a claim left it unchanged). `poller.state` is what the poller's own latest live claim says about this repeater, so a user can see why a poll is not working even while `status` is `active`. `poller.stateAt` is epoch ms when that claim @@ -1950,9 +1951,10 @@ each claim, in this order: 2. **An unsigned claim** has no `poll_url`, so it goes by the broker it arrived on, which only a rebroadcaster reports (`source-host`). It is the server's own when that host is in `polling.mqtt_hosts`, and foreign when it is another host. -3. **An unsigned claim with no `source-host`** cannot be placed and is dropped. So is an unsigned - claim from an observer whose stored claim is signed and under 65 minutes old: an observer that - signs does not stop, so the fields were taken off on the way. +3. **An unsigned claim with no `source-host`** cannot be placed and is dropped. An unsigned claim + is also dropped when the same observer's stored claim is signed and under 65 minutes old. + Firmware that signs keeps signing, so an unsigned claim from it means the signature was removed + on the way. A dropped claim is logged as a warning, at most once every 10 minutes for each observer. @@ -1982,9 +1984,10 @@ Other rules: - **Order and spacing hold across both kinds.** A claim is taken only when it is newer than the one the observer has stored, own or foreign, so a copy that arrives late cannot undo a newer claim. The 30 second spacing between claims counts both kinds too. -- **Changing sides.** An observer whose claim turns foreign leaves every line-up in the same step, - including a requested repeater its claim did not name yet; those repeaters are elected again and - their requests go to another observer or back to waiting. A later claim of the server's own puts +- **Changing sides.** When an observer's claim turns foreign, the observer is removed at once from + every repeater it was poller or standby for, including a requested repeater its claim had not + named yet. Those repeaters are elected again, and their requests go to another observer or back + to waiting. A later claim of the server's own puts it back. - **Turning `check` on, or changing `DOMAIN` or `polling.mqtt_hosts` with it on.** Claims already stored were never placed under the new settings, so the server drops them at startup, before it @@ -2039,7 +2042,8 @@ malformed reading (no `node_id`, an unknown `method`, a missing or unreadable `s [Foreign observers](#foreign-observers)). - `packet_hash` lets Beacon count how many other observers heard the repeater's reply. It is never required. It must be 16 hex characters (8 bytes); any other value is ignored and the - reading is kept without it. + reading is kept without it. In a signed message a `packet_hash` of another length fails the + signature check and the message is dropped. - `rssi` is the signal strength of the repeater's reply at the observer, a whole number in dBm (from 2.3.1). Beacon stores it when it is between -200 and 0 and ignores any other value. The poller view returns the newest one as `latestReadingRssi`. @@ -2067,7 +2071,9 @@ From 2.3.1 Beacon checks it: - A message with no `sig` is unsigned. It is handled as before. - A message with `sig` that does not verify is dropped and logged as a warning. So is one with more or fewer than one reading, a `sig` that is `null` or not 128 hex characters, a time in another - form, a `temperature_c` or `snr` finer than one decimal, a `last_snr` finer than two, a `stats` + form, a missing or negative `reply_hops`, a `node_id` that is not 64 hex characters, a + `packet_hash` that is not 16 hex characters, a whole-number field not written as a plain integer, + a `temperature_c` or `snr` finer than one decimal, a `last_snr` finer than two, a `stats` field not in the list above, a v1 message with no `battery_mv`, a `null` in a signed field, or any key named twice or not in plain lowercase. diff --git a/docs/configuration.md b/docs/configuration.md index a91e916..4b4b019 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -354,8 +354,8 @@ broker that observers publish to directly; nothing about that connection changes that does not fit is ignored. If a property appears twice the first one counts. - Only the rebroadcaster should be able to publish to that broker. Anyone who can publish to it can set the properties. -- One server process accepts at most 256 different `source-broker` names. Past that, new names are - recorded under the connection's own name and an error is logged once. +- Each rebroadcaster connection accepts at most 256 different `source-broker` names. Past that, new + names are recorded under the connection's own name and an error is logged once for that connection. ## Repeater polling @@ -378,10 +378,11 @@ the key. | `evidence_window` | `168h` | `24h` to `720h` | How far back a repeater's zero-hop adverts count as advert evidence that an observer hears it. Adverts older than `packets.retention` are gone, so a longer window adds nothing. Raise both if your repeaters advert less than weekly. | | `requests_per_user` | `6` | 0 to 20 | How many [telemetry requests](telemetry-requests.md) one user may hold. `0` turns requests off. | | `offline_disable_days` | `7` | 1 to 365 | Days no observer hears a repeater before its requests are turned off. | -| `foreign_claims` | `off` | `off` or `check` | Whether claims can come from observers this server does not manage. `off`: every claim is taken as this server's own. `check`: see [Foreign observers](repeater-polling.md#foreign-observers). Needs `DOMAIN`. | +| `foreign_claims` | `off` | `off` or `check` | Whether claims can come from observers this server does not manage. `off`: every claim is taken as this server's own. `check`: see [Foreign observers](repeater-polling.md#foreign-observers). Needs `DOMAIN`, and that is checked even while `enabled` is `false`. | | `request_observers` | `all` | `all` or `approved` | Which observers may be handed a requested repeater and its guest password. `all`: any observer with advert evidence for the repeater. `approved`: only observers you approved. Advert evidence is required in both modes. Set `approved` if you want to vet observers first. See [Approve observers](telemetry-requests.md#approve-observers). | -The number of repeaters one observer polls is not a setting: the firmware holds 8. See +The number of repeaters one observer polls is not a server setting. Each observer reports its own +limit (`max_slots`), 8 unless changed on the device, and Beacon believes at most 32. See [Fixed limits](repeater-polling.md#fixed-limits). Telemetry requests also need accounts on and `BEACON_SECRET_KEY`; see @@ -432,6 +433,7 @@ moved. | `mail.username` | empty | Empty means no authentication. | | `mail.from` | none | Required with `local`. One address, for example `"Beacon "`. | | `mail.starttls` | `true` | When true the send fails unless the server offers STARTTLS. | +| `mail.tls_skip_verify` | `false` | `true` accepts a certificate that cannot be verified (self-signed, private CA). Encrypted, but the server is not checked. See [User accounts](accounts.md#turn-them-on). | The SMTP password is `BEACON_SMTP_PASSWORD` in the environment, never in the file. diff --git a/docs/repeater-polling.md b/docs/repeater-polling.md index 1129a58..da79729 100644 --- a/docs/repeater-polling.md +++ b/docs/repeater-polling.md @@ -74,7 +74,8 @@ to confirm first. Before turning it on: -- Set `DOMAIN` to the host your observers have in `poll.url`. Startup stops without it. +- Set `DOMAIN` to the host your observers have in `poll.url`. Startup stops without it. Give the + host only; a value with a path never matches. - If you read a rebroadcaster, set `MQTT_BROKER_n_REBROADCAST=true` for it, or every claim from older firmware is dropped. Startup logs a warning when `check` is on and no broker has it. - Expect a short changeover. At the first start with `check` on, and after a change to `DOMAIN` or @@ -138,7 +139,8 @@ set poll on - `poll.url` is the Beacon site, with `https://` and no path. Changing it makes the device wait for a fresh policy before it polls again. - `poll add` takes the repeater's 64 character public key, or a key prefix that matches exactly - one neighbour the device has heard. Repeat it for each repeater, up to 8. The repeater must be + one neighbour the device has heard. Repeat it for each repeater, up to the device's + target limit (8 unless changed on the device). The repeater must be a direct neighbour that the observer heard in the last day. The observer never floods to reach one. The firmware's neighbour table holds repeaters only, so this build cannot poll a room server. @@ -168,12 +170,12 @@ Some limits are built into the observer firmware and the server. They have no se | Limit | Value | |---|---| -| Repeaters one observer polls | 8. This counts the repeaters its owner added and the ones Beacon hands it through [telemetry requests](telemetry-requests.md). | +| Repeaters one observer polls | The limit the observer reports in its claim (`max_slots`), 8 when its firmware reports none, and never more than 32. This counts the repeaters its owner added and the ones Beacon hands it through [telemetry requests](telemetry-requests.md). | | Observers assigned to one requested repeater | 3: one poller and two standbys. | | Repeaters an operator can exclude | 16, across the config and the admin route. | A requested repeater is only -handed to an observer that reports a free seat, so an observer whose owner filled all 8 takes no +handed to an observer that reports a free seat, so an observer whose owner filled every slot takes no requests. To change how much polling happens, use these instead (see [Configuration](configuration.md#repeater-polling)): @@ -214,6 +216,11 @@ Beacon accepts a reading only when all of these hold: - `sampled_at` is at most 1 minute ahead of Beacon's clock and not older than 2 hours. - The observer is not blocked. +With `polling.foreign_claims: check` the second condition does not drop a reading: one with no +claim behind it is stored as foreign. A reading message that carries a signature must also pass +the signature check, whatever the setting. In a signed message a `packet_hash` of the wrong length +fails that check. + ## Seeing the readings With polling enabled, a repeater's or room server's detail view in Beacon Web and in the mobile @@ -224,22 +231,30 @@ and shows readings for room servers too, but the current polling firmware polls Only trusted readings are charted. A reading is trusted when its observer was assigned to the repeater and Beacon had itself heard the repeater directly through that observer when the reading -was stored. Readings from any other observer are kept but left out of the charts. To see them, +was stored. A foreign observer is never assigned, so its reading is trusted on the advert evidence +alone (and, with `authority: approved`, your approval). Readings from any other observer are kept +but left out of the charts. To see them, call the API with `include=untrusted`, for example `/api/v1/nodes/{nodeId}/telemetry?range=168h&include=untrusted`. The answer also says how many readings it left out. See the [API contract](api-contract.md#node-telemetry). A Poller tag means a stored claim exists for that observer, whether or not it is assigned a repeater. The hourly cleanup removes a claim about a day after the last one received, and the tag goes with it. Claims from a blocked observer are not stored. An observer blocked after claiming keeps the tag until its claim is cleaned up. With polling off no new claims are stored, so existing tags clear within about a day. The API carries it as `isPoller` on nodes, and `GET /nodes` takes `poller=true|false`. +An observer whose claim is foreign has the Poller tag marked Foreign (`isForeignPoller` in the API). A +repeater's telemetry is labelled as a foreign source when all of its readings came from foreign +observers, and as including foreign readings when some did. + An observer with the Poller tag also has a Poller view on its node, beside Node and Observer, in Beacon Web and the mobile app. It shows: - how many of its slots are used, split into its owner's repeaters and requested ones, and how many are free -- when Beacon last received its claim, and how often it polls each repeater when its firmware - reports that +- when Beacon last received its claim, how often it polls each repeater when its firmware reports + that, a Signed mark when the claim's signature checked out, and for a foreign observer the server + it follows - one row for each repeater: poller, standby or not assigned, the state it reports, its last reply - and SNR, and how many of the repeater's adverts Beacon heard through it + with SNR and RSSI, whether that reading was signed, and how many of the repeater's adverts Beacon + heard through it Anyone who can open the node sees this, including which repeaters are requested and a `login_failed` or `admin_stop` state. On the web the observer's dashboard shows the same, and an diff --git a/docs/telemetry-requests.md b/docs/telemetry-requests.md index 61dcbc9..e6b0038 100644 --- a/docs/telemetry-requests.md +++ b/docs/telemetry-requests.md @@ -175,6 +175,12 @@ current option became active and within the last 4 hours (the default; it is fou even while the blank login works, so a request that is still being polled stays `active`. With no such reading the report counts. +With `polling.foreign_claims: check`, a request for a repeater that a +[foreign observer](repeater-polling.md#foreign-observers) already checks asks the user to confirm +first, because it adds a second poll of that repeater. The same happens when a turned-off request +for such a repeater is turned back on. In the API this is `409 foreign_poller` and +`acknowledgeForeign`. + ## Guest passwords only A guest password is shared with the volunteer observer that polls the repeater, so it must never be diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index db0900c..27e421c 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -71,6 +71,10 @@ Beacon refuses to run with a setting it cannot honour. The message names the key | `invalid alerts configuration`, for example `alerts.push.id: required when alerts.push.enabled is true` | Fix the key the error names. See [Alerts](alerts.md#turn-them-on). | | `alerts.delivery has been replaced: set alerts.email.enabled and alerts.push.enabled instead` | Replace the old key with the two switches. | | `invalid secret key` | `BEACON_SECRET_KEY` is set but not usable. See [Turn it on](telemetry-requests.md#turn-it-on). | +| `DOMAIN: "..." is not a usable public address; use a plain host name`, or `DOMAIN: the public address must have no path, query, fragment or credentials` | With accounts on, `DOMAIN` (or `WEB_DOMAIN`) must be one host name, with an optional port. A Caddy address such as `:80`, or a list of hosts, does not work. | +| `DOMAIN: required when polling.foreign_claims is check`, or `polling.foreign_claims must be off or check` | Set `DOMAIN` in the server's environment, or fix the key. This is checked even with `polling.enabled: false`. | +| `invalid broker name`, with `MQTT_BROKER_1_NAME must be 1 to 64 characters of a-z, 0-9, underscore or hyphen` or `MQTT_BROKER_1_NAME and MQTT_BROKER_2_NAME must differ` | Fix the name in `.env`. | +| `MQTT_BROKER_1_REBROADCAST must be true or false` | Set it to `true` or `false`, or remove it. | ## No packets are arriving diff --git a/docs/upgrading.md b/docs/upgrading.md index 613b2f8..7733003 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -156,30 +156,34 @@ banned address could still reach the site over HTTP/3. ## Upgrading to 2.3.1 from 2.3.0 -**`accounts.public_url` is removed.** The server now takes its public address from the environment: -`https://` and `WEB_DOMAIN`, or `DOMAIN` when `WEB_DOMAIN` is not set. Check this before you upgrade +**`accounts.public_url` is removed.** The server now builds its public address from the environment: +`https://` plus `WEB_DOMAIN`, or plus `DOMAIN` when `WEB_DOMAIN` is not set. Check this before you upgrade if accounts are on: - **Docker stacks:** `DOMAIN` is already in `.env`, so nothing is needed when it is the host people open the web app at. On the split stack that host is `WEB_DOMAIN`, which the server host's `.env` also has. Delete `public_url` from `config.yaml` when you like; a leftover one is ignored and logs a warning at startup. -- **If your `public_url` was a different host** from `DOMAIN` (and `WEB_DOMAIN`), the links in - verification, reset and alert mail change to the `DOMAIN` host on upgrade. Set `WEB_DOMAIN` to +- **If your `public_url` named a host** that is neither `DOMAIN` nor `WEB_DOMAIN`, the links in + verification, reset and alert mail switch to the `DOMAIN` host on upgrade. Set `WEB_DOMAIN` to the old host to keep them. +- **`DOMAIN` must be one host name,** with an optional port. A scheme or a trailing slash is + dropped. If your `.env` has a Caddy address that is not a host (`:80`, or several hosts separated + by commas), startup stops with accounts on. Put the public host in `DOMAIN`. - **Running the server outside the stacks:** set `DOMAIN` in its environment. With accounts on and no `DOMAIN`, startup stops with `DOMAIN: required when accounts.mode is local`. - Local development on `localhost` or `127.0.0.1` still gets a plain `http` address: `DOMAIN=localhost:5173`. -Migrations `090` to `094` run at startup. `091` adds one column to `packets` and `092` one to +Migrations `090` to `094` run at startup. `090` adds two nullable columns to `polling_claims` +(`max_slots`, `poll_interval`). `091` adds one column to `packets` and `092` one to `repeater_readings`, both with a constant default, so neither rewrites its table; the rest of `092` is new, empty tables and three small columns on `polling_claims`. `093` builds a partial index on `repeater_readings` with `CONCURRENTLY`; it covers foreign readings only, so on an upgrade it is empty and builds at once. `094` adds two more columns to `repeater_readings`, again without a rewrite. -Three changes apply to every server, with no setting: +Four changes apply to every server, with no setting: - Packet detail lists the brokers a packet arrived through (`brokers`). Packets stored before the upgrade have an empty list. @@ -187,13 +191,17 @@ Three changes apply to every server, with no setting: days. A broker an observer stopped using drops off after that. - A polling claim or reading that carries a signature is checked, and dropped when the signature is wrong. Only current observer firmware signs. +- An observer's slot limit comes from its claim (`max_slots`, at most 32) and is 8 only when the + firmware reports none. An observer that reports more than 8 can be handed more requested repeaters. -Two new settings are off unless you set them: +Four new settings are off or at their default unless you set them: | Setting | What it is for | |---|---| | `MQTT_BROKER_n_REBROADCAST=true` in `.env` | A broker that forwards from other brokers and tags each message with its source. See [Behind a rebroadcaster](configuration.md#behind-a-rebroadcaster). | | `polling.foreign_claims: check` | Tell your own observers from ones that follow another server. See [Foreign observers](repeater-polling.md#foreign-observers). | +| `MQTT_BROKER_n_NAME` in `.env` | Name a broker connection something other than `mqtt1` or `mqtt2`. See [Configuration](configuration.md). | +| `mail.tls_skip_verify: true` | Send mail through a server whose certificate cannot be verified. See [User accounts](accounts.md#turn-them-on). | Web and mobile builds from before 2.3.1 keep working against a 2.3.1 server. The one exception is on a server with `foreign_claims: check`: asking for telemetry on a repeater a foreign observer already