Skip to content

codonaft/broadcastr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

132 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Broadcastr

Made for Nostr Crates.io Crates.io Dependency Status Awesome GitHub Sponsors

Vendor lock-free stateless alternative to blastr with additional features:

  • relay discovery
  • spam filtering
  • event filtering
    • kind
    • author/mention
    • PoW
  • gossip
  • subscribe to events (of particular authors and event kinds) and distribute them automatically
  • tor/onion relays
  • relays ignore list
  • minimizes the risk of being rate-limited by relays
    • it checks whether event is already published on a certain relay

Changelogs.

Install

From crates.io

cargo install --locked broadcastr

From git

cargo install --locked --force --git https://github.com/codonaft/broadcastr

Run

broadcastr \
  --listen ws://localhost:8080 \
  --relays https://codonaft.com/relays.json \
  --read-relays wss://monitorlizard.nostr1.com,wss://relay.nostr.watch,wss://relaypag.es
πŸ’‘ Usage πŸ‘οΈ

Usage: broadcastr --listen <listen> [--relays <relays>] [--read-relays <read-relays>] [--block-relays <block-relays>] [--block-ttl <block-ttl>] [--kinds <kinds>] [--pubkeys <pubkeys>] [--no-mentions] [--subscribe] [--no-protect] [--no-gossip-discovery] [--no-nip66-discovery] [--no-azzamo] [--tor-proxy <tor-proxy>] [--proxy <proxy>] [--log-level <log-level>] [--max-relays <max-relays>] [--max-events-by-author-per-min <max-events-by-author-per-min>] [--max-events-by-ip-per-min <max-events-by-ip-per-min>] [--min-pow <min-pow>] [--max-tags <max-tags>] [--update-interval <update-interval>] [--max-backoff-interval <max-backoff-interval>] [--connect-timeout <connect-timeout>] [--request-timeout <request-timeout>] [--relay-info <relay-info>] [--redirect <redirect>] [--max-msg-size <max-msg-size>] [--tcp-backlog <tcp-backlog>] [--max-frame-size <max-frame-size>]

Broadcast Nostr events to other relays

Options:
  --listen          the listener ws URI (e.g. "ws://localhost:8080")
  --relays          relays or relay-list URIs in a descending order of priority
                    (comma-separated, optionally with per relay event kind
                    allow-list, e.g.
                    "https://codonaft.com/relays.json,file:///path/to/relays-in-array.json,wss://user.kindpag.es#k=0+3+10002,ws://1.2.3.4:5678")
  --read-relays     same, but for read-only relays; overrides the --relays
                    entries
  --block-relays    same, but for ignored relays; put public URL to your
                    broadcastr here to avoid loops
  --block-ttl       store automatically blocked relays for given amount (default
                    is 2h)
  --kinds           allow some event kinds only (comma-separated allow-list, e.g
                    "0,1,3,5,6,7,4550,34550")
  --pubkeys         allow authors or mentioned authors only (comma-separated
                    hex/bech32/NIP-21 allow-list)
  --no-mentions     disallow mentions (of the allowed authors) by others
  --subscribe       subscribe and automatically distribute events (of the
                    allowed authors and kinds)
  --no-protect      ignore NIP-70 protection tag for the automatically
                    distributed events
  --no-gossip-discovery
                    don't discover additional relays from user profiles
  --no-nip66-discovery
                    don't discover additional relays using NIP-66
  --no-azzamo       don't use azzamo.net for spam filtering
  --tor-proxy       connect to tor onion relays using socks5 proxy (e.g.
                    "127.0.0.1:9050")
  --proxy           make all connections using socks5 proxy
  --log-level       log level (default is info)
  --max-relays      limit the connection pool
  --max-events-by-author-per-min
                    limit events by author (default is 5)
  --max-events-by-ip-per-min
                    limit events by IP (default is 50)
  --min-pow         proof of work difficulty limit
  --max-tags        max tags allowed for non-kind-3 events (default is 32)
  --update-interval relays and spam-lists update interval (default is 15m)
  --max-backoff-interval
                    max update backoff interval (default is 5m)
  --connect-timeout connection timeout (default is 15s)
  --request-timeout request timeout (default is 10s)
  --relay-info      relay info NIP-11 JSON
  --redirect        redirect to a given URL when accessed from a browser
  --max-msg-size    event message size
  --tcp-backlog     max incoming connections per listener IP address
  --max-frame-size  ws frame size
  -h, --help        display usage information

🌐 nginx πŸ‘οΈ

http {
  map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
  }

  real_ip_header X-Forwarded-For;
  real_ip_recursive on;

  server {
    location / {
      proxy_http_version 1.1;
      proxy_connect_timeout 20s;
      proxy_socket_keepalive on;
      proxy_send_timeout 365d;
      proxy_read_timeout 365d;

      proxy_request_buffering off;
      proxy_buffering off;

      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";

      proxy_pass http://localhost:8080/;
    }
  }
}

β–Ά βš™οΈ OpenRC

TODO

  • make it compatible with ordinary clients (besides nak)
    • support delivery of multiple events over the same connection
    • response with vary header
  • support azzamo ban api
  • use client IP (requires X-Forwarded-For or X-Real-IP request header in your reverse proxy)
    • rate-limit
    • allow-list
      • which overrides pubkeys allow-list?
      • disables rate-limit for tor exit nodes?
  • use follower list as allow-list
  • use REQ filter as allow-list?
    • e.g. allow events that ping a certain npub
      • limit number of p tags for events by strangers to avoid spam
  • deduplicate concurrently sent events
  • option to subscribe to a certain REQ filter and automatically broadcast such events
    • with auto added authors and since
    • don't disconnect from relays specified in 10002 of the allowed npubs, keep reading from them?
  • NIP-11
    • custom relay info
    • don't serialize null?
  • custom http page or a redirect
  • improve RAM usage
    • run memory profiler
    • disconnect from relays?
      • that previously didn't receive events with the same kind?
      • that closed connections after we sent them event?
      • option to disconnect after timeout?
      • which are NIP-42-only ("auth-required"/"auth failed")
      • ban relays that didn't receive the known kinds
      • relays that fail due to TLS or DNS
    • make sure we don't attempt to connect to faulty relays
      • retry to connect with an exponential backoff?
  • add metrics
  • endpoint that returns a healthy relay list?
  • socks5/http proxy for all connections
  • login to NIP-42 relays?
    • does it make sense transmitting someone else's events from a generated nsec?
  • option to ignore TLS issues?
    • disallow for NIP-59 and NIP-70?
  • per relay event kind allow-list
  • fetch newest replaceable d-tagged event?
    • when checking whether event exists on the relays
    • kind 30023 in particular
  • batch events received from WS?
    • query them using a single REQ filter
  • act as a proxy?
    • as a RAM-cached proxy for all transmitted events?
    • as a proxy to a list of relays?
    • support REQ?
  • act as a NIP-59 gift wrap proxy?
    • receive events from NIP-42 authenticated users only, WS only
    • distribute to relevant 10050 relay lists
    • ignore broken DM relays

Support

I'm currently investing all my time in FOSS projects.

If you found this repo useful and you want to support me, please

  • ⭐ star
  • ⚑ zap
  • 🌚 something else

Your support keeps me going ❀️ (β—•β€Ώβ—•)

License

MIT/Apache-2.0

About

Nostr relay that transmits events to other relays

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Sponsor this project

Packages

 
 
 

Contributors