-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
base: develop
Are you sure you want to change the base?
Conversation
|
||
// loop fetches new events and send them to via the Loki client. | ||
func (t *Subscription) ReadWorker() { | ||
t.ready = true |
There was a problem hiding this comment.
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
sigEvent, err := windows.CreateEvent(nil, 0, 0, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer windows.CloseHandle(sigEvent) |
There was a problem hiding this comment.
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.
if err != nil { | ||
if err != win_eventlog.ERROR_NO_MORE_ITEMS { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
t.wg.Add(1) | ||
interval := time.NewTicker(time.Second) | ||
defer func() { | ||
t.ready = false | ||
t.wg.Done() | ||
interval.Stop() | ||
}() |
There was a problem hiding this comment.
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
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.