2014-01-09 06:42:05 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
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"`
|
2016-11-19 16:37:22 +00:00
|
|
|
DBName string `json:"db_name"`
|
2016-01-19 03:13:32 +00:00
|
|
|
DBPath string `json:"db_path"`
|
2016-11-19 16:37:22 +00:00
|
|
|
MigrationsPath string `json:"migrations_prefix"`
|
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
|
|
|
|
2016-08-06 23:58:34 +00:00
|
|
|
// Version contains the current gophish version
|
2017-03-02 02:12:32 +00:00
|
|
|
var Version = "0.3"
|
2016-08-06 23:58:34 +00:00
|
|
|
|
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)
|
2016-11-19 16:37:22 +00:00
|
|
|
// Choosing the migrations directory based on the database used.
|
|
|
|
Conf.MigrationsPath = Conf.MigrationsPath + Conf.DBName
|
2014-01-09 06:42:05 +00:00
|
|
|
}
|