Merge pull request #12 from fishcakeday/make-relays-configurable

Make relays configurable
This commit is contained in:
believethehype
2023-04-24 13:35:09 +02:00
committed by GitHub
4 changed files with 24 additions and 1 deletions
+2
View File
@@ -10,3 +10,5 @@ FORWARD_URL="/somepageyouwanttoshowdontuseoptionifnone"
NIP05=true
GET_NOSTR_PROFILE=false
LND_PRIVATE_ONLY=false
DB_DIR="./"
RELAYS="wss://nostr.mutinywallet.com,wss://relay.nostrgraph.net,wss://blastr.f7z.xyz,wss://relay.damus.io/,wss://relay.utxo.one,wss://relay.nostr.ch,wss://eden.nostr.land,wss://nostr.btcmp.com,wss://nostr.relayer.se,wss://relay.current.fyi,wss://nos.lol,wss://nostr.mom,wss://relay.nostr.info,wss://nostr.zebedee.cloud,wss://nostr-pub.wellorder.net,wss://relay.snort.social/,wss://nostr.oxtr.dev/,wss://nostr.fmt.wiz.biz/,wss://brb.io"
+4
View File
@@ -23,6 +23,10 @@ New parameters in this fork:
> (`LND_PRIVATE_ONLY`) should only be activated if satdress is used for a single user that relies on private LND channels only.
> (`DB_DIR`) Specify directory to create or access database
> (`RELAYS`) Specify comma separate list of relays to push zap notes to, in addition to the zapped user relays.
```
+17
View File
@@ -26,6 +26,7 @@ type Settings struct {
Port string `envconfig:"PORT" required:"true"`
Domain string `envconfig:"DOMAIN" required:"true"`
DBDirectory string `envconfig:"DB_DIR" required:"false" default:""`
Relays string `envconfig:"RELAYS" required:"false" default:""`
// GlobalUsers means that user@ part is globally unique across all domains
// WARNING: if you toggle this existing users won't work anymore for safety reasons!
GlobalUsers bool `envconfig:"GLOBAL_USERS" default:"false"`
@@ -51,6 +52,9 @@ var (
log = zerolog.New(os.Stderr).Output(zerolog.ConsoleWriter{Out: os.Stderr})
)
// array of additional relays
var Relays []string
//go:embed index.html
var indexHTML string
@@ -68,6 +72,19 @@ func main() {
log.Fatal().Err(err).Msg("couldn't process envconfig.")
}
// parse our relays
Relays = strings.Split(s.Relays, ",")
// Check if relays are not specified and add our bootstrap relays
if len(Relays) == 1 && Relays[0] == "" {
Relays = []string{
"wss://relay.damus.io", // Main Damus Relay
"wss://nostr.mutinywallet.com", // Special broadcast relay
"wss://relay.nostrgraph.net", // Special broadcast relay
"wss://nos.lol", // Large relay
"wss://relay.snort.social", // Large relay for snort Users
}
}
// increase default makeinvoice client timeout because people are using tor
makeinvoice.Client = &http.Client{Timeout: 25 * time.Second}
+1 -1
View File
@@ -197,7 +197,7 @@ func GetNostrProfileMetaData(npub string) (nostr.ProfileMetadata, error) {
func publishNostrEvent(ev nostr.Event, relays []string) {
// more relays
relays = append(relays, "wss://relay.nostr.ch", "wss://eden.nostr.land", "wss://nostr.btcmp.com", "wss://nostr.relayer.se", "wss://relay.current.fyi", "wss://nos.lol", "wss://nostr.mom", "wss://relay.nostr.info", "wss://nostr.zebedee.cloud", "wss://nostr-pub.wellorder.net", "wss://relay.snort.social/", "wss://relay.damus.io/", "wss://nostr.oxtr.dev/", "wss://nostr.fmt.wiz.biz/", "wss://brb.io")
relays = append(relays, Relays...)
// remove trailing /
relays = cleanUrls(relays)
// unique relays