Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decide to which relay's AUTH you respond #739

Open
dluvian opened this issue Feb 1, 2025 · 3 comments
Open

Decide to which relay's AUTH you respond #739

dluvian opened this issue Feb 1, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@dluvian
Copy link
Contributor

dluvian commented Feb 1, 2025

Describe the enhancement

Add RelayServiceFlags::Auth or some other way to decide to which relay's AUTH request the client will respond.

Use case

You don't want to reveal your identity to random relays.

Additional context

I don't need it right now, just noticed it while thinking about AUTH. I'm talking about Rust, not the bindings.

@dluvian dluvian added the enhancement New feature or request label Feb 1, 2025
@yukibtc
Copy link
Member

yukibtc commented Feb 1, 2025

The easiest way I can think, which is already possible to use, is to disable auto-authentication in options and handle manually the AUTH requests received in notifications. But this will require also to handle manually the resubmission of events for all relays.

Alternatively, we can use the RelaServiceFlags and add the AUTH flag, to selectively choose what relay can auto-authenticate.

It can be enabled by default in the RelayServiceFlags. So, it will be enabled for all relays added with Client::add_relay, but not for the gossip ones (the ones added automatically, from NIP17/NIP65 list).

Using the RelayPool::add_relay, will be enough to change the flags in the RelayOptions.

@dluvian
Copy link
Contributor Author

dluvian commented Feb 1, 2025

Is there a document that describes how gossip works in rust-nostr? Or can you link me the code? I'm implementing gossip myself right now but if I like how it's implemented in rust-nostr then I will switch.

My main concerns are:

  • I don't want to use gossip for every REQ
  • I want to restrict the number of new relays I connect to
  • When selecting gossip relays I want to prefer the ones my client already had success with

@yukibtc
Copy link
Member

yukibtc commented Feb 2, 2025

Is there a document that describes how gossip works in rust-nostr? Or can you link me the code?

The current implementation is in nostr-sdk, in client/mod.rs and gossip/graph.rs modules:

I don't want to use gossip for every REQ

If the gossip option is enabled, only methods that don't require you to specify urls will use the gossip model (send_event, subscribe, fech_events, ...). Gossip is never used for send_event_to, subscribe_to, fetch_events_from and so on.

I want to restrict the number of new relays I connect to

Currently are used at max the first 5 relays from the NIP17/65 lists. I also added an option to limit the numbers of relays in the pool (which is None by default), but probably here something must be reworked. I'm planning to add a "sleep" option that keep all unused gossip relays disconnected if unused (like a connenction on-demand).

When selecting gossip relays I want to prefer the ones my client already had success with

For this I guess is required a persistent db. I have plan to add a persistent database for gossip ranking/score, but I haven't started to work on it yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants