diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-27 10:44:28 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-27 10:44:28 +0100 |
commit | be9278ab026fed34743487ee8305541933e7ae6f (patch) | |
tree | e6c4fc24c05cc3bd658f97cc5dbb3254d86deb2c | |
parent | 7fa2842f5d49e87acf92bcfb3602c52bf482258e (diff) | |
download | easybridge-be9278ab026fed34743487ee8305541933e7ae6f.tar.gz easybridge-be9278ab026fed34743487ee8305541933e7ae6f.zip |
Remove accounts from config file; add log level
-rw-r--r-- | main.go | 42 |
1 files changed, 15 insertions, 27 deletions
@@ -5,12 +5,8 @@ import ( "encoding/hex" "encoding/json" "flag" - "fmt" - _ "fmt" "io/ioutil" "os" - _ "strings" - _ "time" log "github.com/sirupsen/logrus" "gopkg.in/yaml.v2" @@ -18,20 +14,15 @@ import ( "git.deuxfleurs.fr/Deuxfleurs/easybridge/mxlib" ) -type ConfigAccount struct { - Protocol string `json:"protocol"` - Config map[string]string `json:"config"` -} - type ConfigFile struct { - ASBindAddr string `json:"appservice_bind_addr"` - WebBindAddr string `json:"web_bind_addr"` - Registration string `json:"registration"` - Server string `json:"homeserver_url"` - DbType string `json:"db_type"` - DbPath string `json:"db_path"` - MatrixDomain string `json:"matrix_domain"` - Accounts map[string]map[string]ConfigAccount `json:"accounts"` + LogLevel string `json:"log_level"` + ASBindAddr string `json:"appservice_bind_addr"` + WebBindAddr string `json:"web_bind_addr"` + Registration string `json:"registration"` + Server string `json:"homeserver_url"` + DbType string `json:"db_type"` + DbPath string `json:"db_path"` + MatrixDomain string `json:"matrix_domain"` } var configFlag = flag.String("config", "./config.json", "Configuration file path") @@ -41,13 +32,13 @@ var registration *mxlib.Registration func readConfig() ConfigFile { config_file := ConfigFile{ + LogLevel: "info", ASBindAddr: "0.0.0.0:8321", WebBindAddr: "0.0.0.0:8281", Registration: "./registration.yaml", Server: "http://localhost:8008", DbType: "sqlite3", DbPath: "easybridge.db", - Accounts: map[string]map[string]ConfigAccount{}, } _, err := os.Stat(*configFlag) @@ -152,13 +143,17 @@ func readRegistration(file string) mxlib.Registration { } func main() { - log.SetLevel(log.DebugLevel) - flag.Parse() config_file := readConfig() config = &config_file + log_level, err := log.ParseLevel(config.LogLevel) + if err != nil { + log.Fatal(err) + } + log.SetLevel(log_level) + reg_file := readRegistration(config.Registration) registration = ®_file @@ -169,13 +164,6 @@ func main() { StartWeb() - for user, accounts := range config.Accounts { - mxid := fmt.Sprintf("@%s:%s", user, config.MatrixDomain) - for name, params := range accounts { - SetAccount(mxid, name, params.Protocol, params.Config) - } - } - err = <-errch if err != nil { log.Fatal(err) |