diff --git a/config.go b/config.go index 38b5856..ebd2682 100644 --- a/config.go +++ b/config.go @@ -2,6 +2,7 @@ package main import ( "encoding/json" + "fmt" "log" "os" "runtime/debug" @@ -32,6 +33,7 @@ type Config struct { RelayBindAddress string `json:"relay_bind_address"` RelaySoftware string `json:"relay_software"` RelayVersion string `json:"relay_version"` + UserAgent string `json:"user_agent"` PrivateRelayName string `json:"private_relay_name"` PrivateRelayNpub string `json:"private_relay_npub"` PrivateRelayDescription string `json:"private_relay_description"` @@ -66,6 +68,8 @@ type Config struct { S3Config *S3Config `json:"s3_config"` } +const relaySoftware = "https://github.com/bitvora/haven" + func loadConfig() Config { _ = godotenv.Load(".env") @@ -78,8 +82,9 @@ func loadConfig() Config { RelayURL: getEnv("RELAY_URL"), RelayPort: getEnvInt("RELAY_PORT", 3355), RelayBindAddress: getEnvString("RELAY_BIND_ADDRESS", "0.0.0.0"), - RelaySoftware: "https://github.com/bitvora/haven", + RelaySoftware: relaySoftware, RelayVersion: getVersion(), + UserAgent: fmt.Sprintf("Haven/%s (+%s)", getVersion(), relaySoftware), PrivateRelayName: getEnv("PRIVATE_RELAY_NAME"), PrivateRelayNpub: getEnv("PRIVATE_RELAY_NPUB"), PrivateRelayDescription: getEnv("PRIVATE_RELAY_DESCRIPTION"), diff --git a/main.go b/main.go index 351e9df..80b5c2d 100644 --- a/main.go +++ b/main.go @@ -38,7 +38,13 @@ func main() { log.Fatal("🚫 error creating blossom path:", err) } - pool = nostr.NewSimplePool(mainCtx, nostr.WithPenaltyBox()) + pool = nostr.NewSimplePool(mainCtx, + nostr.WithPenaltyBox(), + nostr.WithRelayOptions( + nostr.WithRequestHeader{ + "User-Agent": []string{config.UserAgent}, + }), + ) if len(os.Args) > 1 { switch os.Args[1] { @@ -49,6 +55,7 @@ func main() { runRestore(mainCtx) return case "import": + ensureImportRelays() runImport(mainCtx) return case "help": diff --git a/relays_blastr.example.json b/relays_blastr.example.json index 9ca6e8e..27ac39d 100644 --- a/relays_blastr.example.json +++ b/relays_blastr.example.json @@ -1,22 +1,22 @@ [ - "relay.damus.io", + "nostr-01.yakihonne.com", "nos.lol", - "relay.nostr.band", - "relay.snort.social", + "nostr.bitcoiner.social", "nostr.land", "nostr.mom", - "relay.nos.social", - "relay.primal.net", - "no.str.cr", + "nostr.oxtr.dev", "nostr21.com", - "nostrue.com", - "wot.utxo.one", "nostrelites.org", - "wot.nostr.party", - "wot.sovbit.host", - "wot.girino.org", + "relay.damus.io", + "relay.fountain.fm", "relay.lexingtonbitcoin.org", - "zap.watch", + "relay.nos.social", + "relay.primal.net", + "relay.snort.social", "satsage.xyz", - "wons.calva.dev" + "sendit.nosflare.com", + "wons.calva.dev", + "wot.girino.org", + "wot.nostr.party", + "wot.sovbit.host" ] diff --git a/relays_import.example.json b/relays_import.example.json index 9ca6e8e..b804a1e 100644 --- a/relays_import.example.json +++ b/relays_import.example.json @@ -1,22 +1,22 @@ [ - "relay.damus.io", + "no.str.cr", "nos.lol", - "relay.nostr.band", - "relay.snort.social", + "nostr.bitcoiner.social", "nostr.land", "nostr.mom", - "relay.nos.social", - "relay.primal.net", - "no.str.cr", + "nostr.oxtr.dev", "nostr21.com", - "nostrue.com", - "wot.utxo.one", "nostrelites.org", - "wot.nostr.party", - "wot.sovbit.host", - "wot.girino.org", + "offchain.pub", + "relay.damus.io", + "relay.fountain.fm", "relay.lexingtonbitcoin.org", - "zap.watch", + "relay.nos.social", + "relay.primal.net", + "relay.snort.social", "satsage.xyz", - "wons.calva.dev" + "wons.calva.dev", + "wot.girino.org", + "wot.nostr.party", + "wot.sovbit.host" ]