*: added more logging
This commit is contained in:
parent
4bdf22eadc
commit
1a34b96d03
|
@ -71,6 +71,8 @@ type User struct {
|
||||||
|
|
||||||
// InitAuth - create a global object
|
// InitAuth - create a global object
|
||||||
func InitAuth(dbFilename string, users []User, sessionTTL uint32) *Auth {
|
func InitAuth(dbFilename string, users []User, sessionTTL uint32) *Auth {
|
||||||
|
log.Info("Initializing auth module: %s", dbFilename)
|
||||||
|
|
||||||
a := Auth{}
|
a := Auth{}
|
||||||
a.sessionTTL = sessionTTL
|
a.sessionTTL = sessionTTL
|
||||||
a.sessions = make(map[string]*session)
|
a.sessions = make(map[string]*session)
|
||||||
|
@ -83,7 +85,7 @@ func InitAuth(dbFilename string, users []User, sessionTTL uint32) *Auth {
|
||||||
}
|
}
|
||||||
a.loadSessions()
|
a.loadSessions()
|
||||||
a.users = users
|
a.users = users
|
||||||
log.Debug("Auth: initialized. users:%d sessions:%d", len(a.users), len(a.sessions))
|
log.Info("Auth: initialized. users:%d sessions:%d", len(a.users), len(a.sessions))
|
||||||
return &a
|
return &a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
home/home.go
15
home/home.go
|
@ -43,10 +43,10 @@ const (
|
||||||
|
|
||||||
// Update-related variables
|
// Update-related variables
|
||||||
var (
|
var (
|
||||||
versionString string
|
versionString = "dev"
|
||||||
updateChannel string
|
updateChannel = "none"
|
||||||
versionCheckURL string
|
versionCheckURL = ""
|
||||||
ARMVersion string
|
ARMVersion = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
const versionCheckPeriod = time.Hour * 8
|
const versionCheckPeriod = time.Hour * 8
|
||||||
|
@ -155,11 +155,11 @@ func run(args options) {
|
||||||
configureLogger(args)
|
configureLogger(args)
|
||||||
|
|
||||||
// print the first message after logger is configured
|
// print the first message after logger is configured
|
||||||
msg := "AdGuard Home, version %s, channel %s\n, arch %s %s"
|
msg := "AdGuard Home, version %s, channel %s, arch %s %s"
|
||||||
if ARMVersion != "" {
|
if ARMVersion != "" {
|
||||||
msg = msg + " v" + ARMVersion
|
msg = msg + " v" + ARMVersion
|
||||||
}
|
}
|
||||||
log.Printf(msg, versionString, updateChannel, runtime.GOOS, runtime.GOARCH, ARMVersion)
|
log.Printf(msg, versionString, updateChannel, runtime.GOOS, runtime.GOARCH)
|
||||||
log.Debug("Current working directory is %s", Context.workDir)
|
log.Debug("Current working directory is %s", Context.workDir)
|
||||||
if args.runningAsService {
|
if args.runningAsService {
|
||||||
log.Info("AdGuard Home is running as a service")
|
log.Info("AdGuard Home is running as a service")
|
||||||
|
@ -169,6 +169,7 @@ func run(args options) {
|
||||||
|
|
||||||
Context.firstRun = detectFirstRun()
|
Context.firstRun = detectFirstRun()
|
||||||
if Context.firstRun {
|
if Context.firstRun {
|
||||||
|
log.Info("This is the first time AdGuard Home is launched")
|
||||||
requireAdminRights()
|
requireAdminRights()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +198,7 @@ func run(args options) {
|
||||||
|
|
||||||
err = parseConfig()
|
err = parseConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error("Failed to parse configuration, exiting")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,6 +213,7 @@ func run(args options) {
|
||||||
config.DHCP.ConfigModified = onConfigModified
|
config.DHCP.ConfigModified = onConfigModified
|
||||||
Context.dhcpServer = dhcpd.Create(config.DHCP)
|
Context.dhcpServer = dhcpd.Create(config.DHCP)
|
||||||
if Context.dhcpServer == nil {
|
if Context.dhcpServer == nil {
|
||||||
|
log.Error("Failed to initialize DHCP server, exiting")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
Context.autoHosts.Init("")
|
Context.autoHosts.Init("")
|
||||||
|
|
|
@ -107,7 +107,7 @@ schema_version: 5
|
||||||
// . Wait until the filters are downloaded
|
// . Wait until the filters are downloaded
|
||||||
// . Stop and cleanup
|
// . Stop and cleanup
|
||||||
func TestHome(t *testing.T) {
|
func TestHome(t *testing.T) {
|
||||||
// Reinit context
|
// Init new context
|
||||||
Context = homeContext{}
|
Context = homeContext{}
|
||||||
|
|
||||||
dir := prepareTestDir()
|
dir := prepareTestDir()
|
||||||
|
@ -135,11 +135,11 @@ func TestHome(t *testing.T) {
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
}
|
}
|
||||||
assert.Truef(t, err == nil, "%s", err)
|
assert.Truef(t, err == nil, "%s", err)
|
||||||
assert.Equal(t, 200, resp.StatusCode)
|
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||||
|
|
||||||
resp, err = h.Get("http://127.0.0.1:3000/control/status")
|
resp, err = h.Get("http://127.0.0.1:3000/control/status")
|
||||||
assert.Truef(t, err == nil, "%s", err)
|
assert.Truef(t, err == nil, "%s", err)
|
||||||
assert.Equal(t, 200, resp.StatusCode)
|
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
||||||
|
|
||||||
// test DNS over UDP
|
// test DNS over UDP
|
||||||
r := upstream.NewResolver("127.0.0.1:5354", 3*time.Second)
|
r := upstream.NewResolver("127.0.0.1:5354", 3*time.Second)
|
||||||
|
|
|
@ -42,6 +42,8 @@ type Web struct {
|
||||||
|
|
||||||
// CreateWeb - create module
|
// CreateWeb - create module
|
||||||
func CreateWeb(conf *WebConfig) *Web {
|
func CreateWeb(conf *WebConfig) *Web {
|
||||||
|
log.Info("Initialize web module")
|
||||||
|
|
||||||
w := Web{}
|
w := Web{}
|
||||||
w.conf = conf
|
w.conf = conf
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue