Skip to content

Add an option to turn off the inbound WebSocket server - #238

Merged
kahrendt merged 2 commits into
Sendspin:mainfrom
balloobbot:outbound-only
Nov 4, 2026
Merged

kahrendt merged 2 commits into
Sendspin:mainfrom
balloobbot:outbound-only

Conversation

@balloobbot

Copy link
Copy Markdown
Contributor

Adds accept_inbound_connections to the client config. When off, the client runs no WebSocket server, and connect_to() is the only way a server reaches it. A client that dials one configured server, such as an Axis speaker app, then cannot be reached or paired by any other server on the network. The default is unchanged.

🤖 Generated with Claude Code

A client that dials one configured server with connect_to() must not
be reachable by any other server. accept_inbound_connections = false
skips the WebSocket server; connect_to() works as before. The default
keeps the server on.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Documentation still incorrectly describes server_max_connections as unused when inbound connections are disabled and promises startup listening without accounting for accept_inbound_connections.

2 open issues
What changed in this PR

Adds an outbound-only mode to SendspinClient, allowing applications to disable the inbound WebSocket server while continuing to connect through connect_to(). Existing behavior remains the default.

Changes:

  • Adds the default-enabled accept_inbound_connections configuration option.
  • Skips WebSocket server creation when the option is disabled.
  • Documents the option and adds lifecycle coverage for inbound listening and outbound dialing.
File Description
tests/​test_client_lifecycle.cpp Tests enabled and disabled inbound listening while verifying outbound dialing.
src/​connection_manager.cpp Makes WebSocket server creation conditional on the new option.
include/​sendspin/​config.h Defines and documents the default-enabled configuration field.
docs/​integration-guide.md Documents outbound-only usage and the configuration option.

Review effort: Balanced

Comment thread include/sendspin/config.h Resolved
Comment thread src/connection_manager.cpp Resolved
server_max_connections still sizes the protocol task's accept slots, so only
server_port is unused with accept_inbound_connections off. The start()
descriptions now say that no server starts in that case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@kahrendt kahrendt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@kahrendt
kahrendt enabled auto-merge (squash) November 4, 2026 14:49
@kahrendt
kahrendt merged commit 8692ba1 into Sendspin:main Nov 4, 2026
16 checks passed
kahrendt added a commit that referenced this pull request Nov 4, 2026
## Summary

From the second coherence pass on the allocation follow-ups
(Sendspin/backlog#92). The handshake logs peer text only up to 32 bytes,
but after it three sites a connection keyed with the published Sentinel
PSK reaches logged peer text at full length: up to 16 KiB per message,
enough to stall the protocol task on a UART console.
`determine_message_type()` also compared `type` as a `const char*`, so a
type with an embedded NUL (`"server/hello\u0000x"`) dispatched as the
known one. Separately, a present non-array `server/activate`
`active_roles` was silently taken as omitted, keeping the prior roles,
while its sibling `stream/*` `roles` rejects.

## Change

- **Log bound:** `PEER_TEXT_LOG_BYTES` (32) and `peer_text_for_log()` (a
UTF-8-safe cut) move from `noise_handshake.cpp` to `inline_text.h`. They
bound the unhandled message `type`, an unrecognized enum value from
`read_enum_field()` (server/activate's
`pairing.method`/`pairing.format`), and the `pair/abort` reason. Every
other peer string is bounded where it is parsed.
- **Message type:** `determine_message_type()` reads `type` once as a
`string_view` and compares with `==`.
- **active_roles:** a present non-array value logs and rejects the
activate, like `read_stream_roles()`; absent or null still keeps the
prior set. A rejected activate leaves a nursery connection to the 30 s
establish reap and an admitted one with its prior state.
- **Docs:** `conventions.md` says peer text no field bounds is logged
only up to the cap.
- **Test port:** the inbound-off lifecycle test moves off 19105, which
#238 and #241 both picked, so a parallel ctest run no longer fails one
of them.

## Tests

- `Protocol.DetermineMessageType` gains an embedded-NUL row; a `strcmp`
comparison fails it.
- `Protocol.ServerActivateReadsActiveRoles` gains null, string and
object rows; restoring the nullopt fallback fails the string and object
rows, dropping the null branch fails the null row.
- `Protocol.UnrecognizedPeerTextIsLoggedOnlyUpToTheBound` (pairing
method and pair/abort reason) and
`EncryptedLifecycle.AnUnhandledTypeIsLoggedOnlyUpToTheBound` capture
stderr and check 32 bytes are logged and 33 are not; dropping each cut
fails its test.

## Not in this PR

- A non-string entry in `activities`, `active_roles` or `stream/*`
`roles` is still skipped, so `active_roles:[7]` on a connection that is
not playback-capable passes the "MUST be empty" rule.
- Because the pairing index is bumped only after a successful parse, a
server that counts a parse-rejected pairing activate falls one index
ahead until the next handshake.
@kahrendt kahrendt added the enhancement New feature or request label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants