mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-15 05:31:18 +08:00
23 lines
429 B
Go
23 lines
429 B
Go
package resolver
|
|
|
|
import (
|
|
"context"
|
|
|
|
D "github.com/miekg/dns"
|
|
)
|
|
|
|
var DefaultLocalServer LocalServer
|
|
|
|
type LocalServer interface {
|
|
ServeMsg(ctx context.Context, msg *D.Msg) (*D.Msg, error)
|
|
}
|
|
|
|
// ServeMsg with a dns.Msg, return resolve dns.Msg
|
|
func ServeMsg(ctx context.Context, msg *D.Msg) (*D.Msg, error) {
|
|
if server := DefaultLocalServer; server != nil {
|
|
return server.ServeMsg(ctx, msg)
|
|
}
|
|
|
|
return nil, ErrIPNotFound
|
|
}
|