MCPcopy
hub / github.com/evilsocket/opensnitch / monitor

Method monitor

daemon/dns/systemd/monitor.go:195–215  ·  view source on GitHub ↗

monitor will listen for DNS answers from systemd-resolved.

(ctx context.Context, chanResponse chan *MonitorResponse, chanConnError chan error, callback resolvedCallback)

Source from the content-addressed store, hash-verified

193
194// monitor will listen for DNS answers from systemd-resolved.
195func (r *ResolvedMonitor) monitor(ctx context.Context, chanResponse chan *MonitorResponse, chanConnError chan error, callback resolvedCallback) {
196 for {
197 m := &MonitorResponse{}
198 continues, err := callback(ctx, m)
199 if err != nil {
200 chanConnError <- err
201 goto Exit
202 }
203 if continues != varlink.Continues {
204 goto Exit
205 }
206 log.Trace("ResolvedMonitor >> new response: %#v", m)
207 chanResponse <- m
208 }
209
210Exit:
211 r.mu.Lock()
212 r.connected = false
213 r.mu.Unlock()
214 log.Debug("ResolvedMonitor.monitor() exit.")
215}
216
217// GetDNSResponses returns a channel that you can use to read responses.
218func (r *ResolvedMonitor) GetDNSResponses() chan *MonitorResponse {

Callers 1

SubscribeMethod · 0.95

Calls 3

callbackFuncType · 0.85
LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected