2017-06-18 22:01:44 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config contains the configuration of the Pterodactyl Daemon
|
|
|
|
type Config struct {
|
2017-06-27 08:42:19 +00:00
|
|
|
// Debug enables debug mode
|
|
|
|
Debug bool `mapstructure:"debug"`
|
2017-06-18 22:01:44 +00:00
|
|
|
|
2017-06-19 14:15:28 +00:00
|
|
|
// Web contains the settings of the api webserver
|
|
|
|
Web struct {
|
2017-06-26 09:07:53 +00:00
|
|
|
// ListenHost is the host address to bind the api webserver to
|
|
|
|
ListenHost string `mapstructure:"host"`
|
2017-06-19 14:15:28 +00:00
|
|
|
// ListenPort is the port to bind the api webserver to
|
2017-06-26 09:07:53 +00:00
|
|
|
ListenPort int16 `mapstructure:"port"`
|
2017-06-19 14:15:28 +00:00
|
|
|
|
|
|
|
// SSL contains https configuration for the api webserver
|
|
|
|
SSL struct {
|
|
|
|
// Enabled allows to enable or disable ssl
|
2017-06-26 09:07:53 +00:00
|
|
|
Enabled bool `mapstructure:"enabled"`
|
2017-06-19 14:20:58 +00:00
|
|
|
// GenerateLetsEncrypt
|
2017-06-26 09:07:53 +00:00
|
|
|
GenerateLetsEncrypt bool `mapstructure:"GenerateLetsEncrypt"`
|
2017-06-19 14:15:28 +00:00
|
|
|
// Certificate is the certificate file path to use
|
2017-06-26 09:07:53 +00:00
|
|
|
Certificate string `mapstructure:"certificate"`
|
2017-06-19 14:15:28 +00:00
|
|
|
// Key is the path to the private key for the certificate
|
2017-06-26 09:07:53 +00:00
|
|
|
Key string `mapstructure:"key"`
|
|
|
|
} `mapstructure:"ssl"`
|
2017-06-19 14:15:28 +00:00
|
|
|
|
|
|
|
// Uploads contains file upload configuration
|
|
|
|
Uploads struct {
|
|
|
|
// MaximumSize is the maximum file upload size
|
2017-06-26 09:07:53 +00:00
|
|
|
MaximumSize int64 `mapstructure:"maximumSize"`
|
|
|
|
} `mapstructure:"uploads"`
|
|
|
|
} `mapstructure:"web"`
|
2017-06-19 14:15:28 +00:00
|
|
|
|
|
|
|
// Docker contains docker related configuration
|
|
|
|
Docker struct {
|
|
|
|
// Socket is the path to the docker control socket
|
2017-06-26 09:07:53 +00:00
|
|
|
Socket string `mapstructure:"socket"`
|
2017-06-19 14:15:28 +00:00
|
|
|
// AutoupdateImages allows to disable automatic Image updates
|
2017-06-26 09:07:53 +00:00
|
|
|
AutoupdateImages bool `mapstructure:"autoupdateImages"`
|
2017-06-19 14:15:28 +00:00
|
|
|
// NetworkInterface is the interface for the pterodactyl network
|
2017-06-26 09:07:53 +00:00
|
|
|
NetworkInterface string `mapstructure:"networkInterface"`
|
2017-06-19 14:15:28 +00:00
|
|
|
// TimezonePath is the path to the timezone file to mount in the containers
|
2017-06-26 09:07:53 +00:00
|
|
|
TimezonePath string `mapstructure:"timezonePath"`
|
|
|
|
} `mapstructure:"docker"`
|
2017-06-19 14:15:28 +00:00
|
|
|
|
|
|
|
// Sftp contains information on the integrated sftp server
|
|
|
|
Sftp struct {
|
|
|
|
// Path is the base path of the sftp server
|
2017-06-26 09:07:53 +00:00
|
|
|
Path string `mapstructure:"path"`
|
2017-06-19 14:15:28 +00:00
|
|
|
// Port is the port to bind the sftp server to
|
2017-06-26 09:07:53 +00:00
|
|
|
Port int16 `mapstructure:"port"`
|
|
|
|
} `mapstructure:"sftp"`
|
2017-06-19 14:15:28 +00:00
|
|
|
|
|
|
|
// Query contains parameters related to queriying of running gameservers
|
|
|
|
Query struct {
|
2017-06-26 09:07:53 +00:00
|
|
|
KillOnFail bool `mapstructure:"killOnFail"`
|
|
|
|
FailLimit bool `mapstructure:"failLimit"`
|
|
|
|
} `mapstructure:"query"`
|
2017-06-19 14:15:28 +00:00
|
|
|
|
|
|
|
// Remote is the url of the panel
|
2017-06-26 09:07:53 +00:00
|
|
|
Remote string `mapstructure:"remote"`
|
2017-06-19 14:15:28 +00:00
|
|
|
|
2017-06-18 22:01:44 +00:00
|
|
|
// Log contains configuration related to logging
|
|
|
|
Log struct {
|
2017-06-19 14:15:28 +00:00
|
|
|
// Path is the folder where logfiles should be stored
|
2017-06-26 09:07:53 +00:00
|
|
|
Path string `mapstructure:"path"`
|
2017-06-19 14:15:28 +00:00
|
|
|
// Level is the preferred log level
|
2017-06-27 08:42:19 +00:00
|
|
|
// It is overriden to debug when debug mode is enabled
|
2017-06-26 09:07:53 +00:00
|
|
|
Level string `mapstructure:"level"`
|
2017-06-18 22:01:44 +00:00
|
|
|
|
|
|
|
// DeleteAfterDays is the time in days after which logfiles are deleted
|
|
|
|
// If set to <= 0 logs are kept forever
|
2017-06-26 09:07:53 +00:00
|
|
|
DeleteAfterDays int `mapstructure:"deleteAfterDays"`
|
|
|
|
} `mapstructure:"log"`
|
2017-06-18 22:01:44 +00:00
|
|
|
}
|
|
|
|
|
2017-06-26 09:07:53 +00:00
|
|
|
var config *Config
|
|
|
|
|
2017-06-26 19:04:11 +00:00
|
|
|
func LoadConfiguration(path *string) error {
|
|
|
|
if path != nil {
|
|
|
|
viper.SetConfigFile(*path)
|
|
|
|
} else {
|
|
|
|
viper.AddConfigPath("./")
|
|
|
|
viper.SetConfigName("config")
|
|
|
|
}
|
|
|
|
|
2017-06-18 22:01:44 +00:00
|
|
|
// Find and read the config file
|
|
|
|
if err := viper.ReadInConfig(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-06-26 09:07:53 +00:00
|
|
|
config = new(Config)
|
|
|
|
if err := viper.Unmarshal(config); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-06-18 22:01:44 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2017-06-26 09:07:53 +00:00
|
|
|
// Get returns the configuration
|
|
|
|
func Get() *Config {
|
|
|
|
return config
|
|
|
|
}
|
|
|
|
|
2017-06-18 22:01:44 +00:00
|
|
|
func setDefaults() {
|
|
|
|
|
|
|
|
}
|