-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
76 lines (61 loc) · 1.7 KB
/
config.go
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
package main
type ConfigSite struct {
Listen string `toml:"listen"`
Host string `toml:"host"`
Storage string `toml:"storage"`
Static string `toml:"static"`
BodySize uint64 `toml:"body_size"`
MaxList uint64 `toml:"max_list"`
AvatarSize uint64 `toml:"avatar_size"`
PreviewSize uint64 `toml:"preview_size"`
MaxSize uint64 `toml:"max_size"`
AvifThreshold uint64 `toml:"avif_threshold"`
Debug bool `toml:"debug"`
Thread uint64 `toml:"thread"`
WriteLog bool `toml:"write_log"`
LogFile string `toml:"log_file"`
ReadOnly bool `toml:"read_only"`
}
type ConfigDatabase struct {
MongoUri string `toml:"mongo_uri"`
DBName string `toml:"db_name"`
}
type ConfigSecurity struct {
Salt string `toml:"salt"`
HMAC string `toml:"hmac"`
AdminPassword string `toml:"admin_password"`
RecaptchaKey string `toml:"recaptcha_key"`
}
type ConfigHTTPS struct {
Cert string `toml:"cert"`
Key string `toml:"key"`
Promote bool `toml:"promote"`
}
type Config struct {
Site ConfigSite `toml:"site"`
DB ConfigDatabase `toml:"database"`
Security ConfigSecurity `toml:"security"`
HTTPS ConfigHTTPS `toml:"https"`
}
func (c *Config) SetDefault() {
c.Site.Listen = ":8080"
c.Site.Host = "localhost"
c.Site.Storage = "./storage"
c.Site.Static = "./static"
c.Site.BodySize = 52428800
c.Site.MaxList = 100
c.Site.AvatarSize = 256
c.Site.PreviewSize = 256
c.Site.MaxSize = 8192
c.Site.AvifThreshold = 100
c.Site.WriteLog = false
c.DB.MongoUri = "mongodb://localhost:27017"
c.DB.DBName = "image"
c.Security.Salt = "salt"
c.Security.HMAC = "hmac"
c.Security.AdminPassword = "adminadmin"
c.Security.RecaptchaKey = "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe"
c.HTTPS.Cert = ""
c.HTTPS.Key = ""
c.HTTPS.Promote = false
}