Remove accounts from config file; add log level
This commit is contained in:
parent
7fa2842f5d
commit
be9278ab02
1 changed files with 15 additions and 27 deletions
28
main.go
28
main.go
|
@ -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,12 +14,8 @@ import (
|
|||
"git.deuxfleurs.fr/Deuxfleurs/easybridge/mxlib"
|
||||
)
|
||||
|
||||
type ConfigAccount struct {
|
||||
Protocol string `json:"protocol"`
|
||||
Config map[string]string `json:"config"`
|
||||
}
|
||||
|
||||
type ConfigFile struct {
|
||||
LogLevel string `json:"log_level"`
|
||||
ASBindAddr string `json:"appservice_bind_addr"`
|
||||
WebBindAddr string `json:"web_bind_addr"`
|
||||
Registration string `json:"registration"`
|
||||
|
@ -31,7 +23,6 @@ type ConfigFile struct {
|
|||
DbType string `json:"db_type"`
|
||||
DbPath string `json:"db_path"`
|
||||
MatrixDomain string `json:"matrix_domain"`
|
||||
Accounts map[string]map[string]ConfigAccount `json:"accounts"`
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue