mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-01-13 02:22:48 +01:00
Add configuration cache size and other parameters
This commit is contained in:
parent
b60c728067
commit
99c5273e3a
@ -19,6 +19,10 @@ type Config struct {
|
||||
CertRefreshDelay int `toml:"cert_refresh_delay"`
|
||||
BlockIPv6 bool `toml:"block_ipv6"`
|
||||
Cache bool
|
||||
CacheSize int `toml:"cache_size"`
|
||||
CacheNegTTL uint32 `toml:"cache_neg_ttl"`
|
||||
CacheMinTTL uint32 `toml:"cache_min_ttl"`
|
||||
CacheMaxTTL uint32 `toml:"cache_max_ttl"`
|
||||
ServersConfig map[string]ServerConfig `toml:"servers"`
|
||||
}
|
||||
|
||||
@ -27,6 +31,11 @@ func newConfig() Config {
|
||||
ListenAddresses: []string{"127.0.0.1:53"},
|
||||
Timeout: 2500,
|
||||
CertRefreshDelay: 30,
|
||||
Cache: true,
|
||||
CacheSize: 256,
|
||||
CacheNegTTL: 60,
|
||||
CacheMinTTL: 60,
|
||||
CacheMaxTTL: 8600,
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,9 +69,10 @@ func ConfigLoad(proxy *Proxy, config_file string) error {
|
||||
proxy.daemonize = config.Daemonize
|
||||
proxy.pluginBlockIPv6 = config.BlockIPv6
|
||||
proxy.cache = config.Cache
|
||||
proxy.negCacheMinTTL = 60
|
||||
proxy.minTTL = 60
|
||||
proxy.maxTTL = 86400
|
||||
proxy.cacheSize = config.CacheSize
|
||||
proxy.cacheNegTTL = config.CacheNegTTL
|
||||
proxy.cacheMinTTL = config.CacheMinTTL
|
||||
proxy.cacheMaxTTL = config.CacheMaxTTL
|
||||
if len(config.ServerNames) == 0 {
|
||||
for serverName := range config.ServersConfig {
|
||||
config.ServerNames = append(config.ServerNames, serverName)
|
||||
|
@ -55,6 +55,26 @@ block_ipv6 = false
|
||||
cache = true
|
||||
|
||||
|
||||
## Cache size
|
||||
|
||||
cache_size = 256
|
||||
|
||||
|
||||
## Minimum TTL for cached entries
|
||||
|
||||
cache_min_ttl = 60
|
||||
|
||||
|
||||
## Maxmimum TTL for cached entries
|
||||
|
||||
cache_max_ttl = 86400
|
||||
|
||||
|
||||
## TTL for negatively cached entries
|
||||
|
||||
cache_neg_ttl = 60
|
||||
|
||||
|
||||
############## Servers ##############
|
||||
|
||||
## Static list of available servers
|
||||
|
@ -25,9 +25,10 @@ type Proxy struct {
|
||||
registeredServers []RegisteredServer
|
||||
pluginBlockIPv6 bool
|
||||
cache bool
|
||||
negCacheMinTTL uint32
|
||||
minTTL uint32
|
||||
maxTTL uint32
|
||||
cacheSize int
|
||||
cacheNegTTL uint32
|
||||
cacheMinTTL uint32
|
||||
cacheMaxTTL uint32
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
@ -31,6 +31,10 @@ type PluginsState struct {
|
||||
responsePlugins *[]Plugin
|
||||
synthResponse *dns.Msg
|
||||
dnssec bool
|
||||
cacheSize int
|
||||
cacheNegTTL uint32
|
||||
cacheMinTTL uint32
|
||||
cacheMaxTTL uint32
|
||||
}
|
||||
|
||||
type Plugin interface {
|
||||
@ -60,6 +64,10 @@ func NewPluginsState(proxy *Proxy, proto string) PluginsState {
|
||||
queryPlugins: queryPlugins,
|
||||
responsePlugins: responsePlugins,
|
||||
proto: proto,
|
||||
cacheSize: proxy.cacheSize,
|
||||
cacheNegTTL: proxy.cacheNegTTL,
|
||||
cacheMinTTL: proxy.cacheMinTTL,
|
||||
cacheMaxTTL: proxy.cacheMaxTTL,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user