mirror of
https://github.com/safing/portmaster
synced 2025-09-02 02:29:12 +00:00
Merge pull request #458 from safing/feature/resolver-debug-data
Add resolvers to debug data
This commit is contained in:
commit
a9108ae6ed
3 changed files with 43 additions and 0 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portbase/modules"
|
||||
"github.com/safing/portbase/utils/debug"
|
||||
"github.com/safing/portmaster/resolver"
|
||||
"github.com/safing/portmaster/status"
|
||||
"github.com/safing/portmaster/updates"
|
||||
)
|
||||
|
@ -84,6 +85,7 @@ func debugInfo(ar *api.Request) (data []byte, err error) {
|
|||
di.AddVersionInfo()
|
||||
di.AddPlatformInfo(ar.Context())
|
||||
status.AddToDebugInfo(di)
|
||||
resolver.AddToDebugInfo(di)
|
||||
di.AddLastReportedModuleError()
|
||||
di.AddLastUnexpectedLogs()
|
||||
di.AddGoroutineStack()
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/safing/portbase/utils/debug"
|
||||
"github.com/safing/portmaster/network/state"
|
||||
"github.com/safing/portmaster/process"
|
||||
"github.com/safing/portmaster/resolver"
|
||||
"github.com/safing/portmaster/status"
|
||||
)
|
||||
|
||||
|
@ -74,6 +75,7 @@ func debugInfo(ar *api.Request) (data []byte, err error) {
|
|||
di.AddVersionInfo()
|
||||
di.AddPlatformInfo(ar.Context())
|
||||
status.AddToDebugInfo(di)
|
||||
resolver.AddToDebugInfo(di)
|
||||
AddNetworkDebugData(
|
||||
di,
|
||||
ar.Request.URL.Query().Get("profile"),
|
||||
|
|
|
@ -2,6 +2,7 @@ package resolver
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -10,6 +11,7 @@ import (
|
|||
"github.com/safing/portbase/log"
|
||||
"github.com/safing/portbase/modules"
|
||||
"github.com/safing/portbase/notifications"
|
||||
"github.com/safing/portbase/utils/debug"
|
||||
"github.com/safing/portmaster/intel"
|
||||
"github.com/tevino/abool"
|
||||
|
||||
|
@ -155,3 +157,40 @@ func resetFailingResolversNotification() {
|
|||
failingResolverNotification = nil
|
||||
}
|
||||
}
|
||||
|
||||
// AddToDebugInfo adds the system status to the given debug.Info.
|
||||
func AddToDebugInfo(di *debug.Info) {
|
||||
resolversLock.Lock()
|
||||
defer resolversLock.Unlock()
|
||||
|
||||
content := make([]string, 0, (len(globalResolvers)*4)-1)
|
||||
var working, total int
|
||||
for i, resolver := range globalResolvers {
|
||||
// Count for summary.
|
||||
total++
|
||||
failing := resolver.Conn.IsFailing()
|
||||
if !failing {
|
||||
working++
|
||||
}
|
||||
|
||||
// Add section.
|
||||
if resolver.Info.Name != "" {
|
||||
content = append(content, resolver.Info.Name)
|
||||
} else {
|
||||
content = append(content, resolver.Info.IP.String())
|
||||
}
|
||||
content = append(content, fmt.Sprintf(" %s", resolver.Info.ID()))
|
||||
content = append(content, fmt.Sprintf(" Failing: %v", resolver.Conn.IsFailing()))
|
||||
|
||||
// Add a empty line for all but the last entry.
|
||||
if i+1 < len(globalResolvers) {
|
||||
content = append(content, "")
|
||||
}
|
||||
}
|
||||
|
||||
di.AddSection(
|
||||
fmt.Sprintf("Resolvers: %d/%d", working, total),
|
||||
debug.UseCodeSection|debug.AddContentLineBreaks,
|
||||
content...,
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue