Skip to content

Commit 9b7c23c

Browse files
committed
Nits
1 parent 64edfa3 commit 9b7c23c

13 files changed

+41
-33
lines changed

dnscrypt-proxy/config_loader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func configureDoHClientAuth(proxy *Proxy, config *Config) error {
157157
dlog.Noticef("Enabling TLS authentication")
158158
configClientCred := dohClientCreds[0]
159159
if len(dohClientCreds) > 1 {
160-
dlog.Fatal("Only one tls_client_auth entry is currently supported")
160+
dlog.Fatal("Only one doh_client_x509_auth entry is currently supported")
161161
}
162162
proxy.xTransport.tlsClientCreds = DOHClientCreds{
163163
clientCert: configClientCred.ClientCert,
@@ -188,7 +188,7 @@ func configureServerParams(proxy *Proxy, config *Config) {
188188
// Configure certificate refresh parameters
189189
proxy.certRefreshConcurrency = Max(1, config.CertRefreshConcurrency)
190190
proxy.certRefreshDelay = time.Duration(Max(60, config.CertRefreshDelay)) * time.Minute
191-
proxy.certRefreshDelayAfterFailure = time.Duration(10 * time.Second)
191+
proxy.certRefreshDelayAfterFailure = 10 * time.Second
192192
proxy.certIgnoreTimestamp = config.CertIgnoreTimestamp
193193
proxy.ephemeralKeys = config.EphemeralKeys
194194
proxy.monitoringUI = config.MonitoringUI
@@ -335,7 +335,7 @@ func configureBlockedNames(proxy *Proxy, config *Config) error {
335335
// configureAllowedNames - Configures allowed names
336336
func configureAllowedNames(proxy *Proxy, config *Config) error {
337337
if len(config.AllowedName.File) > 0 && len(config.WhitelistNameLegacy.File) > 0 {
338-
return errors.New("Don't specify both [whitelist] and [allowed_names] sections - Update your config file")
338+
return errors.New("Don't specify both [allowed_names] and [whitelist] sections - Update your config file")
339339
}
340340
if len(config.WhitelistNameLegacy.File) > 0 {
341341
dlog.Notice("Use of [whitelist] is deprecated - Update your config file")

dnscrypt-proxy/config_watcher.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"bytes"
45
"crypto/sha256"
56
"errors"
67
"io"
@@ -299,13 +300,5 @@ func getFileHash(path string) ([]byte, error) {
299300

300301
// hashesEqual compares two hashes for equality
301302
func hashesEqual(h1, h2 []byte) bool {
302-
if len(h1) != len(h2) {
303-
return false
304-
}
305-
for i := range h1 {
306-
if h1[i] != h2[i] {
307-
return false
308-
}
309-
}
310-
return true
303+
return bytes.Equal(h1, h2)
311304
}

dnscrypt-proxy/crypto.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ func ComputeSharedKey(
5555
sharedKey, err = xsecretbox.SharedKey(*secretKey, *serverPk)
5656
if err != nil {
5757
dlog.Criticalf("[%v] Weak XChaCha20 public key", providerName)
58+
if _, err := crypto_rand.Read(sharedKey[:]); err != nil {
59+
dlog.Fatal(err)
60+
}
5861
}
5962
} else {
6063
box.Precompute(&sharedKey, serverPk, secretKey)

dnscrypt-proxy/dnscrypt_certs.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func FetchCurrentDNSCryptCert(
112112
tsBegin := binary.BigEndian.Uint32(binCert[116:120])
113113
tsEnd := binary.BigEndian.Uint32(binCert[120:124])
114114
if tsBegin >= tsEnd {
115-
dlog.Warnf("[%v] certificate ends before it starts (%v >= %v)", *serverName, tsBegin, tsEnd)
115+
dlog.Warnf("[%v] certificate has invalid time range: start >= end (%v >= %v)", *serverName, tsBegin, tsEnd)
116116
continue
117117
}
118118
ttl := tsEnd - tsBegin
@@ -135,9 +135,6 @@ func FetchCurrentDNSCryptCert(
135135
} else {
136136
dlog.Debugf("[%v] certificate still valid for %d days", *serverName, daysLeft)
137137
}
138-
certInfo.ForwardSecurity = false
139-
} else {
140-
certInfo.ForwardSecurity = true
141138
}
142139
if !proxy.certIgnoreTimestamp {
143140
if now > tsEnd || now < tsBegin {
@@ -152,7 +149,7 @@ func FetchCurrentDNSCryptCert(
152149
}
153150
}
154151
if serial < highestSerial {
155-
dlog.Debugf("[%v] Superseded by a previous certificate", *serverName)
152+
dlog.Debugf("[%v] Superseded by a more recent certificate", *serverName)
156153
continue
157154
}
158155
if serial == highestSerial {
@@ -167,6 +164,7 @@ func FetchCurrentDNSCryptCert(
167164
dlog.Noticef("[%v] Cryptographic construction %v not supported", *serverName, cryptoConstruction)
168165
continue
169166
}
167+
certInfo.ForwardSecurity = ttl <= 86400*7
170168
var serverPk [32]byte
171169
copy(serverPk[:], binCert[72:104])
172170
sharedKey := ComputeSharedKey(cryptoConstruction, &proxy.proxySecretKey, &serverPk, &providerName)

dnscrypt-proxy/example-dnscrypt-proxy.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ keepalive = 30
189189

190190
## Set to `true` to constantly try to estimate the latency of all the resolvers
191191
## and adjust the load-balancing parameters accordingly, or to `false` to disable.
192-
## Default is `true` that makes 'p2' `lb_strategy` work well.
192+
## Default is `true`, which makes the `wp2` `lb_strategy` work well.
193193

194194
# lb_estimator = true
195195

@@ -289,7 +289,7 @@ cert_refresh_delay = 240
289289

290290
## Prefer RSA certificates over ECDSA for TLS connections.
291291
## When this is enabled, some servers may become impossible to use,
292-
## or may stop to work later as they upgrade their configuratione.
292+
## or may stop working later as they upgrade their configuration.
293293
## Changing this setting is generally not recommended, but it may
294294
## reduce CPU usage on small routers with slow CPUs.
295295

@@ -525,7 +525,7 @@ cache_neg_max_ttl = 600
525525
## Path of the DoH URL. This is not a file, but the part after the hostname
526526
## in the URL. By convention, `/dns-query` is frequently chosen.
527527
## For each `listen_address` the complete URL to access the server will be:
528-
## `https://<listen_address><path>` (ex: `https://127.0.0.1/dns-query`)
528+
## `https://<listen_address><path>` (ex: `https://127.0.0.1:3000/dns-query`)
529529

530530
# path = '/dns-query'
531531

@@ -840,7 +840,7 @@ prefix = ''
840840
##
841841
## Older versions of the `dnsdist` server software had a bug with queries larger
842842
## than 1500 bytes. This is fixed since `dnsdist` version 1.5.0, but
843-
## some server may still run an outdated version.
843+
## some servers may still run an outdated version.
844844
##
845845
## The list below enables workarounds to make non-relayed usage more reliable
846846
## until the servers are fixed.
@@ -988,6 +988,7 @@ algorithm = "none"
988988
## - ipcrypt-deterministic: 32 hex chars (16 bytes) - Generate with: openssl rand -hex 16
989989
## - ipcrypt-nd: 32 hex chars (16 bytes) - Generate with: openssl rand -hex 16
990990
## - ipcrypt-ndx: 64 hex chars (32 bytes) - Generate with: openssl rand -hex 32
991+
## - ipcrypt-pfx: 64 hex chars (32 bytes) - Generate with: openssl rand -hex 32
991992
## Example for deterministic/nd: key = "1234567890abcdef1234567890abcdef"
992993
## Example for ndx: key = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
993994
## IMPORTANT: Keep this key secret

dnscrypt-proxy/ipcrypt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func NewIPCryptConfig(keyHex string, algorithm string) (*IPCryptConfig, error) {
4141

4242
config := &IPCryptConfig{
4343
Key: key,
44-
Algorithm: algorithm,
44+
Algorithm: strings.ToLower(algorithm),
4545
}
4646

4747
// Validate key length and prepare config based on algorithm

dnscrypt-proxy/pattern_matcher.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (patternMatcher *PatternMatcher) Add(pattern string, val any, position int)
9595
pattern = strings.TrimPrefix(pattern, ".") // Remove leading dot if present
9696
}
9797
if len(pattern) == 0 {
98-
dlog.Errorf("Syntax error in the rule file at line %d", position)
98+
return fmt.Errorf("Syntax error in the rule file at line %d", position)
9999
}
100100

101101
pattern = strings.ToLower(pattern)
@@ -139,9 +139,9 @@ func (patternMatcher *PatternMatcher) Eval(qName string) (reject bool, reason st
139139
if len(match) < len(revQname) && len(revQname) > 0 {
140140
if i := strings.LastIndex(revQname, "."); i > 0 {
141141
pName := revQname[:i]
142-
if match, _, found := patternMatcher.suffixes.LongestPrefix([]byte(pName)); found {
142+
if match, xval2, found := patternMatcher.suffixes.LongestPrefix([]byte(pName)); found {
143143
if len(match) == len(pName) || pName[len(match)] == '.' {
144-
return true, "*." + StringReverse(string(match)), xval
144+
return true, "*." + StringReverse(string(match)), xval2
145145
}
146146
}
147147
}

dnscrypt-proxy/plugin_allow_ip.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (plugin *PluginAllowedIP) Name() string {
3434
}
3535

3636
func (plugin *PluginAllowedIP) Description() string {
37-
return "Allows DNS queries containing specific IP addresses"
37+
return "Allows DNS responses containing specific IP addresses"
3838
}
3939

4040
func (plugin *PluginAllowedIP) Init(proxy *Proxy) error {

dnscrypt-proxy/plugin_block_ipv6.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (plugin *PluginBlockIPv6) Eval(pluginsState *PluginsState, msg *dns.Msg) er
3939
Name: question.Header().Name, Class: dns.ClassINET, TTL: 86400,
4040
}
4141
hinfo.Cpu = "AAAA queries have been locally blocked by dnscrypt-proxy"
42-
hinfo.Os = "Set block_ipv6 to false to disable that feature"
42+
hinfo.Os = "Set block_ipv6 to false to disable this feature"
4343
synth.Answer = []dns.RR{hinfo}
4444
qName := question.Header().Name
4545
i := strings.Index(qName, ".")

dnscrypt-proxy/plugin_captive_portal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func (plugin *PluginCaptivePortal) Name() string {
1414
}
1515

1616
func (plugin *PluginCaptivePortal) Description() string {
17-
return "Handle test queries operating systems make to detect Wi-Fi captive portal"
17+
return "Handle test queries that operating systems make to detect Wi-Fi captive portals"
1818
}
1919

2020
func (plugin *PluginCaptivePortal) Init(proxy *Proxy) error {

0 commit comments

Comments
 (0)