Skip to content
Snippets Groups Projects
Commit 764306e4 authored by Josh Brooks's avatar Josh Brooks
Browse files

Add banned user list config to load on start

parent 01825dce
No related branches found
No related tags found
4 merge requests!50Revert "update deps",!48Release,!42Add username field to users table for raw username,!41Xx 3692/banned users
...@@ -45,6 +45,11 @@ func InitParams(vip *viper.Viper) params.General { ...@@ -45,6 +45,11 @@ func InitParams(vip *viper.Viper) params.General {
jww.FATAL.Fatalf("Failed to read session path: %+v", err) jww.FATAL.Fatalf("Failed to read session path: %+v", err)
} }
bannedUserList, err := utils.ReadFile(viper.GetString("bannedUserList"))
if err != nil {
jww.WARN.Printf("Failed to read banned user list: %v", err)
}
// Only require proto user path if session does not exist // Only require proto user path if session does not exist
var protoUserJson []byte var protoUserJson []byte
protoUserPath := "" protoUserPath := ""
...@@ -105,5 +110,6 @@ func InitParams(vip *viper.Viper) params.General { ...@@ -105,5 +110,6 @@ func InitParams(vip *viper.Viper) params.General {
IO: ioparams, IO: ioparams,
Twilio: twilioparams, Twilio: twilioparams,
ProtoUserJson: protoUserJson, ProtoUserJson: protoUserJson,
BannedUserList: string(bannedUserList),
} }
} }
...@@ -19,6 +19,7 @@ import ( ...@@ -19,6 +19,7 @@ import (
"gitlab.com/xx_network/primitives/ndf" "gitlab.com/xx_network/primitives/ndf"
"gitlab.com/xx_network/primitives/utils" "gitlab.com/xx_network/primitives/utils"
"os" "os"
"strings"
"time" "time"
) )
...@@ -42,7 +43,16 @@ var rootCmd = &cobra.Command{ ...@@ -42,7 +43,16 @@ var rootCmd = &cobra.Command{
initConfig() initConfig()
initLog() initLog()
p := InitParams(viper.GetViper()) p := InitParams(viper.GetViper())
storage, err := storage.NewStorage(p.DbUsername, p.DbPassword, p.DbName, p.DbAddress, p.DbPort)
bannedUsers := make(map[string]struct{})
if p.BannedUserList != "" {
bannedUserList := strings.Split(p.BannedUserList, ",")
for _, bannedUser := range bannedUserList {
bannedUsers[bannedUser] = struct{}{}
}
}
storage, err := storage.NewStorage(p.DbUsername, p.DbPassword, p.DbName, p.DbAddress, p.DbPort, bannedUsers)
if err != nil { if err != nil {
jww.FATAL.Panicf("Failed to initialize storage interface: %+v", err) jww.FATAL.Panicf("Failed to initialize storage interface: %+v", err)
} }
......
...@@ -13,6 +13,7 @@ type General struct { ...@@ -13,6 +13,7 @@ type General struct {
ProtoUserJson []byte ProtoUserJson []byte
Ndf string Ndf string
PermCert []byte PermCert []byte
BannedUserList string
Database Database
IO IO
......
...@@ -10,3 +10,5 @@ dbUsername: "" ...@@ -10,3 +10,5 @@ dbUsername: ""
dbPassword: "" dbPassword: ""
dbName: "" dbName: ""
dbAddress: "" dbAddress: ""
bannedUserList: "bannedUserList.csv"
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment