Merge pull request #51 from cr0bar/master

Change to support name and version number for NIP-11
This commit is contained in:
Barry Deen 2024-09-18 07:30:22 -04:00 committed by GitHub
commit 7f35c801b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 2 deletions

View File

@ -3,6 +3,8 @@ RELAY_NAME="utxo WoT relay"
RELAY_PUBKEY="e2ccf7cf20403f3f2a4a55b328f0de3be38558a7d5f33632fdaaefc726c1c8eb" # not your npub! RELAY_PUBKEY="e2ccf7cf20403f3f2a4a55b328f0de3be38558a7d5f33632fdaaefc726c1c8eb" # not your npub!
RELAY_DESCRIPTION="Only notes in utxo WoT" RELAY_DESCRIPTION="Only notes in utxo WoT"
RELAY_URL="wss://wot.utxo.one" RELAY_URL="wss://wot.utxo.one"
RELAY_ICON="https://nostr.build/i/53866b44135a27d624e99c6165cabd76ac8f72797209700acb189fce75021f47.jpg"
RELAY_CONTACT="https://utxo.one"
# where we should store the database # where we should store the database
DB_PATH="db" DB_PATH="db"
@ -18,4 +20,4 @@ REFRESH_INTERVAL_HOURS=1
MINIMUM_FOLLOWERS=5 MINIMUM_FOLLOWERS=5
# archive all notes from everyone in your WoT from other relays # archive all notes from everyone in your WoT from other relays
ARCHIVAL_SYNC="FALSE" ARCHIVAL_SYNC="FALSE"

View File

@ -61,7 +61,7 @@ ARCHIVAL_SYNC="FALSE" # set to TRUE to archive every note from every person in t
Run the following command to build the relay: Run the following command to build the relay:
```bash ```bash
go build go build -ldflags "-X main.version=$(git describe --tags --always)"
``` ```
### 5. Create a Systemd Service (optional) ### 5. Create a Systemd Service (optional)

13
main.go
View File

@ -18,6 +18,10 @@ import (
"github.com/nbd-wtf/go-nostr" "github.com/nbd-wtf/go-nostr"
) )
var (
version string
)
type Config struct { type Config struct {
RelayName string RelayName string
RelayPubkey string RelayPubkey string
@ -29,6 +33,8 @@ type Config struct {
RefreshInterval int RefreshInterval int
MinimumFollowers int MinimumFollowers int
ArchivalSync bool ArchivalSync bool
RelayContact string
RelayIcon string
} }
var pool *nostr.SimplePool var pool *nostr.SimplePool
@ -73,7 +79,12 @@ func main() {
relay.Info.Name = config.RelayName relay.Info.Name = config.RelayName
relay.Info.PubKey = config.RelayPubkey relay.Info.PubKey = config.RelayPubkey
relay.Info.Icon = config.RelayIcon
relay.Info.Contact = config.RelayContact
relay.Info.Description = config.RelayDescription relay.Info.Description = config.RelayDescription
relay.Info.Software = "WoT Relay"
relay.Info.Version = version
appendPubkey(config.RelayPubkey) appendPubkey(config.RelayPubkey)
db := getDB() db := getDB()
@ -183,6 +194,8 @@ func LoadConfig() Config {
RelayName: getEnv("RELAY_NAME"), RelayName: getEnv("RELAY_NAME"),
RelayPubkey: getEnv("RELAY_PUBKEY"), RelayPubkey: getEnv("RELAY_PUBKEY"),
RelayDescription: getEnv("RELAY_DESCRIPTION"), RelayDescription: getEnv("RELAY_DESCRIPTION"),
RelayContact: getEnv("RELAY_CONTACT"),
RelayIcon: getEnv("RELAY_ICON"),
DBPath: getEnv("DB_PATH"), DBPath: getEnv("DB_PATH"),
RelayURL: getEnv("RELAY_URL"), RelayURL: getEnv("RELAY_URL"),
IndexPath: getEnv("INDEX_PATH"), IndexPath: getEnv("INDEX_PATH"),