chore: refactor dns

This commit is contained in:
Andrey Semenov 2024-09-18 04:06:16 +05:00
parent f6da91cc48
commit 97af86cd84

View File

@ -2,7 +2,6 @@ package handler
import ( import (
"context" "context"
"fmt"
"net" "net"
"time" "time"
@ -27,11 +26,12 @@ func (l *LoggingHandler) DoHandle(ctx context.Context, host string, qTypes []uin
t := time.Now() t := time.Now()
addrs, err := resolver.Resolve(ctx, host, qTypes) addrs, err := resolver.Resolve(ctx, host, qTypes)
if err != nil { if err != nil {
return nil, fmt.Errorf("%s: %w", resolver, err) logger.Debug().Msgf("failed to resolve %s using %s", host, resolver)
return nil, err
} }
if len(addrs) > 0 { if len(addrs) > 0 {
d := time.Since(t).Milliseconds() d := time.Since(t).Milliseconds()
logger.Debug().Msgf("resolved %s from %s in %d ms", addrs[0].String(), host, d) logger.Debug().Msgf("resolved %s from %s in %d ms", addrs[0].String(), host, d)
} }
return addrs, err return addrs, nil
} }