More flexible logging; add support for the Windows event log

This commit is contained in:
Frank Denis 2018-01-19 20:06:04 +01:00
parent ed33eb4890
commit 6e1eaf7b90
4 changed files with 32 additions and 4 deletions

View File

@ -18,9 +18,9 @@ dnscrypt-proxy is a flexible DNS proxy. It runs on your computer or router, and
### Setting up dnscrypt-proxy ### Setting up dnscrypt-proxy
1) Modify the [`dnscrypt-proxy.toml`](https://raw.githubusercontent.com/jedisct1/dnscrypt-proxy/master/dnscrypt-proxy/dnscrypt-proxy.toml) configuration file according to your needs. 1. Modify the [`dnscrypt-proxy.toml`](https://raw.githubusercontent.com/jedisct1/dnscrypt-proxy/master/dnscrypt-proxy/dnscrypt-proxy.toml) configuration file according to your needs.
2) Make sure that nothing else is already listening to port 53 on your system and run (in a console with elevated privileges on Windows) the `dnscrypt-proxy` application. Change your DNS settings to the configured IP address and check that everything works as expected. A DNS query for `resolver.00f.net` should return one of the chosen DNS servers instead of your ISP's resolver. 2. Make sure that nothing else is already listening to port 53 on your system and run (in a console with elevated privileges on Windows) the `dnscrypt-proxy` application. Change your DNS settings to the configured IP address and check that everything works as expected. A DNS query for `resolver.00f.net` should return one of the chosen DNS servers instead of your ISP's resolver.
3) Register as a system service (see below). 3. Register as a system service (see below).
### Installing as a system service (Windows, Linux, MacOS) ### Installing as a system service (Windows, Linux, MacOS)
@ -64,6 +64,7 @@ The current 2.0.0 beta version includes all the major features from dnscrypt-pro
| Built-in system installer | Only on Windows | Install/uninstall/start/stop/restart as a service on Windows, Linux/(systemd,Upstart,SysV), and macOS/launchd | | Built-in system installer | Only on Windows | Install/uninstall/start/stop/restart as a service on Windows, Linux/(systemd,Upstart,SysV), and macOS/launchd |
| Built-in servers latency benchmark | No | Yes | | Built-in servers latency benchmark | No | Yes |
| Query type filter: only log a relevant set of query types | No | Yes | | Query type filter: only log a relevant set of query types | No | Yes |
| Support for the Windows Event Log | No | Yes |
## Planned features ## Planned features

View File

@ -13,6 +13,9 @@ import (
) )
type Config struct { type Config struct {
LogLevel int `toml:"log_level"`
LogFile *string `toml:"log_file"`
UseSyslog bool `toml:"use_syslog"`
ServerNames []string `toml:"server_names"` ServerNames []string `toml:"server_names"`
ListenAddresses []string `toml:"listen_addresses"` ListenAddresses []string `toml:"listen_addresses"`
Daemonize bool Daemonize bool
@ -38,6 +41,7 @@ type Config struct {
func newConfig() Config { func newConfig() Config {
return Config{ return Config{
LogLevel: int(dlog.LogLevel()),
ListenAddresses: []string{"127.0.0.1:53"}, ListenAddresses: []string{"127.0.0.1:53"},
Timeout: 2500, Timeout: 2500,
CertRefreshDelay: 30, CertRefreshDelay: 30,
@ -98,6 +102,14 @@ func ConfigLoad(proxy *Proxy, svcFlag *string, config_file string) error {
if _, err := toml.DecodeFile(*configFile, &config); err != nil { if _, err := toml.DecodeFile(*configFile, &config); err != nil {
return err return err
} }
if config.LogLevel >= 0 && config.LogLevel < int(dlog.SeverityLast) {
dlog.SetLogLevel(dlog.Severity(config.LogLevel))
}
if config.UseSyslog {
dlog.UseSyslog(true)
} else if config.LogFile != nil {
dlog.UseLogFile(*config.LogFile)
}
proxy.timeout = time.Duration(config.Timeout) * time.Millisecond proxy.timeout = time.Duration(config.Timeout) * time.Millisecond
proxy.mainProto = "udp" proxy.mainProto = "udp"
if config.ForceTCP { if config.ForceTCP {

View File

@ -59,6 +59,21 @@ force_tcp = false
timeout = 2500 timeout = 2500
# Log level (0-6, default: 2 - 0 is very verbose, 6 only contains fatal errors)
# log_level = 2
# log file for the application
# log_file = "dnscrypt-proxy.log"
# Use the system logger (syslog on Unix, Event Log on Windows)
# use_syslog = true
## Delay, in minutes, after which certificates are reloaded ## Delay, in minutes, after which certificates are reloaded
cert_refresh_delay = 30 cert_refresh_delay = 30

View File

@ -16,7 +16,7 @@ import (
"golang.org/x/crypto/curve25519" "golang.org/x/crypto/curve25519"
) )
const AppVersion = "2.0.0beta3" const AppVersion = "2.0.0beta4"
type Proxy struct { type Proxy struct {
proxyPublicKey [32]byte proxyPublicKey [32]byte