From 32f3673b268ed727491344e613a800f0c047603f Mon Sep 17 00:00:00 2001 From: Fishcake Date: Mon, 24 Apr 2023 15:55:21 +0900 Subject: [PATCH 1/4] feat(conf): make our relays configurable --- .env.example | 2 ++ main.go | 7 +++++++ nostr.go | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 083d28d..da8a2c8 100644 --- a/.env.example +++ b/.env.example @@ -10,3 +10,5 @@ FORWARD_URL="/somepageyouwanttoshowdontuseoptionifnone" NIP05=true GET_NOSTR_PROFILE=false LND_PRIVATE_ONLY=false +DB_DIR="./" +OUR_RELAYS="wss://nostr.mutinywallet.com,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" \ No newline at end of file diff --git a/main.go b/main.go index 9334c85..836e148 100644 --- a/main.go +++ b/main.go @@ -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:""` + OURRelayes string `envconfig:"OUR_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 ourRelays []string + //go:embed index.html var indexHTML string @@ -68,6 +72,9 @@ func main() { log.Fatal().Err(err).Msg("couldn't process envconfig.") } + // parse our relays + ourRelays = strings.Split(s.OURRelayes, ",") + // increase default makeinvoice client timeout because people are using tor makeinvoice.Client = &http.Client{Timeout: 25 * time.Second} diff --git a/nostr.go b/nostr.go index b03d63e..0b2f95e 100644 --- a/nostr.go +++ b/nostr.go @@ -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, ourRelays...) // remove trailing / relays = cleanUrls(relays) // unique relays From a268ded17aafe2b3400c466d47889492eff2216d Mon Sep 17 00:00:00 2001 From: Fishcake Date: Mon, 24 Apr 2023 16:32:39 +0900 Subject: [PATCH 2/4] chore(docs): add info about new parameters to README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3a5b7be..c9a9f14 100644 --- a/README.md +++ b/README.md @@ -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 + +> (`OUR_RELAYS`) Specify comma separate list of relays to push zap notes to, in addition to the zapped user relays. + ``` From 52ebe4d86a75def089a0b706d2b9d1f445bcd31b Mon Sep 17 00:00:00 2001 From: Fishcake Date: Mon, 24 Apr 2023 17:08:19 +0900 Subject: [PATCH 3/4] Fix relay variable name and add bootstrap relays --- .env.example | 2 +- README.md | 2 +- main.go | 16 +++++++++++++--- nostr.go | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index da8a2c8..e162697 100644 --- a/.env.example +++ b/.env.example @@ -11,4 +11,4 @@ NIP05=true GET_NOSTR_PROFILE=false LND_PRIVATE_ONLY=false DB_DIR="./" -OUR_RELAYS="wss://nostr.mutinywallet.com,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" \ No newline at end of file +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" \ No newline at end of file diff --git a/README.md b/README.md index c9a9f14..4d10842 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ New parameters in this fork: > (`DB_DIR`) Specify directory to create or access database -> (`OUR_RELAYS`) Specify comma separate list of relays to push zap notes to, in addition to the zapped user relays. +> (`RELAYS`) Specify comma separate list of relays to push zap notes to, in addition to the zapped user relays. diff --git a/main.go b/main.go index 836e148..79b95ac 100644 --- a/main.go +++ b/main.go @@ -26,7 +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:""` - OURRelayes string `envconfig:"OUR_RELAYS" required:"false" default:""` + Relayes 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"` @@ -53,7 +53,7 @@ var ( ) // array of additional relays -var ourRelays []string +var Relays []string //go:embed index.html var indexHTML string @@ -73,7 +73,17 @@ func main() { } // parse our relays - ourRelays = strings.Split(s.OURRelayes, ",") + Relays = strings.Split(s.Relayes, ",") + // 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} diff --git a/nostr.go b/nostr.go index 0b2f95e..8684075 100644 --- a/nostr.go +++ b/nostr.go @@ -197,7 +197,7 @@ func GetNostrProfileMetaData(npub string) (nostr.ProfileMetadata, error) { func publishNostrEvent(ev nostr.Event, relays []string) { // more relays - relays = append(relays, ourRelays...) + relays = append(relays, Relays...) // remove trailing / relays = cleanUrls(relays) // unique relays From 87ee2f91b810e26ccf44c8f55031854d3afe2f69 Mon Sep 17 00:00:00 2001 From: Fishcake Date: Mon, 24 Apr 2023 17:57:45 +0900 Subject: [PATCH 4/4] fix(typo): Relayes --> Relays --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 79b95ac..c13494d 100644 --- a/main.go +++ b/main.go @@ -26,7 +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:""` - Relayes string `envconfig:"RELAYS" 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"` @@ -73,7 +73,7 @@ func main() { } // parse our relays - Relays = strings.Split(s.Relayes, ",") + Relays = strings.Split(s.Relays, ",") // Check if relays are not specified and add our bootstrap relays if len(Relays) == 1 && Relays[0] == "" { Relays = []string{