mosdns/pkg/server/iface.go
dengxiongjian cd761e8145
Some checks are pending
Test mosdns / build (push) Waiting to run
新增Mikrotik API 插入解析ip
2025-07-31 11:28:55 +08:00

30 lines
734 B
Go

package server
import (
"context"
"net/netip"
"github.com/miekg/dns"
)
// Handler handles incoming request q and MUST ALWAYS return a response.
// Handler MUST handle dns errors by itself and return a proper error responses.
// e.g. Return a SERVFAIL if something goes wrong.
// If Handle() returns a nil resp, caller will
// udp: do nothing.
// tcp/dot: close the connection immediately.
// doh: send a 500 response.
// doq: close the stream immediately.
type Handler interface {
Handle(ctx context.Context, q *dns.Msg, meta QueryMeta, packMsgPayload func(m *dns.Msg) (*[]byte, error)) (respPayload *[]byte)
}
type QueryMeta struct {
FromUDP bool
// Optional
ClientAddr netip.Addr
ServerName string
UrlPath string
}