2019-09-01 20:59:51 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-ini/ini"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
//Configuration Struct
|
|
|
|
type Configuration struct {
|
|
|
|
AdminPassword string
|
|
|
|
Interface string
|
|
|
|
DBFile string
|
|
|
|
Mode int
|
2019-09-04 20:11:13 +00:00
|
|
|
OpenWindows bool
|
2019-09-04 20:59:33 +00:00
|
|
|
OpenBrowser bool
|
2019-09-14 17:15:41 +00:00
|
|
|
SaveMetrics bool
|
2019-09-01 20:59:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var siteConf = &Configuration{}
|
|
|
|
|
2019-09-05 19:35:07 +00:00
|
|
|
// InitConfig parses the config and maps out values
|
2019-09-01 20:59:51 +00:00
|
|
|
func InitConfig() {
|
2019-09-02 20:19:49 +00:00
|
|
|
err := ini.MapTo(siteConf, "./config.ini")
|
2019-09-01 20:59:51 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-05 19:35:07 +00:00
|
|
|
// GetConfig returns the full config
|
2019-09-01 20:59:51 +00:00
|
|
|
func GetConfig() *Configuration {
|
|
|
|
return siteConf
|
|
|
|
}
|
|
|
|
|
2019-09-05 19:35:07 +00:00
|
|
|
// GetMode returns the mode
|
2019-09-01 20:59:51 +00:00
|
|
|
func GetMode() int {
|
|
|
|
return siteConf.Mode
|
|
|
|
}
|
|
|
|
|
2019-09-05 19:35:07 +00:00
|
|
|
// GetInterface returns the interface the server listens on
|
2019-09-01 20:59:51 +00:00
|
|
|
func GetInterface() string {
|
|
|
|
return siteConf.Interface
|
|
|
|
}
|
|
|
|
|
2019-09-05 19:35:07 +00:00
|
|
|
// GetAdminPassword returns the admin password
|
2019-09-01 20:59:51 +00:00
|
|
|
func GetAdminPassword() string {
|
|
|
|
return siteConf.AdminPassword
|
|
|
|
}
|
|
|
|
|
2019-09-05 19:35:07 +00:00
|
|
|
// GetDBFile returns the path to the db file
|
2019-09-01 20:59:51 +00:00
|
|
|
func GetDBFile() string {
|
|
|
|
return siteConf.DBFile
|
|
|
|
}
|
2019-09-04 20:11:13 +00:00
|
|
|
|
2019-09-05 19:35:07 +00:00
|
|
|
// GetOpenWindows returns whether to open electron windows or not
|
2019-09-04 20:11:13 +00:00
|
|
|
func GetOpenWindows() bool {
|
|
|
|
return siteConf.OpenWindows
|
|
|
|
}
|
2019-09-04 20:59:33 +00:00
|
|
|
|
2019-09-05 19:35:07 +00:00
|
|
|
// GetOpenBrowser returns whether to open browser windows or not
|
2019-09-04 20:59:33 +00:00
|
|
|
func GetOpenBrowser() bool {
|
|
|
|
return siteConf.OpenBrowser
|
|
|
|
}
|
2019-09-14 17:15:41 +00:00
|
|
|
|
|
|
|
// GetSaveMetrics returns whether to use metrics or not
|
|
|
|
func GetSaveMetrics() bool {
|
|
|
|
return siteConf.SaveMetrics
|
|
|
|
}
|