mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-12-25 19:55:38 +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
|
|
}
|