2014-01-09 06:42:05 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
2014-07-06 03:57:17 +00:00
|
|
|
// SMTPServer represents the SMTP configuration details
|
2014-03-25 03:31:33 +00:00
|
|
|
type SMTPServer struct {
|
|
|
|
Host string `json:"host"`
|
|
|
|
User string `json:"user"`
|
|
|
|
Password string `json:"password"`
|
|
|
|
}
|
|
|
|
|
2016-01-17 16:45:13 +00:00
|
|
|
// AdminServer represents the Admin server configuration details
|
|
|
|
type AdminServer struct {
|
|
|
|
ListenURL string `json:"listen_url"`
|
|
|
|
UseTLS bool `json:"use_tls"`
|
|
|
|
CertPath string `json:"cert_path"`
|
|
|
|
KeyPath string `json:"key_path"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// PhishServer represents the Phish server configuration details
|
|
|
|
type PhishServer struct {
|
|
|
|
ListenURL string `json:"listen_url"`
|
|
|
|
UseTLS bool `json:"use_tls"`
|
|
|
|
CertPath string `json:"cert_path"`
|
|
|
|
KeyPath string `json:"key_path"`
|
|
|
|
}
|
|
|
|
|
2014-03-25 03:31:33 +00:00
|
|
|
// Config represents the configuration information.
|
|
|
|
type Config struct {
|
2016-01-19 03:13:32 +00:00
|
|
|
AdminConf AdminServer `json:"admin_server"`
|
|
|
|
PhishConf PhishServer `json:"phish_server"`
|
|
|
|
SMTPConf SMTPServer `json:"smtp"`
|
|
|
|
DBPath string `json:"db_path"`
|
|
|
|
MigrationsPath string `json:"migrations_path"`
|
2014-03-25 03:31:33 +00:00
|
|
|
}
|
|
|
|
|
2016-01-25 02:47:16 +00:00
|
|
|
// Conf contains the initialized configuration struct
|
2014-03-25 03:31:33 +00:00
|
|
|
var Conf Config
|
2014-01-09 06:42:05 +00:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
// Get the config file
|
|
|
|
config_file, err := ioutil.ReadFile("./config.json")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("File error: %v\n", err)
|
|
|
|
}
|
|
|
|
json.Unmarshal(config_file, &Conf)
|
|
|
|
}
|