Skip to content

Commit

Permalink
use canonicalize_url consistently on relay url ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
ksedgwic committed Oct 26, 2024
1 parent 3abf36a commit 67b5e1a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,20 @@ impl Damus {
"wss://nostr.wine",
"wss://purplepag.es",
];
pool.bootstrapping_relays = bootstrapping_urls.iter().map(|&s| s.to_string()).collect();
let forced_urls = parsed_args.relays.into_iter().collect::<BTreeSet<_>>(); // normally empty
pool.forced_relays = forced_urls;
// the user tracker will call configure_relays after filling in advertised
pool.bootstrapping_relays = bootstrapping_urls
.iter()
.map(|&s| s.to_string())
.map(|s| RelayPool::canonicalize_url(&s))
.collect();
// normally empty
pool.forced_relays = parsed_args
.relays
.into_iter()
.map(|s| RelayPool::canonicalize_url(&s))
.collect::<BTreeSet<_>>();
// avoid relay thrash, don't call configure_relays here
// because the initial advertised set will be registered
// shortly and it will be called then

let account = accounts
.get_selected_account()
Expand Down
5 changes: 4 additions & 1 deletion src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ fn set_advertised_relays(pool: &mut RelayPool, relays: Vec<String>) {
let wakeup = move || {
// FIXME - how do we repaint?
};
pool.advertised_relays = relays.into_iter().collect();
pool.advertised_relays = relays
.into_iter()
.map(|s| RelayPool::canonicalize_url(&s))
.collect();
if let Err(e) = pool.configure_relays(wakeup) {
error!("{:?}", e)
}
Expand Down

0 comments on commit 67b5e1a

Please sign in to comment.