chore: variablize relay info

This commit is contained in:
Amarpreet Minhas 2024-08-14 21:20:14 -04:00
parent d6a09a364b
commit 50c878dc67
5 changed files with 34 additions and 10 deletions

View file

@ -17,3 +17,8 @@ GRANT ALL PRIVILEGES ON DATABASE wgk TO wgk;
ALTER DATABASE wgk OWNER TO wgk;
EOF
```
To build a release version, go to a tag and run:
```
go build -ldflags="-X main.Commit=$(git tag)"
```

View file

@ -12,6 +12,11 @@ type (
MatrixIdentityServer string
MatrixMsc3575Address string
MatrixWellKnownAddress string
RelayName string
RelayPubkey string
RelayDescription string
RelayIcon string
RelayContact string
}
)
@ -23,6 +28,11 @@ func GetConfig() Config {
MatrixIdentityServer: getEnv("MATRIX_IDENTITY_SERVER", ""),
MatrixMsc3575Address: getEnv("MATRIX_MSC3575_ADDRESS", ""),
MatrixWellKnownAddress: getEnv("MATRIX_WELL_KNOWN_ADDRESS", ""),
RelayName: getEnv("RELAY_NAME", ""),
RelayPubkey: getEnv("RELAY_PUBKEY", ""),
RelayDescription: getEnv("RELAY_DESCRIPTION", ""),
RelayIcon: getEnv("RELAY_ICON", ""),
RelayContact: getEnv("RELAY_CONTACT", ""),
}
}

View file

@ -11,6 +11,10 @@ import (
"github.com/fiatjaf/eventstore/postgresql"
)
var (
Version string
)
func main() {
l := gologger.Get(config.GetConfig().LogLevel).With().Str("context", "main").Logger()
db, _ := db.NewDB()
@ -22,7 +26,7 @@ func main() {
l.Panic().Msgf("unable to connect to relay db: %s", err.Error())
}
relay := nostr.NewRelay()
relay := nostr.NewRelay(Version)
// matrix endpoints
l.Debug().Msg("enabling matrix well-known endpoints")

View file

@ -108,15 +108,15 @@ func GetNostrAddr(w http.ResponseWriter, r *http.Request) {
return
}
func NewRelay() *khatru.Relay {
func NewRelay(version string) *khatru.Relay {
// relay configuration
relay = khatru.NewRelay()
relay.Info.Name = "Devvul Nostr Relay"
relay.Info.PubKey = "ac7d66c7065e211b27759ffe2b333fde34e307cead79ce7c00f401d8fa6c08d1"
relay.Info.Description = "nostr relay for devvul users"
relay.Info.Icon = "https://pfp.nostr.build/ee442b3c54143099fb483b5e3a6e1e41144df5c7457313a30586a082baa1babc.png"
relay.Info.Version = "0.0.1"
relay.Info.Contact = "asara@devvul.com"
relay.Info.Name = config.GetConfig().RelayName
relay.Info.PubKey = config.GetConfig().RelayPubkey
relay.Info.Description = config.GetConfig().RelayDescription
relay.Info.Icon = config.GetConfig().RelayIcon
relay.Info.Contact = config.GetConfig().RelayContact
relay.Info.Version = version
relay.Info.Software = "https://git.devvul.com/asara/well-goknown"
// contact lists
relay.Info.SupportedNIPs = append(relay.Info.SupportedNIPs, 2)

View file

@ -1,5 +1,10 @@
export DATABASE_URL="postgres://user:password@127.0.0.1:5432/db?sslmode=disable"
export LISTEN_ADDR=":8090"
export LOG_LEVEL=0
export MATRIX_WELL_KNOWN_ADDRESS=matrix.example.com
export MATRIX_MSC3575_ADDRESS=https://matrix.example.com
export DATABASE_URL="postgres://user:password@127.0.0.1:5432/db?sslmode=disable"
export MATRIX_WELL_KNOWN_ADDRESS=matrix.example.com
export RELAY_CONTACT="matrix:u/asara:devvul.com"
export RELAY_DESCRIPTION="nostr relay running via git.devvul.com/asara/well-goknown"
export RELAY_ICON=""
export RELAY_NAME="Nostr Relay"
export RELAY_PUBKEY=""