Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d20918179f |
+16
-23
@@ -212,33 +212,20 @@ func (w *Watcher) runDNSChecks(ctx context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// logFailedLookup logs a failed DNS lookup at error level, unless ctx
|
|
||||||
// was cancelled: shutdown cancels it, and a lookup it cut short did not
|
|
||||||
// fail. A lookup that ran out of time did fail, so it is logged.
|
|
||||||
func (w *Watcher) logFailedLookup(
|
|
||||||
ctx context.Context,
|
|
||||||
msg string,
|
|
||||||
args ...any,
|
|
||||||
) {
|
|
||||||
if errors.Is(ctx.Err(), context.Canceled) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
w.log.Error(msg, args...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *Watcher) checkDomain(
|
func (w *Watcher) checkDomain(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
domain string,
|
domain string,
|
||||||
) {
|
) {
|
||||||
nameservers, err := w.resolver.LookupNS(ctx, domain)
|
nameservers, err := w.resolver.LookupNS(ctx, domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.logFailedLookup(
|
// Shutdown cancels ctx; a lookup it cut short did not fail.
|
||||||
ctx,
|
if !errors.Is(ctx.Err(), context.Canceled) {
|
||||||
|
w.log.Error(
|
||||||
"failed to lookup NS",
|
"failed to lookup NS",
|
||||||
"domain", domain,
|
"domain", domain,
|
||||||
"error", err,
|
"error", err,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -274,12 +261,14 @@ func (w *Watcher) checkDomain(
|
|||||||
// the domain's IP addresses.
|
// the domain's IP addresses.
|
||||||
results, err := w.resolver.LookupAllRecords(ctx, domain)
|
results, err := w.resolver.LookupAllRecords(ctx, domain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.logFailedLookup(
|
// Shutdown cancels ctx; a lookup it cut short did not fail.
|
||||||
ctx,
|
if !errors.Is(ctx.Err(), context.Canceled) {
|
||||||
|
w.log.Error(
|
||||||
"failed to lookup records for domain",
|
"failed to lookup records for domain",
|
||||||
"domain", domain,
|
"domain", domain,
|
||||||
"error", err,
|
"error", err,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -355,12 +344,14 @@ func (w *Watcher) resolveNameserverAddresses(
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
w.logFailedLookup(
|
// Shutdown cancels ctx; a lookup it cut short did not fail.
|
||||||
ctx,
|
if !errors.Is(ctx.Err(), context.Canceled) {
|
||||||
|
w.log.Error(
|
||||||
"no addresses found for nameserver",
|
"no addresses found for nameserver",
|
||||||
"nameserver", ns,
|
"nameserver", ns,
|
||||||
"error", err,
|
"error", err,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if prevIPs, ok := prev[ns]; ok {
|
if prevIPs, ok := prev[ns]; ok {
|
||||||
addresses[ns] = prevIPs
|
addresses[ns] = prevIPs
|
||||||
@@ -408,12 +399,14 @@ func (w *Watcher) checkHostname(
|
|||||||
) {
|
) {
|
||||||
results, err := w.resolver.LookupAllRecords(ctx, hostname)
|
results, err := w.resolver.LookupAllRecords(ctx, hostname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
w.logFailedLookup(
|
// Shutdown cancels ctx; a lookup it cut short did not fail.
|
||||||
ctx,
|
if !errors.Is(ctx.Err(), context.Canceled) {
|
||||||
|
w.log.Error(
|
||||||
"failed to lookup records",
|
"failed to lookup records",
|
||||||
"hostname", hostname,
|
"hostname", hostname,
|
||||||
"error", err,
|
"error", err,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user