Pull request: all: fix lint and naming issues vol. 3

Merge in DNS/adguard-home from 2276-fix-lint-3 to master

Updates #2276.

Squashed commit of the following:

commit 6ee94cc6ed2a9762b70ef395b58b496434244b80
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Dec 7 15:55:45 2020 +0300

    all: fix lint and naming issues vol. 3
This commit is contained in:
Ainar Garipov
2020-12-07 16:04:53 +03:00
parent 7f29d4e546
commit 9b963fc777
23 changed files with 234 additions and 226 deletions

View File

@@ -3,7 +3,6 @@ package home
import (
"context"
"crypto/tls"
golog "log"
"net"
"net/http"
"strconv"
@@ -30,7 +29,7 @@ const (
WriteTimeout = 10 * time.Second
)
type WebConfig struct {
type webConfig struct {
firstRun bool
BindHost string
BindPort int
@@ -61,34 +60,20 @@ type HTTPSServer struct {
// Web - module object
type Web struct {
conf *WebConfig
conf *webConfig
forceHTTPS bool
portHTTPS int
httpServer *http.Server // HTTP module
httpsServer HTTPSServer // HTTPS module
errLogger *golog.Logger
}
// Proxy between Go's "log" and "golibs/log"
type logWriter struct {
}
// HTTP server calls this function to log an error
func (w *logWriter) Write(p []byte) (int, error) {
log.Debug("Web: %s", string(p))
return 0, nil
}
// CreateWeb - create module
func CreateWeb(conf *WebConfig) *Web {
func CreateWeb(conf *webConfig) *Web {
log.Info("Initialize web module")
w := Web{}
w.conf = conf
lw := logWriter{}
w.errLogger = golog.New(&lw, "", 0)
// Initialize and run the admin Web interface
box := packr.NewBox("../../build/static")
@@ -166,13 +151,14 @@ func (web *Web) Start() {
// we need to have new instance, because after Shutdown() the Server is not usable
address := net.JoinHostPort(web.conf.BindHost, strconv.Itoa(web.conf.BindPort))
web.httpServer = &http.Server{
ErrorLog: web.errLogger,
ErrorLog: log.StdLog("web: http", log.DEBUG),
Addr: address,
Handler: withMiddlewares(Context.mux, limitRequestBody),
ReadTimeout: web.conf.ReadTimeout,
ReadHeaderTimeout: web.conf.ReadHeaderTimeout,
WriteTimeout: web.conf.WriteTimeout,
}
err := web.httpServer.ListenAndServe()
if err != http.ErrServerClosed {
cleanupAlways()
@@ -220,7 +206,7 @@ func (web *Web) tlsServerLoop() {
// prepare HTTPS server
address := net.JoinHostPort(web.conf.BindHost, strconv.Itoa(web.conf.PortHTTPS))
web.httpsServer.server = &http.Server{
ErrorLog: web.errLogger,
ErrorLog: log.StdLog("web: https", log.DEBUG),
Addr: address,
TLSConfig: &tls.Config{
Certificates: []tls.Certificate{web.httpsServer.cert},