mihomo/component/resolver/local.go

23 lines
429 B
Go
Raw Permalink Normal View History

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