File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,15 @@ use anyhow::{anyhow, Result};
44
55use super :: Config ;
66
7+ /// Manages OHTTP relay selection with privacy and resilience in mind.
8+ ///
9+ /// Relays are selected randomly from the configured list to avoid creating
10+ /// a fingerprintable pattern at the network layer. Even though OHTTP protects
11+ /// the user's IP address, always contacting the same relay in the same order
12+ /// reveals metadata about the client's behavior.
13+ ///
14+ /// Failed relays are tracked and excluded from future selections until
15+ /// the session is reset, providing resilience without sacrificing privacy.
716#[ derive( Debug , Clone ) ]
817pub struct RelayManager {
918 selected_relay : Option < url:: Url > ,
@@ -46,6 +55,10 @@ pub(crate) async fn unwrap_ohttp_keys_or_else_fetch(
4655 }
4756}
4857
58+ /// Fetches OHTTP keys using a randomly selected relay from the configured list.
59+ ///
60+ /// Random relay selection prevents network-layer fingerprinting. See [`RelayManager`]
61+ /// for details on the selection and failure-tracking strategy.
4962async fn fetch_ohttp_keys (
5063 config : & Config ,
5164 directory : Option < url:: Url > ,
Original file line number Diff line number Diff line change @@ -13,6 +13,12 @@ use crate::OhttpKeys;
1313/// directory. Proxying requests for ohttp keys ensures a client IP address is never revealed to
1414/// the payjoin directory.
1515///
16+ /// When multiple relays are available, callers SHOULD select one at random rather than
17+ /// always using the same relay. A fixed selection order creates a fingerprintable pattern
18+ /// at the network layer even though the IP is protected by OHTTP.
19+ /// See `payjoin-cli`'s `RelayManager` for a reference implementation that combines
20+ /// random selection with failed-relay tracking for resilience.
21+ ///
1622/// * `payjoin_directory`: The payjoin directory from which to fetch the ohttp keys. This
1723/// directory stores and forwards payjoin client payloads.
1824pub async fn fetch_ohttp_keys (
You can’t perform that action at this time.
0 commit comments