2020-01-25 17:43:02 +00:00
|
|
|
package settings
|
2013-07-23 11:10:38 +00:00
|
|
|
|
|
|
|
import (
|
2013-07-26 10:54:19 +00:00
|
|
|
"strconv"
|
2013-07-23 11:10:38 +00:00
|
|
|
)
|
|
|
|
|
2020-01-25 17:43:02 +00:00
|
|
|
type HostsSettings struct {
|
|
|
|
HostsFile string `toml:"host-file" env:"HOSTS_FILE"`
|
|
|
|
RedisEnable bool `toml:"redis-enable" env:"REDIS_HOSTS_ENABLE"`
|
|
|
|
RedisKey string `toml:"redis-key" env:"REDIS_HOSTS_KEY"`
|
|
|
|
TTL uint32 `toml:"ttl" env:"HOSTS_TTL"`
|
|
|
|
RefreshInterval uint32 `toml:"refresh-interval" env:"HOSTS_REFRESH_INTERVAL"`
|
2015-10-13 11:33:51 +00:00
|
|
|
}
|
|
|
|
|
2013-07-23 11:10:38 +00:00
|
|
|
type Settings struct {
|
2018-08-05 08:48:26 +00:00
|
|
|
Version string `toml:"version"`
|
|
|
|
Debug bool `toml:"debug"`
|
2013-07-23 11:10:38 +00:00
|
|
|
Server DNSServerSettings `toml:"server"`
|
|
|
|
ResolvConfig ResolvSettings `toml:"resolv"`
|
|
|
|
Redis RedisSettings `toml:"redis"`
|
2016-02-12 13:29:25 +00:00
|
|
|
Memcache MemcacheSettings `toml:"memcache"`
|
2013-07-23 11:10:38 +00:00
|
|
|
Log LogSettings `toml:"log"`
|
|
|
|
Cache CacheSettings `toml:"cache"`
|
2013-07-26 04:06:16 +00:00
|
|
|
Hosts HostsSettings `toml:"hosts"`
|
2013-07-23 11:10:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ResolvSettings struct {
|
2018-08-05 08:48:26 +00:00
|
|
|
Timeout int `toml:"timeout" env:"RESOLV_TIMEOUT"`
|
|
|
|
Interval int `toml:"interval" env:"RESOLV_INTERVAL"`
|
|
|
|
SetEDNS0 bool `toml:"setedns0" env:"RESOLV_EDNS0"`
|
2020-01-25 18:48:26 +00:00
|
|
|
ServerListFile []string `toml:"server-list-file" env:"SERVER_LIST_FILE"`
|
2018-08-05 03:53:11 +00:00
|
|
|
ResolvFile string `toml:"resolv-file" env:"RESOLV_FILE"`
|
2013-07-23 11:10:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type DNSServerSettings struct {
|
2018-08-05 03:53:11 +00:00
|
|
|
Host string `toml:"host" env:"SERVER_BIND"`
|
|
|
|
Port int `toml:"port" env:"SERVER_PORT"`
|
2013-07-23 11:10:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type RedisSettings struct {
|
2018-08-05 03:53:11 +00:00
|
|
|
Host string `toml:"host" env:"REDIS_HOST"`
|
|
|
|
Port int `toml:"port" env:"REDIS_PORT"`
|
|
|
|
DB int `toml:"db" env:"REDIS_DB"`
|
|
|
|
Password string `toml:"password" env:"REDIS_PASSWORD"`
|
2013-07-23 11:10:38 +00:00
|
|
|
}
|
|
|
|
|
2016-02-12 13:29:25 +00:00
|
|
|
type MemcacheSettings struct {
|
2018-08-05 03:53:11 +00:00
|
|
|
Servers []string `toml:"servers" env:"MEMCACHE_SERVERS"`
|
2016-02-12 13:29:25 +00:00
|
|
|
}
|
|
|
|
|
2013-07-26 10:54:19 +00:00
|
|
|
func (s RedisSettings) Addr() string {
|
|
|
|
return s.Host + ":" + strconv.Itoa(s.Port)
|
|
|
|
}
|
|
|
|
|
2013-07-23 11:10:38 +00:00
|
|
|
type LogSettings struct {
|
2018-08-05 08:48:26 +00:00
|
|
|
Stdout bool `toml:"stdout" env:"LOG_STDOUT"`
|
2018-08-05 04:12:28 +00:00
|
|
|
File string `toml:"file" env:"LOG_FILE"`
|
|
|
|
Level string `toml:"level" env:"LOG_LEVEL"`
|
2015-10-13 11:33:51 +00:00
|
|
|
}
|
|
|
|
|
2013-07-23 11:10:38 +00:00
|
|
|
type CacheSettings struct {
|
2018-08-05 03:53:11 +00:00
|
|
|
Backend string `toml:"backend" env:"CACHE_BACKEND"`
|
|
|
|
Expire int `toml:"expire" env:"CACHE_EXPIRE"`
|
|
|
|
Maxcount int `toml:"maxcount" env:"CACHE_MAX_COUNT"`
|
|
|
|
}
|