mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-19 16:30:07 +08:00
Some checks failed
Test / test (1.20, macos-13) (push) Has been cancelled
Test / test (1.20, macos-latest) (push) Has been cancelled
Test / test (1.20, ubuntu-24.04-arm) (push) Has been cancelled
Test / test (1.20, ubuntu-latest) (push) Has been cancelled
Test / test (1.20, windows-latest) (push) Has been cancelled
Test / test (1.21, macos-13) (push) Has been cancelled
Test / test (1.21, macos-latest) (push) Has been cancelled
Test / test (1.21, ubuntu-24.04-arm) (push) Has been cancelled
Test / test (1.21, ubuntu-latest) (push) Has been cancelled
Test / test (1.21, windows-latest) (push) Has been cancelled
Test / test (1.22, macos-13) (push) Has been cancelled
Test / test (1.22, macos-latest) (push) Has been cancelled
Test / test (1.22, ubuntu-24.04-arm) (push) Has been cancelled
Test / test (1.22, ubuntu-latest) (push) Has been cancelled
Test / test (1.22, windows-latest) (push) Has been cancelled
Test / test (1.23, macos-13) (push) Has been cancelled
Test / test (1.23, macos-latest) (push) Has been cancelled
Test / test (1.23, ubuntu-24.04-arm) (push) Has been cancelled
Test / test (1.23, ubuntu-latest) (push) Has been cancelled
Test / test (1.23, windows-latest) (push) Has been cancelled
Test / test (1.24, macos-13) (push) Has been cancelled
Test / test (1.24, macos-latest) (push) Has been cancelled
Test / test (1.24, ubuntu-24.04-arm) (push) Has been cancelled
Test / test (1.24, ubuntu-latest) (push) Has been cancelled
Test / test (1.24, windows-latest) (push) Has been cancelled
Test / test (1.25, macos-13) (push) Has been cancelled
Test / test (1.25, macos-latest) (push) Has been cancelled
Test / test (1.25, ubuntu-24.04-arm) (push) Has been cancelled
Test / test (1.25, ubuntu-latest) (push) Has been cancelled
Test / test (1.25, windows-latest) (push) Has been cancelled
Trigger CMFA Update / trigger-CMFA-update (push) Has been cancelled
30 lines
666 B
Go
30 lines
666 B
Go
package dns
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
|
|
"github.com/metacubex/mihomo/component/resolver"
|
|
icontext "github.com/metacubex/mihomo/context"
|
|
D "github.com/miekg/dns"
|
|
)
|
|
|
|
type Service struct {
|
|
handler handler
|
|
}
|
|
|
|
// ServeMsg implement [resolver.Service] ResolveMsg
|
|
func (s *Service) ServeMsg(ctx context.Context, msg *D.Msg) (*D.Msg, error) {
|
|
if len(msg.Question) == 0 {
|
|
return nil, errors.New("at least one question is required")
|
|
}
|
|
|
|
return s.handler(icontext.NewDNSContext(ctx), msg)
|
|
}
|
|
|
|
var _ resolver.Service = (*Service)(nil)
|
|
|
|
func NewService(resolver *Resolver, mapper *ResolverEnhancer) *Service {
|
|
return &Service{handler: newHandler(resolver, mapper)}
|
|
}
|