Skip to content

Commit 86e6a08

Browse files
committed
use canonicalize_url consistently on relay url ingress
1 parent e625e33 commit 86e6a08

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/app.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -696,10 +696,20 @@ impl Damus {
696696
"wss://nostr.wine",
697697
"wss://purplepag.es",
698698
];
699-
pool.bootstrapping_relays = bootstrapping_urls.iter().map(|&s| s.to_string()).collect();
700-
let forced_urls = parsed_args.relays.into_iter().collect::<BTreeSet<_>>(); // normally empty
701-
pool.forced_relays = forced_urls;
702-
// the user tracker will call configure_relays after filling in advertised
699+
pool.bootstrapping_relays = bootstrapping_urls
700+
.iter()
701+
.map(|&s| s.to_string())
702+
.map(|s| RelayPool::canonicalize_url(&s))
703+
.collect();
704+
// normally empty
705+
pool.forced_relays = parsed_args
706+
.relays
707+
.into_iter()
708+
.map(|s| RelayPool::canonicalize_url(&s))
709+
.collect::<BTreeSet<_>>();
710+
// avoid relay thrash, don't call configure_relays here
711+
// because the initial advertised set will be registered
712+
// shortly and it will be called then
703713

704714
let account = accounts
705715
.get_selected_account()

src/task.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ fn set_advertised_relays(pool: &mut RelayPool, relays: Vec<String>) {
103103
let wakeup = move || {
104104
// FIXME - how do we repaint?
105105
};
106-
pool.advertised_relays = relays.into_iter().collect();
106+
pool.advertised_relays = relays
107+
.into_iter()
108+
.map(|s| RelayPool::canonicalize_url(&s))
109+
.collect();
107110
if let Err(e) = pool.configure_relays(wakeup) {
108111
error!("{:?}", e)
109112
}

0 commit comments

Comments
 (0)