Skip to content

enostr: enable TLS for the tokio websocket backend#1492

Merged
jb55 merged 2 commits into
damus-io:masterfrom
asoltys:fix/websocket-tls
Jun 28, 2026
Merged

enostr: enable TLS for the tokio websocket backend#1492
jb55 merged 2 commits into
damus-io:masterfrom
asoltys:fix/websocket-tls

Conversation

@asoltys

@asoltys asoltys commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Problem

After switching enostr's default to ewebsock's tokio websocket backend (commit c726f46, "chore(deps): pin negentropy transport prerequisites"), all wss:// relay connections fail:

ERROR enostr::relay::coordinator: relay wss://relay.damus.io/ error: "URL error: TLS support not compiled in"

ewebsock's tls feature only enables TLS for its blocking tungstenite backend (tungstenite/rustls-tls-webpki-roots). The tokio backend connects via tokio-tungstenite, and no crate in the workspace enables a TLS feature on it — so the tokio path has no TLS connector and every secure relay is rejected at connect time. (NIP-11 metadata fetches still work because they use a separate HTTP client, which can mask the issue.)

Fix

Enable tokio-tungstenite's rustls-tls-webpki-roots feature as part of the tokio-websocket feature. This matches the rustls + webpki-roots stack ewebsock already pulls in for its blocking backend, so no additional TLS stack is introduced. ewebsock pins tokio-tungstenite to 0.24 (same as the workspace), so Cargo feature unification applies the TLS connector to ewebsock's tokio backend.

Verification

Before: every wss:// relay → "TLS support not compiled in", blank timelines.
After: TLS errors gone, relays connect (e.g. nos.lol, relay.coinos.io, relay.primal.net). Remaining failures are purely relay-side (nostr.wine 403 paid-relay auth, transient 502/503s).

Note

Also includes a small unrelated build fix: columns: fix ambiguous float type in repost iconlet h = 32.0; was ambiguous and broke .max() on newer rustc (E0689 via the float_literal_f32_fallback future-compat change). Happy to split this into its own PR if preferred.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved TLS support for websocket connections, helping secure connections work more reliably in the Tokio backend.
    • Added a small rendering type fix in the repost UI to keep drawing behavior consistent.

asoltys and others added 2 commits June 27, 2026 22:52
Switching enostr's default to ewebsock's tokio backend (commit c726f46)
left wss:// relay connections broken: ewebsock's `tls` feature only wires
TLS into its *blocking* tungstenite backend, while the tokio backend
connects via tokio-tungstenite, which had no TLS feature enabled. Every
secure relay therefore failed with:

    relay wss://... error: "URL error: TLS support not compiled in"

Enable tokio-tungstenite's `rustls-tls-webpki-roots` feature as part of
`tokio-websocket` (matching the rustls + webpki-roots stack ewebsock
already uses for its blocking backend, so no new TLS stack is added).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`let h = 32.0;` left the type ambiguous, so `.max()` on a value derived
from it failed to compile on newer rustc (E0689, via the
float_literal_f32_fallback future-compat change). Annotate `h` as f32
(egui geometry is all f32) to resolve it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The tokio-websocket feature in enostr now enables tokio-tungstenite/rustls-tls-webpki-roots, with tokio-tungstenite added as an optional workspace dependency. A separate one-line fix changes the h constant in quote_icon from 32.0 to 32.0_f32.

Misc Fixes

Layer / File(s) Summary
tokio-websocket TLS wiring
crates/enostr/Cargo.toml
tokio-tungstenite added as optional workspace dependency; tokio-websocket feature extended to enable tokio-tungstenite/rustls-tls-webpki-roots with clarifying comments.
f32 literal type fix
crates/notedeck_columns/src/ui/repost.rs
Scaling constant h in quote_icon changed to explicit 32.0_f32.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 A feature flag here, a type tweak there,
TLS for tokio, secured with care,
rustls roots now bundled in tight,
And 32.0_f32 typed just right.
Hop along, the build should compile bright! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: enabling TLS for the tokio websocket backend in enostr.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crates/notedeck_columns/src/ui/repost.rs (1)

118-120: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add rustdoc for quote_icon.

This function was modified in this PR, but it still has no doc comment. As per coding guidelines, "Ensure docstring coverage for any code added or modified".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/notedeck_columns/src/ui/repost.rs` around lines 118 - 120, Add a
rustdoc comment for the quote_icon function in quote_icon so the modified public
API is documented per coverage guidelines. Keep the doc comment brief and
descriptive, explaining that it returns the widget used for the quote icon, and
place it directly above quote_icon so it stays attached to the function even if
the implementation changes.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/notedeck_columns/src/ui/repost.rs`:
- Around line 118-120: Add a rustdoc comment for the quote_icon function in
quote_icon so the modified public API is documented per coverage guidelines.
Keep the doc comment brief and descriptive, explaining that it returns the
widget used for the quote icon, and place it directly above quote_icon so it
stays attached to the function even if the implementation changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 73eec11a-9b40-4ade-a039-23549583aa0a

📥 Commits

Reviewing files that changed from the base of the PR and between 9c4db6e and e7e4819.

📒 Files selected for processing (2)
  • crates/enostr/Cargo.toml
  • crates/notedeck_columns/src/ui/repost.rs

@jb55
jb55 merged commit e7e4819 into damus-io:master Jun 28, 2026
5 of 8 checks passed
@jb55

jb55 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants