forked from pufferpanel/pufferpanel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
81 lines (71 loc) · 2.71 KB
/
config.go
File metadata and controls
81 lines (71 loc) · 2.71 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
Copyright 2020 Padduck, LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package pufferpanel
import (
"github.com/spf13/viper"
"strings"
)
func init() {
viper.SetEnvPrefix("PUFFER")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()
viper.SetConfigName("config")
viper.AddConfigPath("/etc/pufferpanel/")
viper.AddConfigPath(".")
//global settings
viper.SetDefault("logs", "logs")
viper.SetDefault("web.host", "0.0.0.0:8080")
viper.SetDefault("token.private", "private.pem")
viper.SetDefault("token.public", "public.pem")
//panel specific settings
viper.SetDefault("panel.enable", true)
viper.SetDefault("panel.database.session", 60)
viper.SetDefault("panel.database.dialect", "sqlite3")
//viper.SetDefault("panel.database.url", "file:pufferpanel.db?cache=shared")
viper.SetDefault("panel.database.log", false)
viper.SetDefault("panel.web.files", "www")
viper.SetDefault("panel.email.templates", "email/emails.json")
viper.SetDefault("panel.email.provider", "")
viper.SetDefault("panel.email.from", "")
viper.SetDefault("panel.email.domain", "")
viper.SetDefault("panel.email.key", "")
viper.SetDefault("panel.settings.companyName", "PufferPanel")
viper.SetDefault("panel.settings.defaultTheme", "PufferPanel")
viper.SetDefault("panel.settings.masterUrl", "http://localhost:8080")
//daemon specific settings
viper.SetDefault("daemon.enable", true)
viper.SetDefault("daemon.console.buffer", 50)
viper.SetDefault("daemon.console.forward", false)
viper.SetDefault("daemon.sftp.host", "0.0.0.0:5657")
viper.SetDefault("daemon.sftp.key", "sftp.key")
viper.SetDefault("daemon.auth.url", "http://localhost:8080")
viper.SetDefault("daemon.auth.clientId", "")
viper.SetDefault("daemon.auth.clientSecret", "")
viper.SetDefault("daemon.data.cache", "cache")
viper.SetDefault("daemon.data.servers", "servers")
viper.SetDefault("daemon.data.modules", "modules")
viper.SetDefault("daemon.data.crashLimit", 3)
viper.SetDefault("daemon.data.maxWSDownloadSize", int64(1024 * 1024 * 20))
}
func LoadConfig(path string) error {
if path != "" {
viper.SetConfigFile(path)
}
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
} else {
return err
}
}
return nil
}