Try to sane default on jetstream base path
This commit is contained in:
parent
ec4e0302c0
commit
ee6bfe24f5
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue