diff --git a/dnscrypt-proxy/config.go b/dnscrypt-proxy/config.go index 20d7a521..7359bbcb 100644 --- a/dnscrypt-proxy/config.go +++ b/dnscrypt-proxy/config.go @@ -49,6 +49,7 @@ type Config struct { BlockIPv6 bool `toml:"block_ipv6"` BlockUnqualified bool `toml:"block_unqualified"` BlockUndelegated bool `toml:"block_undelegated"` + SleepMode bool `toml:"sleep_mode"` Cache bool CacheSize int `toml:"cache_size"` CacheNegTTL uint32 `toml:"cache_neg_ttl"` @@ -474,6 +475,8 @@ func ConfigLoad(proxy *Proxy, flags *ConfigFlags) error { proxy.pluginBlockIPv6 = config.BlockIPv6 proxy.pluginBlockUnqualified = config.BlockUnqualified proxy.pluginBlockUndelegated = config.BlockUndelegated + proxy.sleepMode = config.SleepMode + proxy.cache = config.Cache proxy.cacheSize = config.CacheSize diff --git a/dnscrypt-proxy/example-dnscrypt-proxy.toml b/dnscrypt-proxy/example-dnscrypt-proxy.toml index c0f909a8..f6da7bd9 100644 --- a/dnscrypt-proxy/example-dnscrypt-proxy.toml +++ b/dnscrypt-proxy/example-dnscrypt-proxy.toml @@ -55,6 +55,11 @@ max_clients = 250 # user_name = 'nobody' +## Sleep mode: add an incremental delay to queries so that you eventually get some sleep instead of watching videos all night long. + +sleep_mode = false + + ## Require servers (from remote sources) to satisfy specific properties # Use servers reachable over IPv4 diff --git a/dnscrypt-proxy/proxy.go b/dnscrypt-proxy/proxy.go index 104616dd..b3911551 100644 --- a/dnscrypt-proxy/proxy.go +++ b/dnscrypt-proxy/proxy.go @@ -71,6 +71,7 @@ type Proxy struct { certRefreshDelayAfterFailure time.Duration timeout time.Duration certRefreshDelay time.Duration + sleepDelay time.Duration cacheSize int logMaxBackups int logMaxAge int @@ -94,6 +95,7 @@ type Proxy struct { anonDirectCertFallback bool pluginBlockUndelegated bool child bool + sleepMode bool requiredProps stamps.ServerInformalProperties ServerNames []string DisabledServerNames []string @@ -617,6 +619,12 @@ func (proxy *Proxy) processIncomingQuery( if len(query) < MinDNSPacketSize { return response } + + if proxy.sleepMode { + time.Sleep(proxy.sleepDelay) + proxy.sleepDelay += 10 * time.Microsecond + } + pluginsState := NewPluginsState(proxy, clientProto, clientAddr, serverProto, start) serverName := "-" needsEDNS0Padding := false