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
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.
3) Register as a system service (see below).
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.
3. Register as a system service (see below).
### 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 servers latency benchmark | 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

View File

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

View File

@ -59,6 +59,21 @@ force_tcp = false
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
cert_refresh_delay = 30

View File

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