Commit Graph
16 Commits
Author SHA1 Message Date
efitenandClaude Opus 5.5 2c1905f077 fix(config): keep verifyAdverts through normalizeConfig
normalizeConfig (src/config.js) copied every feature flag except
verifyAdverts. processFrame reads the flag from the normalized config
(src/app.js:1333), so verifyAdverts:true in config.json never reached
heardKeyAfterVerify and 0-hop adverts with an invalid signature were
still accepted under their claimed pubkey.

The existing test only called featureEnabled on hand-built objects.
The new test goes through normalizeConfig: true when set, false when
absent or false.

Tests: node --test, 429/429 pass (run in the WSL sandbox with the
installed node_modules of 4a91f20; the worktree has no node_modules).
Not done: version bump and docs/releases entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NEgJ9U9V5WmHyRjL96MaDz
2026-10-23 00:26:21 +02:00
efitenandClaude Opus 5.5 52c95526a5 feat: choose the uplink ping scope from the repeaters around the companion (v1.22.0)
A fixed uplinkScope ("be") reaches almost nobody just over the border: of
the Limburg border repeaters in CoreScope's node_declared_regions, many in NL
declare only *, nl or nl-li. uplinkScope is now a preference list
("de,nl,be"). Per ping, src/autoscope.js counts how many of the repeaters
heard directly in the last 5 minutes forward each candidate (the companion's
default scope first, then the list) and takes the most forwarded. With none
forwarded but *, the ping goes out un-scoped (fw v12+); with nothing known,
in the companion's default scope (CMD_GET_DEFAULT_FLOOD_SCOPE, fw v10+).

Declared regions come from CoreScope GET /api/nodes/declared-regions
(uplinkRegionsUrl, default corescopeUrl + that path, every 30 min) merged
with this session's own region answers. The MQTT payload is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 21:28:16 +02:00
efitenandClaude Opus 5.5 70a59c6197 feat: uplink ping, test whether the mesh hears the companion
CoreDrive only measured what the companion hears. With uplinkPing on (off by
default), it sends a short message on a dedicated hashtag channel
(#coredrive) carrying only a random tag, listens 10 s for a repeater
re-broadcasting it, and publishes the result on the new topic
meshcore/client/{pk}/uplink (UPLINK_PING): tag, packet hash of the echo,
every echo with its first and last hop, and the GPS fix. The position never
goes over the mesh.

- src/grptxt.js: hashtag channel key, channel hash, GRP_TXT MAC check and
  AES-128-ECB decrypt, and the packet hash, per the firmware
  (Mesh.cpp:540-557, Utils.cpp:127-145, Packet.cpp:41-50). Checked against a
  real #wardriving packet from CoreScope live: same text and same hash
  (12c82f82df4cc29c). AES-ECB comes from @noble/ciphers 2.0.1, as WebCrypto
  has no ECB.
- src/uplinkping.js: channel message, get/set channel and flood-scope frames
  (companion_radio/MyMesh.cpp), slot choice that never overwrites another
  channel, echo matching on the tag.
- src/uplinksched.js: a ping only with a fix of 100 m or better, after
  uplinkIntervalSec (60) and uplinkMinMoveM (250), under uplinkMaxPerHour (50),
  and not in a ~180 m cell pinged in the last uplinkSkipDays (7).
- uplinkScope (e.g. "be") sends the ping as a region-scoped flood via
  CMD_SET_FLOOD_SCOPE (fw v8+) and resets the override right after.
- app.js holds the radio (acquireRadio) for the whole exchange, as OK/ERR
  replies carry no correlator; it skips while parked, signing or asking.
- DEVICE_INFO now yields the channel slot count; log header gets a ping row.

Tests: 417 pass (+20): crypto against the real packet, frames, slot choice,
echo matching, scheduler, config defaults, payload shape, header row. Not
tested on air: no ping has been sent from a real companion yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:52:02 +02:00
efitenandClaude Opus 5.5 5da69305b8 feat: ask a repeater without a CoreScope name for its own name
Field case 2026-10-16: c0cdee59e0db981b answered every discover sweep,
but CoreScope has never seen its advert, so it stayed a bare prefix and
got no regions ask either.

- nodeNames flag (on when config.json exists and omits it, off without
  a config, like regionDiscovery). With it on, discover requests drop
  DISCOVER_PREFIX_ONLY, so replies carry the full 32-byte pubkey
  (+24 bytes each, simple_repeater/MyMesh.cpp:824).
- A repeater heard in range is looked up once per session. Only when
  CoreScope answers without a name is it asked ANON_REQ_TYPE_OWNER
  (MyMesh.cpp:165). The reply is "name\nowner_info"; owner_info is
  dropped.
- Name and regions asks share one queue and one per-encounter budget
  (src/asknext.js): the companion keeps one pending anon request
  (companion_radio/MyMesh.cpp:1570) and the repeater limiter is shared
  across request types. The name is asked first.
- The name replaces the prefix in the recent list and regions card, and
  is published on meshcore/client/{pk}/names as NODE_NAME with the
  companion's fix. New topic; /packets is unchanged.
- Debug header: a names row and nodeNames in the config row.

Not done: CoreScope does not ingest /names yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 09:25:48 +02:00
efitenandClaude Opus 5.5 11ca093dd9 feat(names): resolve an ambiguous path hash to its one forwarder
A 2-byte path hash that CoreScope calls ambiguous stayed a bare prefix,
even when the only other match cannot forward. Field case 2026-10-16:
e470 matched BE-HSS-HVZZWL-DIS (repeater) and Aegis (companion), so the
repeater got no name and no regions ask.

Companions and sensors do not forward by default
(companion_radio/MyMesh.cpp:486), so for keys of 4 bytes or fewer the
candidates are fetched from the new optional searchUrl
(/api/nodes/search) and narrowed to repeater/room. Exactly one left:
that is the node. A full search page (10 rows) decides nothing, because
it may have cut off a second forwarder.

Not covered: a companion with client-repeat turned on is ignored here.
Resolve and pubkey lookups now share one session cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 09:25:34 +02:00
efitenandClaude Opus 5.5 cea751fa7c feat(config): optional corescopeUrl, normalized to an origin
Falls back to the origin of resolveUrl; both empty turns the account
feature off. Runtime config only, nothing hardcoded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 10:52:35 +02:00
efitenandClaude Opus 5 9a8614396b fix: the per-encounter allowance was 3, not the 4 v1.16.0 announced
Two files held a default for the same limit. src/regionsched.js set DEFAULT_MAX_ASKS = 4
and only the tests read it; src/config.js carried its own 3, and the app reads the
config. So the raise from 3 to 4 shipped in the release notes and not in the app. Nothing
failed and no test could see it — the only evidence was a field log line reading
"attempt 3 of 3 this encounter".

Fixed at the cause rather than by correcting the number: config.js now imports all five
pacing defaults from the scheduler, so there is one number per limit. A test asserts the
config's defaults ARE the scheduler's, which is the assertion that was missing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-13 02:05:03 +02:00
efitenandClaude Opus 5 d2e2573375 feat: verify advert signatures before an identity reaches CoreScope (closes #11)
An Advert's Ed25519 signature is the only cryptographic proof of identity MeshCore
offers. Everything else is plaintext and attacker-chosen: pubkey, name and self-reported
position are whatever the sender wrote, and hop counts, paths and prefixes carry no MAC.
The capture rule in this repo covers provenance, not authenticity, so a 0-hop advert can
be genuinely heard direct and still name a node that does not exist. Adverts captured
here are published to CoreScope, the registry the name resolvers read from, so one
forgery heard by one driver becomes a named node on someone else's screen.

parsePacket now returns advertSig: the pubkey, the signature and the exact message the
firmware signs, which is pubkey(32) || timestamp(4, LE) || app_data with app_data
truncated to MAX_ADVERT_DATA_SIZE (meshcore-firmware src/Mesh.cpp:271-280 verifies what
:404-437 signed, cap at src/MeshCore.h:12). The timestamp goes in as the raw wire bytes,
not the parsed advertTs, so no re-encoding can disagree with what was received. Getting
the 32-byte cap wrong would make every long advert look forged, so the fixture test
covers it, and the real captured advert already in the fixtures verifies against its own
signature, which is what proves the construction rather than asserting it.

src/advertsig.js does the crypto and nothing else. Verification is async: @noble/ed25519
needs a hash and only the async path has one without extra wiring. The capture handler
was already async. A forged advert can carry a pubkey or signature that is not a valid
curve point, which noble rejects by throwing, so that is caught and read as a failed
verification rather than taking the capture path down.

A failed check drops the identity and keeps the reception. The SNR and RSSI measured at
that position are real whoever wrote the advert; only the name attached to them is
worthless, and discarding the row would lose genuine coverage. This is deliberately
narrower than core-hunter, which refuses the whole reception (efiten/core-hunter#356),
because that repo is about identity and this one is about coverage. As a side effect the
node stops being a region-discovery candidate, so the app never sends an anonymous
request to an address somebody invented.

verifyAdverts is off unless config.json says otherwise, and is listed false in
FEATURE_DEFAULTS as well as NO_CONFIG_DEFAULTS. It is the only flag that makes the app
record less than it heard, and inheriting that silently would look like adverts going
missing. The exported log header reports it next to the other three, because "no advert
in the capture" and "advert rejected" are otherwise the same silence.

Not done: no Settings UI for the flag, config.json only, matching the other three. The
gate is not exercised against a forged advert on real hardware, only against fixtures
and a signed synthetic advert.

New dependency: @noble/ed25519 3.2.0. Bundle 435.17 kB -> 442.78 kB (gzip 136.22 ->
139.71).

Tests: 255 pass (+16). SW cache v39 -> v40.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Manrn3qdrTJFz3C4o9PPFL
2026-09-09 17:55:29 +02:00
Erwin FitenandClaude Opus 5 8d6254f8ce feat(config): regionDiscovery defaults ON in an existing config, OFF with none
Completes the default-on change. The transmitting feature's default now depends on
WHERE the silence comes from, which is the distinction that makes it safe:

- an absent key in a config.json that EXISTS -> on. That file is a deployment whose
  operator owns the repeaters being asked, and this is exactly the case that bit us:
  a config predating the key silently reported the feature off.
- no config loaded at all -> off. The app then knows nothing about whose mesh it is
  on, and repeaters rate-limit anonymous requests to 4 per 180s shared across every
  requester and type, so one client asking once a minute claims most of that budget.
  Collecting on an assumption spends our own bandwidth; transmitting on one spends a
  stranger's airtime.

FEATURE_DEFAULTS / NO_CONFIG_DEFAULTS make that split explicit, and every
regionDiscovery gate in app.js now goes through featureEnabled() so "which default
applies" has exactly one answer, in config.js. Those gates read
`!cfg || !cfg.regionDiscovery`, which happened to be equivalent for a normalized
config but restated the policy in five places.

Tests: 220 pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 09:53:19 +02:00
Erwin FitenandClaude Opus 5 89565ff1f9 feat(config): the two logging flags default ON; collect even with no config
Goal: never lose a window of coverage data to a config problem. Data that was
never collected is gone for good; data collected and discarded server-side costs
only bandwidth.

Two separate changes, because they cover two different failures:

- normalizeConfig: an ABSENT fullRfLog/rfSampler key now means on. A config.json
  written before those keys existed reported both off while the served file said
  on - indistinguishable from the features being broken. An explicit `false`
  still wins.
- featureEnabled(cfg, name): resolves a flag when there is NO config at all. Every
  gate read `!cfg || !cfg.X`, i.e. "we do not know yet" == "off", so a failed
  config fetch stopped data collection on top of stopping uploads. The app now
  keeps capturing on defaults and the queue publishes once config arrives.

regionDiscovery deliberately still defaults to false. It is the only feature that
transmits, against third-party repeaters that rate-limit anonymous requests to 4
per 180s shared across every requester and type - one client asking once a minute
already claims most of that budget. Spending someone else's airtime on an
assumption is not a default.

The exported log header now names the defaults in force when no config loaded, so
a reader can tell what is in the queued records without guessing.

Documented in the README together with the two standing warnings that make this a
real trade: fullRfLog multiplies upload volume and is discarded unless the
ingestor has clientRxObservations.enabled, and an rfSampler publish denied by the
broker ACL is still PUBACKed, so it looks healthy while the server stores nothing.
config.example.json updated to match the new defaults.

Tests: 220 pass (+3).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 09:49:51 +02:00
Erwin FitenandClaude Opus 5 229bbf656c fix: a failed config fetch no longer silently disables the whole session
Two field logs traced to one root cause: config.json is fetched exactly once at
DOMContentLoaded and never retried, so a single transient failure at startup left
getConfig() returning null (or a stale cached copy) for the rest of the session.

Log A: no config at all. connectAll took its else branch, never built a Publisher,
and then reported "All connected - capturing" anyway. An hour of receptions queued
and nothing published. The Push button answered "nothing pending / not connected"
because drain() returns 0 for a null publisher exactly as it does for an empty
queue - and its reconnect branch was guarded on `publisher && !connected()`, which
skipped the one case needing recovery. The only message naming the cause went to
els('status'), which the next connect cleared with log('').

Log B: a config.json cached before rfSampler/regionDiscovery existed. Absent flags
normalize to false, so both features were dead while the served config said on -
publishing worked, everything looked green, and nothing reported it. A stale config
is worse than none: none is detectable, stale is not.

- sw.js: config.json bypasses the cache in both directions, and the
  caches.match('/') fallback is limited to navigations. Serving index.html for a
  JSON request is what turned an offline start into "invalid JSON: Unexpected
  token '<'".
- config.js: loadConfig dedupes concurrent attempts, caches only on success so a
  retry actually re-fetches, and names an HTML body instead of leaking a parse error.
- uplink.js (new, pure): uplinkState / uplinkWarning / pushOutcome /
  regionInertReason / buildLogHeader.
- app.js: retries the config on every connect, on `online`, and once a minute while
  missing; startPublisher() split out so a late config brings uploading up without
  reconnecting; a red Home banner while receptions are buffered but not uploaded;
  the progress list no longer claims an uplink it does not have; pushNow reports
  queue depth independently of link health and picks the matching repair.
- Region discovery names which of its four gates is holding it, once, in the log -
  "no regions lines" was consistent with all four and distinguished none. Its
  re-entry throttle is now stamped before the gates instead of after.
- Every exported log carries a header with app version, EFFECTIVE config flags,
  firmware version, region-discovery status, uplink state and queue depth. Both
  field logs arrived unattributable to a version; the header is built at share time
  so it cannot roll out of the 200-line ring buffer the way a startup line does.

Tests: 217 pass (+41). sw.js is driven in a node:vm ServiceWorkerGlobalScope so the
shipped file is tested, not a copy of its logic.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 09:45:09 +02:00
efitenandClaude Opus 5 d16e55de97 feat: round-robin region discovery on the discover clock
Ask exactly one repeater per region-discovery round (half the 30s discover
cadence, so once a minute) for its declared flood-allowed region list, and
compare it later against what CoreScope observes it actually forward.

- src/regionreq.js: selectNextTarget(state) -> pubkey|null, pure round-robin
  selection with demotion for non-answerers (never dropped, since silence is
  ambiguous: out of range, rate-limited, old firmware, or busy).
- src/meshpacket.js: parsePacket now also returns advertTs (the node's own
  re-advert clock, so a repeater is re-asked only after a config edit) and
  advertType (ADV_TYPE_*, so only ADV_TYPE_REPEATER nodes are ever asked --
  only simple_repeater firmware implements the reply).
- src/app.js: wiring only. Candidates are 0-hop adverts (full pubkey, direct
  RF range) from repeaters; maybeQueryRegions() rides the discover clock at
  half rate and sends at most one buildRegionsRequest per round, logged at
  the tx (orange) level; onRegionsFrame is a dedicated listener fed the RAW
  notification (never parseFrame(...).data, which strips the code byte and
  would silently break parseRegionsResponse's bytes[0] check).
- Feature gate: FIRMWARE_VER_CODE >= 13 (CMD_SEND_ANON_REQ's non-contact
  allowance), read via the existing requestDeviceInfo() call at connect;
  when regionDiscovery is configured on but the firmware is too old, the
  feature stays off and Settings shows why.
- config.regionDiscovery defaults to false (config.js, config.example.json).
- index.html: regionsInfo status line in Settings/Diagnostics.
- sw.js: cache buster v18 -> v19 (frontend files changed).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 15:11:02 +02:00
efiten 156757a853 feat: RF environment sampler with moving/parked cadence 2026-08-18 11:05:54 +02:00
efitenandClaude Opus 5 9339b66e6f feat: optional full RF logging of unattributable receptions (v1.5.0)
Adds fullRfLog (default off) so a sysop can opt in to queuing receptions
the capture path cannot attribute to a node — DIRECT routes, 1-byte path
hashes, etc — as a diagnostic RF observation stream. The decision lives
in a new pure src/capture.js so it stays testable without a DOM; an
unattributable reception moves no coverage state (counters, SNR meter,
recently-heard, beeper, map hexes untouched). MQTT payload shape and
Publisher.buildPayload are unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 10:17:27 +02:00
efiten 6e80334dc6 fix(config): cache loadConfig, guard array input, test mqttPassword normalization 2026-06-13 21:07:54 +02:00
efiten 2bd69ab30f feat(config): runtime config.json loader + validation 2026-06-13 21:00:16 +02:00