Enforce the relay scheme policy in the Rust relay pool, not only in the add-relay dialog
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- networking, security
Research direction
Start in rust/src/api/nostr.rs, where initialize_in, add_relay and apply_relay_list_event reach RelayPool::sync_discovered, and read _validateRelayUrl in lib/features/settings/screens/relays_screen.dart to see the current Dart-only check. The issue asks for one scheme policy in the Rust pool, applied at all three entry points, with persisted ws:// rows deactivated rather than deleted. Done means a release-mode cargo test case shows a ws:// relay is neither connected nor added, while debug and Mortsom behaviour is unchanged.
Written by the indexing model from the issue text.
Description
Problem
The wss:// requirement for relays is enforced only by the add-relay dialog in Dart (_validateRelayUrl in lib/features/settings/screens/relays_screen.dart). The Rust relay pool never checks the scheme:
initialize_in(rust/src/api/nostr.rs) reconnects every persisted active URL.add_relaypersists whatever URL it is given.apply_relay_list_event→RelayPool::sync_discoveredauto-adds whatever a Mostro node announces in its kind 10002 list.
So a release build connects over plaintext ws:// to any relay a node announces, and keeps any ws:// row already in its database. #833 makes the dialog accept ws:// in debug builds, which adds one more way for such a row to exist (a release build reusing a debug build's data directory on the same machine), but the gap predates it. Raised by Codex on #833: https://github.com/MostroP2P/app/pull/833#discussion_r4295512614
Per AGENTS.md, Rust owns relays, so the policy belongs in the pool, not in a dialog.
Proposal
- Define the scheme policy once in the Rust core: which schemes a build accepts. Release and profile builds accept
wss://only; debug builds (cfg(debug_assertions)) and the Mortsom test environment acceptws://as well. - Pass the test-environment allowance down from Dart at
initialize(the Mortsom entry point is the only one that can grant it), so a Mortsom release build keeps itsws://relays fromMORTSOM_RELAYS. - Apply the policy at every entry point:
initialize_in(persisted rows and seeds),add_relay, andsync_discovered(announced relays). A rejected announced relay is logged, not blacklisted, so a node that later announces it overwss://is still picked up. - Rows that no longer qualify on load: deactivate them rather than delete them, and log it, so a developer switching back to a debug build gets them back.
- The dialog keeps its early check for the error message, but the Rust result is what decides.
Acceptance
- A release build with a persisted
ws://row does not connect to it and marks the row inactive. - A release build whose node announces a
ws://relay in its kind 10002 does not add it. - A debug build and a Mortsom build behave as today.
- Tests at the pool level for the three entry points, and a
cfg(debug_assertions)-independent seam so the release case is testable undercargo test.
- Dominant language
- Dart
- Stars
- 11
- Forks
- 9
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 16
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MostroP2P/app
-
documentation priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 73/100
Maintainers usually reply within 1 day
-
area: ui bug priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
area: ui bug priority: high
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Bug: Button "Share logs" does nothingPossibly taken @Luquitasjeffrey claimed this 7 days ago. Open
Difficulty 2/5 Half a day Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
area: rust-core bug priority: low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
Similar issues
-
Python example: list a model's scenes and their camerasPossibly taken @rudraparmar76 claimed this today. Opendocumentation good first issue python
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
iamahsanmehmood/openskp#796 · 1 comment ·
Maintainers usually reply within 1 day
-
needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Plural rendering: first matching part wins, but gen-l10n lets the last one win (=1 shadows one)Openbug help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
crowdin/flutter-sdk#97 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
MrSpideyNihal/lockfeed#16 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
InlitX/GymMane#529 · 1 comment ·
Maintainers usually reply within 1 day