0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-12-14 14:24:07 +01:00

Try to sane default on jetstream base path

This commit is contained in:
Neil Alexander 2021-07-14 15:22:25 +01:00
parent ec4e0302c0
commit ee6bfe24f5
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 13 additions and 7 deletions

View file

@ -1,8 +1,6 @@
package main package main
import ( import (
"crypto/rand"
"encoding/hex"
"flag" "flag"
"fmt" "fmt"
@ -72,9 +70,6 @@ func main() {
// don't hit matrix.org when running tests!!! // don't hit matrix.org when running tests!!!
cfg.SigningKeyServer.KeyPerspectives = config.KeyPerspectives{} cfg.SigningKeyServer.KeyPerspectives = config.KeyPerspectives{}
cfg.UserAPI.BCryptCost = bcrypt.MinCost 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) j, err := yaml.Marshal(cfg)

View file

@ -329,6 +329,7 @@ func (c *Dendrite) Verify(configErrs *ConfigErrors, isMonolith bool) {
} }
func (c *Dendrite) Wiring() { func (c *Dendrite) Wiring() {
c.Global.JetStream.Matrix = &c.Global
c.ClientAPI.Matrix = &c.Global c.ClientAPI.Matrix = &c.Global
c.EDUServer.Matrix = &c.Global c.EDUServer.Matrix = &c.Global
c.FederationAPI.Matrix = &c.Global c.FederationAPI.Matrix = &c.Global

View file

@ -1,8 +1,14 @@
package config package config
import "fmt" import (
"fmt"
"log"
"regexp"
)
type JetStream struct { type JetStream struct {
Matrix *Global `yaml:"-"`
// Persistent directory to store JetStream streams in. // Persistent directory to store JetStream streams in.
StoragePath Path `yaml:"storage_path"` StoragePath Path `yaml:"storage_path"`
// A list of NATS addresses to connect to. If none are specified, an // A list of NATS addresses to connect to. If none are specified, an
@ -22,7 +28,11 @@ func (c *JetStream) TopicFor(name string) string {
func (c *JetStream) Defaults() { func (c *JetStream) Defaults() {
c.Addresses = []string{} c.Addresses = []string{}
c.TopicPrefix = "Dendrite" c.TopicPrefix = "Dendrite"
c.StoragePath = Path("./") reg, err := regexp.Compile(`[^a-zA-Z0-9\.]+`)
if err != nil {
log.Fatal(err)
}
c.StoragePath = Path("./" + reg.ReplaceAllString(string(c.Matrix.ServerName), ""))
} }
func (c *JetStream) Verify(configErrs *ConfigErrors, isMonolith bool) { func (c *JetStream) Verify(configErrs *ConfigErrors, isMonolith bool) {