chore: always pass context when resolve dns

This commit is contained in:
wwqgtxx
2022-11-12 13:18:36 +08:00
parent dbadf37823
commit 901a47318d
20 changed files with 156 additions and 135 deletions

View File

@ -1,17 +1,21 @@
package resolver
import D "github.com/miekg/dns"
import (
"context"
D "github.com/miekg/dns"
)
var DefaultLocalServer LocalServer
type LocalServer interface {
ServeMsg(msg *D.Msg) (*D.Msg, error)
ServeMsg(ctx context.Context, msg *D.Msg) (*D.Msg, error)
}
// ServeMsg with a dns.Msg, return resolve dns.Msg
func ServeMsg(msg *D.Msg) (*D.Msg, error) {
func ServeMsg(ctx context.Context, msg *D.Msg) (*D.Msg, error) {
if server := DefaultLocalServer; server != nil {
return server.ServeMsg(msg)
return server.ServeMsg(ctx, msg)
}
return nil, ErrIPNotFound