Skip to content

Commit 6a679cc

Browse files
committed
Move local DoH configuration to its own section
1 parent be996c4 commit 6a679cc

3 files changed

Lines changed: 42 additions & 18 deletions

File tree

dnscrypt-proxy/config.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ const (
2727
)
2828

2929
type Config struct {
30-
LogLevel int `toml:"log_level"`
31-
LogFile *string `toml:"log_file"`
32-
UseSyslog bool `toml:"use_syslog"`
33-
ServerNames []string `toml:"server_names"`
34-
DisabledServerNames []string `toml:"disabled_server_names"`
35-
ListenAddresses []string `toml:"listen_addresses"`
36-
LocalDoHListenAddresses []string `toml:"local_doh_listen_addresses"`
37-
LocalDoHCertFile string `toml:"local_doh_cert_file"`
38-
LocalDoHCertKeyFile string `toml:"local_doh_cert_key_file"`
30+
LogLevel int `toml:"log_level"`
31+
LogFile *string `toml:"log_file"`
32+
UseSyslog bool `toml:"use_syslog"`
33+
ServerNames []string `toml:"server_names"`
34+
DisabledServerNames []string `toml:"disabled_server_names"`
35+
ListenAddresses []string `toml:"listen_addresses"`
36+
LocalDoH LocalDoHConfig `toml:"local_doh"`
3937
Daemonize bool
4038
UserName string `toml:"user_name"`
4139
ForceTCP bool `toml:"force_tcp"`
@@ -97,9 +95,6 @@ func newConfig() Config {
9795
return Config{
9896
LogLevel: int(dlog.LogLevel()),
9997
ListenAddresses: []string{"127.0.0.1:53"},
100-
LocalDoHListenAddresses: []string{"127.0.0.1:443"},
101-
LocalDoHCertFile: "localhost.pem",
102-
LocalDoHCertKeyFile: "localhost.pem",
10398
Timeout: 5000,
10499
KeepAlive: 5,
105100
CertRefreshDelay: 240,
@@ -195,6 +190,12 @@ type BrokenImplementationsConfig struct {
195190
BrokenQueryPadding []string `toml:"broken_query_padding"`
196191
}
197192

193+
type LocalDoHConfig struct {
194+
ListenAddresses []string `toml:"listen_addresses"`
195+
CertFile string `toml:"cert_file"`
196+
CertKeyFile string `toml:"cert_key_file"`
197+
}
198+
198199
type ServerSummary struct {
199200
Name string `json:"name"`
200201
Proto string `json:"proto"`
@@ -331,7 +332,7 @@ func ConfigLoad(proxy *Proxy, flags *ConfigFlags) error {
331332
proxy.certRefreshDelayAfterFailure = time.Duration(10 * time.Second)
332333
proxy.certIgnoreTimestamp = config.CertIgnoreTimestamp
333334
proxy.ephemeralKeys = config.EphemeralKeys
334-
if len(config.ListenAddresses) == 0 && len(config.LocalDoHListenAddresses) == 0 {
335+
if len(config.ListenAddresses) == 0 && len(config.LocalDoH.ListenAddresses) == 0 {
335336
dlog.Debug("No local IP/port configured")
336337
}
337338

@@ -355,9 +356,9 @@ func ConfigLoad(proxy *Proxy, flags *ConfigFlags) error {
355356
proxy.serversInfo.lbEstimator = config.LBEstimator
356357

357358
proxy.listenAddresses = config.ListenAddresses
358-
proxy.localDoHListenAddresses = config.LocalDoHListenAddresses
359-
proxy.localDoHCertFile = config.LocalDoHCertFile
360-
proxy.localDoHCertKeyFile = config.LocalDoHCertKeyFile
359+
proxy.localDoHListenAddresses = config.LocalDoH.ListenAddresses
360+
proxy.localDoHCertFile = config.LocalDoH.CertFile
361+
proxy.localDoHCertKeyFile = config.LocalDoH.CertKeyFile
361362
proxy.daemonize = config.Daemonize
362363
proxy.pluginBlockIPv6 = config.BlockIPv6
363364
proxy.cache = config.Cache

dnscrypt-proxy/example-dnscrypt-proxy.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,29 @@ cache_neg_max_ttl = 600
340340

341341

342342

343+
##################################
344+
# Local DoH server #
345+
##################################
346+
347+
[local_doh]
348+
349+
## dnscrypt-proxy can act as a local DoH server. By doing so, web browsers
350+
## requiring a direct connection to a DoH server in order to enable some
351+
## features will enable these, without bypassing your DNS proxy..
352+
353+
## Addresses that the local DoH server should listen to
354+
355+
# listen_addresses = ['127.0.0.1:3000']
356+
357+
358+
## Certificate file and key - Note that the certificate has to be trusted.
359+
## See the Wiki for more information.
360+
361+
# cert_file = "localhost.pem"
362+
# cert_key_file = "localhost.pem"
363+
364+
365+
343366
###############################
344367
# Query logging #
345368
###############################

dnscrypt-proxy/proxy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (proxy *Proxy) addLocalDoHListener(listenAddrStr string) {
184184
}
185185
FileDescriptorNum++
186186

187-
dlog.Noticef("Now listening to %v [HTTP]", listenAddrStr)
187+
dlog.Noticef("Now listening to %v [DoH]", listenAddrStr)
188188
go proxy.localDoHListener(listenerTCP.(*net.TCPListener))
189189
}
190190

@@ -323,7 +323,7 @@ func (proxy *Proxy) localDoHListenerFromAddr(listenAddr *net.TCPAddr) error {
323323
if err != nil {
324324
return err
325325
}
326-
dlog.Noticef("Now listening to %v [HTTP]", listenAddr)
326+
dlog.Noticef("Now listening to %v [DoH]", listenAddr)
327327
go proxy.localDoHListener(acceptPc)
328328
return nil
329329
}

0 commit comments

Comments
 (0)