Pull request: 2954 wrong logs

Merge in DNS/adguard-home from 2954-wrong-logs to master

Closes #2954.

Squashed commit of the following:

commit 94c77a4dfcadbbf4f44ba4c6b30d4d00d98e659b
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Thu Apr 15 19:15:18 2021 +0300

    all: log changes

commit b5095715e7ba7fd99a03869a97cf7291daaa4fc4
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Thu Apr 15 19:09:46 2021 +0300

    go.mod: upd golibs

commit 70ec262f7bf177e4f9c7a9ee345ec2694e27a549
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Thu Apr 15 17:57:25 2021 +0300

    home: fix config logging

commit f45c407b400431ac0501b915a3070c6071112fee
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Wed Apr 14 15:00:55 2021 +0300

    home: fix rdns logging
This commit is contained in:
Eugene Burkov 2021-04-16 10:32:41 +03:00
parent d83091fc1f
commit 91304663b7
7 changed files with 14 additions and 8 deletions

View File

@ -32,6 +32,7 @@ and this project adheres to
### Changed ### Changed
- Quality of logging ([#2954]).
- Normalization of hostnames with spaces sent by DHCP clients ([#2945]). - Normalization of hostnames with spaces sent by DHCP clients ([#2945]).
- The access to the private hosts is now forbidden for users from external - The access to the private hosts is now forbidden for users from external
networks ([#2889]). networks ([#2889]).
@ -81,6 +82,7 @@ and this project adheres to
[#2934]: https://github.com/AdguardTeam/AdGuardHome/issues/2934 [#2934]: https://github.com/AdguardTeam/AdGuardHome/issues/2934
[#2945]: https://github.com/AdguardTeam/AdGuardHome/issues/2945 [#2945]: https://github.com/AdguardTeam/AdGuardHome/issues/2945
[#2947]: https://github.com/AdguardTeam/AdGuardHome/issues/2947 [#2947]: https://github.com/AdguardTeam/AdGuardHome/issues/2947
[#2954]: https://github.com/AdguardTeam/AdGuardHome/issues/2954
[#2961]: https://github.com/AdguardTeam/AdGuardHome/issues/2961 [#2961]: https://github.com/AdguardTeam/AdGuardHome/issues/2961

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.15
require ( require (
github.com/AdguardTeam/dnsproxy v0.35.5 github.com/AdguardTeam/dnsproxy v0.35.5
github.com/AdguardTeam/golibs v0.4.4 github.com/AdguardTeam/golibs v0.4.5
github.com/AdguardTeam/urlfilter v0.14.4 github.com/AdguardTeam/urlfilter v0.14.4
github.com/NYTimes/gziphandler v1.1.1 github.com/NYTimes/gziphandler v1.1.1
github.com/ameshkov/dnscrypt/v2 v2.0.3 github.com/ameshkov/dnscrypt/v2 v2.0.3

2
go.sum
View File

@ -24,6 +24,8 @@ github.com/AdguardTeam/golibs v0.4.0/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKU
github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.2/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
github.com/AdguardTeam/golibs v0.4.4 h1:cM9UySQiYFW79zo5XRwnaIWVzfW4eNXmZktMrWbthpw= github.com/AdguardTeam/golibs v0.4.4 h1:cM9UySQiYFW79zo5XRwnaIWVzfW4eNXmZktMrWbthpw=
github.com/AdguardTeam/golibs v0.4.4/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4= github.com/AdguardTeam/golibs v0.4.4/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
github.com/AdguardTeam/golibs v0.4.5 h1:RRA9ZsmbJEN4OllAx0BcfvSbRBxxpWluJijBYmtp13U=
github.com/AdguardTeam/golibs v0.4.5/go.mod h1:skKsDKIBB7kkFflLJBpfGX+G8QFTx0WKUzB6TIgtUj4=
github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU= github.com/AdguardTeam/gomitmproxy v0.2.0/go.mod h1:Qdv0Mktnzer5zpdpi5rAwixNJzW2FN91LjKJCkVbYGU=
github.com/AdguardTeam/urlfilter v0.14.4 h1:lrS7lrfxVCFh4TFB6nwPp5UE4n1XNvv3zUetduD9mZw= github.com/AdguardTeam/urlfilter v0.14.4 h1:lrS7lrfxVCFh4TFB6nwPp5UE4n1XNvv3zUetduD9mZw=
github.com/AdguardTeam/urlfilter v0.14.4/go.mod h1:klx4JbOfc4EaNb5lWLqOwfg+pVcyRukmoJRvO55lL5U= github.com/AdguardTeam/urlfilter v0.14.4/go.mod h1:klx4JbOfc4EaNb5lWLqOwfg+pVcyRukmoJRvO55lL5U=

View File

@ -2,6 +2,7 @@ package home
import ( import (
"errors" "errors"
"fmt"
"io/ioutil" "io/ioutil"
"net" "net"
"os" "os"
@ -260,8 +261,7 @@ func readConfigFile() ([]byte, error) {
configFile := config.getConfigFilename() configFile := config.getConfigFilename()
d, err := ioutil.ReadFile(configFile) d, err := ioutil.ReadFile(configFile)
if err != nil { if err != nil {
log.Error("Couldn't read config file %s: %s", configFile, err) return nil, fmt.Errorf("couldn't read config file %s: %w", configFile, err)
return nil, err
} }
return d, nil return d, nil
} }

View File

@ -163,12 +163,14 @@ func setupContext(args options) {
err = parseConfig() err = parseConfig()
if err != nil { if err != nil {
log.Error("Failed to parse configuration, exiting") log.Error("parsing configuration file: %s", err)
os.Exit(1) os.Exit(1)
} }
if args.checkConfig { if args.checkConfig {
log.Info("Configuration file is OK") log.Info("configuration file is ok")
os.Exit(0) os.Exit(0)
} }
} }

View File

@ -90,7 +90,7 @@ func (r *RDNS) workerLoop() {
for ip := range r.ipCh { for ip := range r.ipCh {
host, err := r.exchanger.Exchange(ip) host, err := r.exchanger.Exchange(ip)
if err != nil { if err != nil {
log.Error("rdns: resolving %q: %s", ip, err) log.Debug("rdns: resolving %q: %s", ip, err)
continue continue
} }

View File

@ -171,7 +171,7 @@ func (web *Web) Start() {
hostStr := web.conf.BindHost.String() hostStr := web.conf.BindHost.String()
// we need to have new instance, because after Shutdown() the Server is not usable // we need to have new instance, because after Shutdown() the Server is not usable
web.httpServer = &http.Server{ web.httpServer = &http.Server{
ErrorLog: log.StdLog("web: http", log.DEBUG), ErrorLog: log.StdLog("web: plain", log.DEBUG),
Addr: net.JoinHostPort(hostStr, strconv.Itoa(web.conf.BindPort)), Addr: net.JoinHostPort(hostStr, strconv.Itoa(web.conf.BindPort)),
Handler: withMiddlewares(Context.mux, limitRequestBody), Handler: withMiddlewares(Context.mux, limitRequestBody),
ReadTimeout: web.conf.ReadTimeout, ReadTimeout: web.conf.ReadTimeout,
@ -184,7 +184,7 @@ func (web *Web) Start() {
if web.conf.BetaBindPort != 0 { if web.conf.BetaBindPort != 0 {
web.httpServerBeta = &http.Server{ web.httpServerBeta = &http.Server{
ErrorLog: log.StdLog("web: http", log.DEBUG), ErrorLog: log.StdLog("web: plain", log.DEBUG),
Addr: net.JoinHostPort(hostStr, strconv.Itoa(web.conf.BetaBindPort)), Addr: net.JoinHostPort(hostStr, strconv.Itoa(web.conf.BetaBindPort)),
Handler: withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta), Handler: withMiddlewares(Context.mux, limitRequestBody, web.wrapIndexBeta),
ReadTimeout: web.conf.ReadTimeout, ReadTimeout: web.conf.ReadTimeout,