Get around CCP bootstrap relay banning by caching user's relays as their bootstrap relays

Changelog-Fixed: Get around CCP bootstrap relay banning by caching user's relays as their bootstrap relays
This commit is contained in:
William Casarin
2023-04-04 10:12:29 -07:00
parent 3da12e708f
commit 679779ab3e
9 changed files with 73 additions and 17 deletions

View File

@@ -79,11 +79,15 @@ struct LoginView: View {
return
}
// this is a weird way to login anyways
/*
var bootstrap_relays = load_bootstrap_relays(pubkey: nip05.pubkey)
for relay in nip05.relays {
if !(BOOTSTRAP_RELAYS.contains { $0 == relay }) {
BOOTSTRAP_RELAYS.append(relay)
if !(bootstrap_relays.contains { $0 == relay }) {
bootstrap_relays.append(relay)
}
}
*/
save_pubkey(pubkey: nip05.pubkey)
notify(.login, ())

View File

@@ -22,7 +22,7 @@ struct RelayConfigView: View {
var recommended: [RelayDescriptor] {
let rs: [RelayDescriptor] = []
return BOOTSTRAP_RELAYS.reduce(into: rs) { xs, x in
return state.bootstrap_relays.reduce(into: rs) { xs, x in
if state.pool.get_relay(x) == nil {
xs.append(RelayDescriptor(url: URL(string: x)!, info: .rw))
}

View File

@@ -90,7 +90,8 @@ struct SaveKeysView: View {
}
func complete_account_creation(_ account: CreateAccountModel) {
for relay in BOOTSTRAP_RELAYS {
let bootstrap_relays = load_bootstrap_relays(pubkey: account.pubkey)
for relay in bootstrap_relays {
add_rw_relay(self.pool, relay)
}