From 74735e7cd53e16e4313516ae0606b798ec0e4dc2 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 14 Jul 2021 14:26:14 +0100 Subject: [PATCH] Config tweaks, make random jetstream storage path for CI --- cmd/generate-config/main.go | 5 +++++ setup/config/config.go | 1 - setup/config/config_jetstream.go | 4 +--- setup/jetstream/nats.go | 10 ++++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/generate-config/main.go b/cmd/generate-config/main.go index bd70cbc5..52566dc1 100644 --- a/cmd/generate-config/main.go +++ b/cmd/generate-config/main.go @@ -1,6 +1,8 @@ package main import ( + "crypto/rand" + "encoding/hex" "flag" "fmt" @@ -70,6 +72,9 @@ func main() { // don't hit matrix.org when running tests!!! cfg.SigningKeyServer.KeyPerspectives = config.KeyPerspectives{} cfg.UserAPI.BCryptCost = bcrypt.MinCost + var id [8]byte + _, _ = rand.Read(id[:]) + cfg.Global.JetStream.StoragePath = config.Path(hex.EncodeToString(id[:])) } j, err := yaml.Marshal(cfg) diff --git a/setup/config/config.go b/setup/config/config.go index 0589b5a3..a1fb9593 100644 --- a/setup/config/config.go +++ b/setup/config/config.go @@ -329,7 +329,6 @@ func (c *Dendrite) Verify(configErrs *ConfigErrors, isMonolith bool) { } func (c *Dendrite) Wiring() { - c.Global.JetStream.Matrix = &c.Global c.ClientAPI.Matrix = &c.Global c.EDUServer.Matrix = &c.Global c.FederationAPI.Matrix = &c.Global diff --git a/setup/config/config_jetstream.go b/setup/config/config_jetstream.go index 0f348aa9..63957cf5 100644 --- a/setup/config/config_jetstream.go +++ b/setup/config/config_jetstream.go @@ -3,8 +3,6 @@ package config import "fmt" type JetStream struct { - Matrix *Global `yaml:"-"` - // Persistent directory to store JetStream streams in. StoragePath Path `yaml:"storage_path"` // A list of NATS addresses to connect to. If none are specified, an @@ -24,7 +22,7 @@ func (c *JetStream) TopicFor(name string) string { func (c *JetStream) Defaults() { c.Addresses = []string{} c.TopicPrefix = "Dendrite" - c.StoragePath = Path(fmt.Sprintf("./%s", c.Matrix.ServerName)) + c.StoragePath = Path("./") } func (c *JetStream) Verify(configErrs *ConfigErrors, isMonolith bool) { diff --git a/setup/jetstream/nats.go b/setup/jetstream/nats.go index 0300f076..59856454 100644 --- a/setup/jetstream/nats.go +++ b/setup/jetstream/nats.go @@ -24,10 +24,12 @@ func SetupConsumerProducer(cfg *config.JetStream) (sarama.Consumer, sarama.SyncP if s == nil { var err error natsServer, err = natsserver.NewServer(&natsserver.Options{ - ServerName: "monolith", - DontListen: true, - JetStream: true, - StoreDir: string(cfg.Matrix.JetStream.StoragePath), + ServerName: "monolith", + DontListen: true, + JetStream: true, + StoreDir: string(cfg.StoragePath), + NoSystemAccount: true, + AllowNewAccounts: false, }) if err != nil { panic(err)