This repository was archived by the owner on Feb 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathconfig.go
More file actions
51 lines (42 loc) · 1.4 KB
/
config.go
File metadata and controls
51 lines (42 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package pufferd
import (
"github.com/spf13/viper"
"strings"
)
func init() {
//env configuration
viper.SetEnvPrefix("PUFFERPANEL")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()
}
func SetDefaults() {
//defaults we can set at this point in time
viper.SetDefault("console.buffer", 50)
viper.SetDefault("console.forward", false)
viper.SetDefault("listen.web", "0.0.0.0:5656")
//viper.SetDefault("listen.socket", "unix:/var/run/pufferd.sock")
viper.SetDefault("listen.webCert", "https.pem")
viper.SetDefault("listen.webKey", "https.key")
viper.SetDefault("listen.sftp", "0.0.0.0:5657")
viper.SetDefault("listen.sftpKey", "sftp.key")
viper.SetDefault("auth.publicKey", "panel.pem")
viper.SetDefault("auth.url", "http://localhost:8080")
viper.SetDefault("auth.clientId", "")
viper.SetDefault("auth.clientSecret", "")
viper.SetDefault("data.cache", "cache")
viper.SetDefault("data.servers", "servers")
viper.SetDefault("data.modules", "modules")
viper.SetDefault("data.logs", "logs")
viper.SetDefault("data.crashLimit", 3)
viper.SetDefault("data.maxWSDownloadSize", int64(1024*1024*20)) //1024 bytes (1KB) * 1024 (1MB) * 50 (50MB))
}
func LoadConfig() error {
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
//this is just a missing config, since ENV is supported, ignore
} else {
return err
}
}
return nil
}