Don't ignore config flag for yggdrasil demo if set

Signed-off-by: bn4t <me@bn4t.me>
This commit is contained in:
bn4t 2021-12-07 16:11:36 +01:00 committed by bn4t
parent 61406a6747
commit b2cf2acd9d

View file

@ -19,8 +19,10 @@ import (
"crypto/tls" "crypto/tls"
"flag" "flag"
"fmt" "fmt"
"github.com/matrix-org/gomatrixserverlib"
"net" "net"
"net/http" "net/http"
"os"
"time" "time"
"github.com/gorilla/mux" "github.com/gorilla/mux"
@ -42,8 +44,6 @@ import (
"github.com/matrix-org/dendrite/setup/config" "github.com/matrix-org/dendrite/setup/config"
"github.com/matrix-org/dendrite/setup/mscs" "github.com/matrix-org/dendrite/setup/mscs"
"github.com/matrix-org/dendrite/userapi" "github.com/matrix-org/dendrite/userapi"
"github.com/matrix-org/gomatrixserverlib"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
@ -72,7 +72,21 @@ func main() {
} }
*/ */
// iterate through the cli args and check if the config flag was set
configFlagSet := false
for _, arg := range os.Args {
if arg == "--config" || arg == "-config" {
configFlagSet = true
break
}
}
cfg := &config.Dendrite{} cfg := &config.Dendrite{}
// use custom config if config flag is set
if configFlagSet {
cfg = setup.ParseFlags(true)
} else {
cfg.Defaults(true) cfg.Defaults(true)
cfg.Global.ServerName = gomatrixserverlib.ServerName(ygg.DerivedServerName()) cfg.Global.ServerName = gomatrixserverlib.ServerName(ygg.DerivedServerName())
cfg.Global.PrivateKey = ygg.PrivateKey() cfg.Global.PrivateKey = ygg.PrivateKey()
@ -92,6 +106,7 @@ func main() {
if err = cfg.Derive(); err != nil { if err = cfg.Derive(); err != nil {
panic(err) panic(err)
} }
}
base := base.NewBaseDendrite(cfg, "Monolith") base := base.NewBaseDendrite(cfg, "Monolith")
defer base.Close() // nolint: errcheck defer base.Close() // nolint: errcheck