add config ssl file check

This commit is contained in:
Jay 2019-06-30 10:12:00 +00:00
parent c1f0ae6b9b
commit 45c8fc4f0e
2 changed files with 22 additions and 2 deletions

12
main.go
View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"dorisbot/pkg/config"
"dorisbot/pkg/options" "dorisbot/pkg/options"
"dorisbot/pkg/svc/discord" "dorisbot/pkg/svc/discord"
"fmt" "fmt"
@ -12,6 +13,7 @@ func init() {
} }
func main() { func main() {
var err error
opts := options.GetOptions() opts := options.GetOptions()
if opts.Help { if opts.Help {
opts.ShowUsage() opts.ShowUsage()
@ -20,9 +22,15 @@ func main() {
fmt.Println("Bot Svc") fmt.Println("Bot Svc")
cc := make(chan bool) cc := make(chan bool)
botToken := "NDEyNTEzNzk2OTA1NTAwNjcy.XQ-Shw.sS-Ldtu1fgCaPPNG_Bn3i0LX2wg"
client, err := discord.NewClient(botToken) err = config.LoadConfig(opts.Config)
if err != nil {
log.Fatal(err)
}
conf := config.GetConfig()
client, err := discord.NewClient(conf.Discord.BotToken)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -76,5 +76,17 @@ func LoadConfig(p ...string) (err error) {
return err return err
} }
if exists := utils.CheckExists(conf.Database.SSLCa, false); !exists {
return errors.New("ssl ca file not exists")
}
if exists := utils.CheckExists(conf.Database.SSLCrt, false); !exists {
return errors.New("ssl crt file not exists")
}
if exists := utils.CheckExists(conf.Database.SSLKey, false); !exists {
return errors.New("ssl key file not exists")
}
return return
} }