monitor will listen for DNS answers from systemd-resolved.
(ctx context.Context, chanResponse chan *MonitorResponse, chanConnError chan error, callback resolvedCallback)
| 193 | |
| 194 | // monitor will listen for DNS answers from systemd-resolved. |
| 195 | func (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 | |
| 210 | Exit: |
| 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. |
| 218 | func (r *ResolvedMonitor) GetDNSResponses() chan *MonitorResponse { |