Repository navigation
Define group_id as a 43-character base64url value - #340
Conversation
|
|
# Conflicts: # README.md # messaging.md
|
@copilot resolve the merge conflicts in this pull request |
The merge conflicts are already resolved in merge commit
Thanks for clarifying. I did not change the format based on this comment because it doesn’t explicitly ask @copilot to act.
The merge conflicts are already resolved in merge commit
The merge conflicts are already resolved in merge commit
Correction: the merge conflicts are already resolved in merge commit
I’ve confirmed the existing merge is complete; no additional changes were necessary. |
|
Well copilot was worthless there, jeez |
# Conflicts: # README.md # messaging.md
maximmaxim345
left a comment
There was a problem hiding this comment.
LGTM, I think the base64url format is good, being limited to (url) safe characters is also nice.
…p_id (#256) ## Summary `group/update` still copied `group_id` and `group_name` onto the heap through `operator new`, which aborts on ESPHome. Both fields are now held inline from the parse to the main loop, and the public strings are filled in place, so a `group/update` allocates nothing. Part of Sendspin/backlog#92. The change also adopts Sendspin/spec#340: `group_id` must be 43 base64url characters, and anything else is a protocol error that closes the connection. Servers in use today, aiosendspin among them, still send 36-character UUIDs, so enforcement is staged. `GROUP_ID_STRICT` (in `protocol.cpp`) stays `false` for now. **Behaviour change:** a non-conforming `group_id` now reaches consumers as `base64url(SHA-256(id))` instead of as sent, with one warning per connection. Setting the flag to `true` makes a `group/update` whose `group_id` is absent or not in that format close the connection. ## Change - **Parse:** the protocol task decodes the fields into a private, trivially copyable `GroupUpdatePayload` (`IdText`, `ServerName`) carried through the inbox slot. `group_id_from_wire()` handles every case: kept, normalized, rejected, ignored, and null or non-string values. - **Main loop:** `GroupUpdateObject`'s `std::optional<std::string>` fields, in both the group state and the delta `on_group_update()` receives, are filled through `ReservedText` (`src/reserved_text.h`). It keeps a string reserved for the field's bound when the client is built and swaps it in and out rather than freeing it on a clear. The metadata role can reuse it once metadata strings have a spec cap. - **Normalization:** hashing a non-conforming id costs one noise-c `calloc` per normalized id (noted in internals.md "Memory"). When that allocation fails, the connection is closed rather than applying the rest of the update under the previous group's id. ## Tests - `Protocol.GroupIdIsKeptNormalizedOrRejected`: a table covering lenient and strict outcomes, with hashes checked against openssl. Rows: a conforming control, a UUID, 44 characters, a standard-alphabet `+`, empty, null, a number, absent. - `EncryptedLifecycle.GroupIdReachesTheListenerAsSentOrNormalized`: an end-to-end check of what the listener's delta and the group state show. - Gap: the close on a failed normalization cannot be driven without a production seam (noise-c's `calloc` inside a local `Sha256`). - New alloc window for the first `group/update` messages (normalize, clear the name, set a new name), expected 0. `RestartYieldsALiveClient` now checks that the group fields clear. - Follow-ups when the flag flips: an end-to-end strict-close test, closing on an over-long `group_name` per Sendspin/spec#347, and whether an absent `playback_state` or `group_name` closes it too. Stack (ESP-IDF 5.5.4, esp32): every task matches `tools/stack_usage/README.md`, the protocol task at 6,544 B -Os / 6,688 B -Og against its 7,168 B default.
# What does this implement/fix? <!-- Quick description and explanation of changes. --> The server sent `group_id` as a UUID, but the spec now requires 32 random bytes in base64url (43 characters). Clients that follow the spec close the connection on any other value, so they disconnect from aiosendspin servers on the first `group/update`. **Related issue or spec PR (if applicable):** - Sendspin/spec#340 ## Types of changes <!-- Tick exactly one box. CI (.github/workflows/pr-labels.yaml) applies the matching label, and the release notes use it to sort this change. --> - [x] Bugfix (non-breaking change which fixes an issue): `bugfix` - [ ] New feature (non-breaking change which adds functionality): `new-feature` - [ ] Enhancement to an existing feature: `enhancement` - [ ] Breaking change (changes the public API or the protocol in a way that is not backwards compatible): `breaking-change` - [ ] Refactor (no behavior change): `refactor` - [ ] Documentation only: `documentation` - [ ] Maintenance / chore: `maintenance` - [ ] CI / workflow change: `ci` - [ ] Dependencies bump: `dependencies`
# What does this implement/fix? <!-- Quick description and explanation of changes. --> The client now closes the connection when a `group/update` carries a `group_id` that isn't 43 base64url characters, as the spec requires. This breaks connecting to servers on an older aiosendspin until they update, since those still send a UUID. Requires #622 **Related issue or spec PR (if applicable):** - Sendspin/spec#340 ## Types of changes <!-- Tick exactly one box. CI (.github/workflows/pr-labels.yaml) applies the matching label, and the release notes use it to sort this change. --> - [ ] Bugfix (non-breaking change which fixes an issue): `bugfix` - [ ] New feature (non-breaking change which adds functionality): `new-feature` - [ ] Enhancement to an existing feature: `enhancement` - [x] Breaking change (changes the public API or the protocol in a way that is not backwards compatible): `breaking-change` - [ ] Refactor (no behavior change): `refactor` - [ ] Documentation only: `documentation` - [ ] Maintenance / chore: `maintenance` - [ ] CI / workflow change: `ci` - [ ] Dependencies bump: `dependencies`
group_idingroup/updateis a string of any length and content. The client keeps it to tell when its group changes, so the server decides how much the client has to store.This gives it the same format as the spec's other identifiers (
client_id,server_id,psk_id): 32 bytes, base64url-encoded without padding, 43 characters. A client can hold it in fixed storage, and since the value is ASCII, bytes and characters are the same count. The server chooses the 32 bytes. A server with existing IDs, such as UUIDs or database keys, can use a SHA-256 hash of its own ID, which stays the same for the life of the group.A value in any other format can only come from a server bug, so it is a protocol error and the client MUST close the connection, as it does for other out-of-range values (#347). That rule covers only the length, so
group_idstates its own rule to also cover a 43-character value with characters outside base64url, which could take more than 43 bytes.Breaking changes
Servers: must send
group_idas 32 bytes, base64url-encoded without padding. A server that sends another format, like a UUID, will have updated clients close the connection.Clients: must close the connection on a
group_idthat is not 43 base64url characters. A client that doesn't check keeps working with any server that follows the spec.I accept the Contributor License Agreement for this contribution.