2020-08-10 15:18:04 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-09-03 11:12:11 +02:00
|
|
|
"flag"
|
2020-08-10 15:18:04 +02:00
|
|
|
"fmt"
|
|
|
|
|
2020-12-02 18:41:00 +01:00
|
|
|
"github.com/matrix-org/dendrite/setup/config"
|
2021-10-29 13:06:10 +02:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
2021-03-08 14:19:02 +01:00
|
|
|
"golang.org/x/crypto/bcrypt"
|
2020-08-10 15:18:04 +02:00
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2020-09-03 11:12:11 +02:00
|
|
|
defaultsForCI := flag.Bool("ci", false, "sane defaults for CI testing")
|
2021-10-29 13:06:10 +02:00
|
|
|
serverName := flag.String("server", "", "The domain name of the server if not 'localhost'")
|
|
|
|
dbURI := flag.String("db", "", "The DB URI to use for all components if not SQLite files")
|
2020-09-03 11:12:11 +02:00
|
|
|
flag.Parse()
|
|
|
|
|
2022-01-05 18:44:49 +01:00
|
|
|
cfg := &config.Dendrite{
|
|
|
|
Version: config.Version,
|
|
|
|
}
|
2021-11-24 12:57:39 +01:00
|
|
|
cfg.Defaults(true)
|
2021-10-29 13:06:10 +02:00
|
|
|
if *serverName != "" {
|
|
|
|
cfg.Global.ServerName = gomatrixserverlib.ServerName(*serverName)
|
|
|
|
}
|
|
|
|
if *dbURI != "" {
|
|
|
|
cfg.AppServiceAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
2021-11-24 11:45:23 +01:00
|
|
|
cfg.FederationAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
2021-10-29 13:06:10 +02:00
|
|
|
cfg.KeyServer.Database.ConnectionString = config.DataSource(*dbURI)
|
|
|
|
cfg.MSCs.Database.ConnectionString = config.DataSource(*dbURI)
|
|
|
|
cfg.MediaAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
|
|
|
cfg.RoomServer.Database.ConnectionString = config.DataSource(*dbURI)
|
|
|
|
cfg.SyncAPI.Database.ConnectionString = config.DataSource(*dbURI)
|
|
|
|
cfg.UserAPI.AccountDatabase.ConnectionString = config.DataSource(*dbURI)
|
|
|
|
}
|
2020-08-11 14:21:26 +02:00
|
|
|
cfg.Global.TrustedIDServers = []string{
|
|
|
|
"matrix.org",
|
|
|
|
"vector.im",
|
|
|
|
}
|
2020-08-10 15:18:04 +02:00
|
|
|
cfg.Logging = []config.LogrusHook{
|
|
|
|
{
|
|
|
|
Type: "file",
|
|
|
|
Level: "info",
|
|
|
|
Params: map[string]interface{}{
|
|
|
|
"path": "/var/log/dendrite",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2021-11-24 11:45:23 +01:00
|
|
|
cfg.FederationAPI.KeyPerspectives = config.KeyPerspectives{
|
2020-08-11 14:21:26 +02:00
|
|
|
{
|
|
|
|
ServerName: "matrix.org",
|
|
|
|
Keys: []config.KeyPerspectiveTrustKey{
|
|
|
|
{
|
|
|
|
KeyID: "ed25519:auto",
|
|
|
|
PublicKey: "Noi6WqcDj0QmPxCNQqgezwTlBKrfqehY1u2FyWP9uYw",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
KeyID: "ed25519:a_RXGa",
|
|
|
|
PublicKey: "l8Hft5qXKn1vfHrg3p4+W8gELQVo8N13JkluMfmn2sQ",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
cfg.MediaAPI.ThumbnailSizes = []config.ThumbnailSize{
|
|
|
|
{
|
|
|
|
Width: 32,
|
|
|
|
Height: 32,
|
|
|
|
ResizeMethod: "crop",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Width: 96,
|
|
|
|
Height: 96,
|
|
|
|
ResizeMethod: "crop",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Width: 640,
|
|
|
|
Height: 480,
|
|
|
|
ResizeMethod: "scale",
|
|
|
|
},
|
|
|
|
}
|
2020-08-10 15:18:04 +02:00
|
|
|
|
2020-09-03 11:12:11 +02:00
|
|
|
if *defaultsForCI {
|
2021-03-05 11:40:27 +01:00
|
|
|
cfg.AppServiceAPI.DisableTLSValidation = true
|
2020-09-03 11:12:11 +02:00
|
|
|
cfg.ClientAPI.RateLimiting.Enabled = false
|
2022-02-01 17:36:17 +01:00
|
|
|
cfg.FederationAPI.DisableTLSValidation = false
|
2021-11-24 11:45:23 +01:00
|
|
|
// don't hit matrix.org when running tests!!!
|
|
|
|
cfg.FederationAPI.KeyPerspectives = config.KeyPerspectives{}
|
2021-01-22 17:08:47 +01:00
|
|
|
cfg.MSCs.MSCs = []string{"msc2836", "msc2946", "msc2444", "msc2753"}
|
2020-12-04 15:11:01 +01:00
|
|
|
cfg.Logging[0].Level = "trace"
|
2022-01-26 13:23:27 +01:00
|
|
|
cfg.Logging[0].Type = "std"
|
2021-03-08 14:19:02 +01:00
|
|
|
cfg.UserAPI.BCryptCost = bcrypt.MinCost
|
2022-01-05 18:44:49 +01:00
|
|
|
cfg.Global.JetStream.InMemory = true
|
2022-02-17 11:59:44 +01:00
|
|
|
cfg.ClientAPI.RegistrationSharedSecret = "complement"
|
2020-09-03 11:12:11 +02:00
|
|
|
}
|
|
|
|
|
2020-08-10 15:18:04 +02:00
|
|
|
j, err := yaml.Marshal(cfg)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(string(j))
|
|
|
|
}
|