Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monitor System DNS client queries #1426

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

dhaavi
Copy link
Member

@dhaavi dhaavi commented Jan 22, 2024

This feature adds monitoring capabilities for the system DNS client.

How?
Windows: Windows Events subcription on the DNS Client
Linux: DBUS monitoring of systemd-resolved

This will allow Portmaster to disable the Secure DNS, while keeping DNS insights.

Comment on lines +55 to +58

// loop fetches new events and send them to via the Loki client.
func (t *Subscription) ReadWorker() {
t.ready = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment needs to be updated

Comment on lines +34 to +38
sigEvent, err := windows.CreateEvent(nil, 0, 0, nil)
if err != nil {
return nil, err
}
defer windows.CloseHandle(sigEvent)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? sigEvent is not used anymore in the function body.

Comment on lines +73 to +74
if err != nil {
if err != win_eventlog.ERROR_NO_MORE_ITEMS {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be errors.Is

eventLogName string
eventLogQuery string

ready bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ready is never read anywhere so I guess we can drop it.

Comment on lines +59 to +65
t.wg.Add(1)
interval := time.NewTicker(time.Second)
defer func() {
t.ready = false
t.wg.Done()
interval.Stop()
}()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess ReadWorker is expected to run in a goroutine. so access to read is unprotected if it's launched multiple times.
Also, wg.Add(1) should be called before the go-routine is launched since there could be a race condition when starting the ReadWorker and immediatley calling Stop which could cause a panic. See https://pkg.go.dev/sync#WaitGroup.Add.

Better add a dedicated Start() routine that adds to the wg and kicks of the goroutine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants