Enforce the relay scheme policy in the Rust relay pool, not only in the add-relay dialog

Aperta
#834 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
dart, rust

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area: relays area: rust-core enhancement

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_relay persists whatever URL it is given.
  • apply_relay_list_event → RelayPool::sync_discovered auto-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

  1. 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 accept ws:// as well.
  2. 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 its ws:// relays from MORTSOM_RELAYS.
  3. Apply the policy at every entry point: initialize_in (persisted rows and seeds), add_relay, and sync_discovered (announced relays). A rejected announced relay is logged, not blacklisted, so a node that later announces it over wss:// is still picked up.
  4. 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.
  5. 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 under cargo test.
Lingua principale
Dart
Stelle
11
Fork
9
Merge medio
2g 1h
PR unite (30g)
16

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MostroP2P/app

Tutte le issue di MostroP2P/app

Issue simili

Altre issue su Dart

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.