vishalxl / nostr_console

Nostr console is an open-source twitter-like social network, direct chat app and group chat all bundled into one program. Built on the decentralized Nostr protocol.
GNU Affero General Public License v3.0
439 stars 33 forks source link

allow multiple relays to be added to the relay list on start #43

Closed ghost closed 1 year ago

ghost commented 1 year ago
dart run bin/nostr_console.dart --relay wss://nostr.radixrat.com,wss://nostr.zebedee.cloud
...
Also going to use new relay: wss://nostr.radixrat.com apart from the relays [wss://relay.damus.io, wss://relay.nostr.info, wss://nostr-relay.wlvs.space]
Also going to use new relay: wss://nostr.zebedee.cloud apart from the relays [wss://relay.damus.io, wss://relay.nostr.info, wss://nostr-relay.wlvs.space, wss://nostr.radixrat.com

left as --relay to maximize backward compatibility, @vishalxl may have something else in mind for this type of feature though just saw someone post a question about it on nostr

vishalxl commented 1 year ago

Hey thanks. I think its good to enable user to replace all relays.

So if hardcoded relays are a,b,c then user wants to add "d", then he/she can pass on all four "a,b,c,d".

But he user wants to add only "a,b", then they pass "a,b" then c is also removed.

This allows user to totally control relays.

(user will be shown relays being hard coded or being used so they can decide)

vishalxl commented 1 year ago

But I can do it myself too. No pressure. Just wanted to point out.

vishalxl commented 1 year ago

first code pull request. This is great. Thank you.

ghost commented 1 year ago

I can make that modification, so basically if user is passing --relay we adopt their relay list for gListRelayUrls1

jeremyd commented 1 year ago

:fire: :+1:

ghost commented 1 year ago

single relay (prior behaviour)

dart run bin/nostr_console.dart --relay wss://nostr.radixrat.com/

Relay List: [wss://nostr.radixrat.com]

multi-relay

dart run bin/nostr_console.dart --relay wss://nostr.radixrat.com,wss://nostr.zebedee.cloud

Relay List: [wss://nostr.radixrat.com, wss://nostr.zebedee.cloud]

Malformed URLS without wss:// default back to default relays (if user didn't provide any valid relays):

dart run bin/nostr_console.dart --relay wst://nostr.radixrat.com,wst://nostr.zebedee.cloud

The provided relay entry: wst://nostr.radixrat.com does not start with wss://, omitting
The provided relay entry: wst://nostr.zebedee.cloud does not start with wss://, omitting
No valid relays were provided, using the default relay list
Relay List: [wss://relay.damus.io, wss://relay.nostr.info, wss://nostr-relay.wlvs.space]
ghost commented 1 year ago

@vishalxl had to pick up kid from school first, I implemented ability for user to replace entire relay list, log output shown above for a few scenarios, see if that matches what you were thinking of.

vishalxl commented 1 year ago

i will do two more changes. someone was saying they needed to test ws://localhost, so the check should allow ws:// too.

also I want to change these sets of relays from lists to sets, which they should have been from the starting. so we aren't anyway working with same entries, which even user can by mistake send in. Again, just highlighting here. I will pull in and can do the changes myself unless you are in mood to do it.

ghost commented 1 year ago

i will do two more changes. someone was saying they needed to test ws://localhost, so the check should allow ws:// too.

also I want to change these sets of relays from lists to sets, which they should have been from the starting. so we aren't anyway working with same entries, which even user can by mistake send in. Again, just highlighting here. I will pull in and can do the changes myself unless you are in mood to do it.

I can take a stab at it

ghost commented 1 year ago

ws:// allowed

dart run bin/nostr_console.dart --relay ws://nostr.radixrat.com,ws://nostr.zebedee.cloud

Relay List: {ws://nostr.radixrat.com, ws://nostr.zebedee.cloud}

malformed urls still caught ie: wa://:

The provided relay entry: wa://nostr.radixrat.com does not start with ws:// or wss://, omitting
The provided relay entry: wa://nostr.zebedee.cloud does not start with ws:// or wss://, omitting
No valid relays were provided, using the default relay list
Relay List: {wss://relay.damus.io, wss://relay.nostr.info, wss://nostr-relay.wlvs.space}

since set now we shouldn't need to check for duplicate relay entries, so that was removed

ex passing two dupe relays:

dart run bin/nostr_console.dart --relay wss://relay.damus.io,wss://relay.damus.io

Relay List: {wss://relay.damus.io}
ghost commented 1 year ago

@vishalxl hopefully that covers your last response