github.com/metacubex/mihomo@v1.18.5/component/resolver/local.go (about)

     1  package resolver
     2  
     3  import (
     4  	"context"
     5  
     6  	D "github.com/miekg/dns"
     7  )
     8  
     9  var DefaultLocalServer LocalServer
    10  
    11  type LocalServer interface {
    12  	ServeMsg(ctx context.Context, msg *D.Msg) (*D.Msg, error)
    13  }
    14  
    15  // ServeMsg with a dns.Msg, return resolve dns.Msg
    16  func ServeMsg(ctx context.Context, msg *D.Msg) (*D.Msg, error) {
    17  	if server := DefaultLocalServer; server != nil {
    18  		return server.ServeMsg(ctx, msg)
    19  	}
    20  
    21  	return nil, ErrIPNotFound
    22  }