1 Star 0 Fork 0

AutoM Studio/coredns

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
minimal.go 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
Miek Gieben 提交于 2021-03-16 17:55 +08:00 . plugin/minimal: fix import path (#4523)
package minimal
import (
"context"
"fmt"
"time"
"github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/pkg/nonwriter"
"github.com/coredns/coredns/plugin/pkg/response"
"github.com/miekg/dns"
)
// minimalHandler implements the plugin.Handler interface.
type minimalHandler struct {
Next plugin.Handler
}
func (m *minimalHandler) Name() string { return "minimal" }
func (m *minimalHandler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
nw := nonwriter.New(w)
rcode, err := plugin.NextOrFailure(m.Name(), m.Next, ctx, nw, r)
if err != nil {
return rcode, err
}
ty, _ := response.Typify(nw.Msg, time.Now().UTC())
cl := response.Classify(ty)
// if response is Denial or Error pass through also if the type is Delegation pass through
if cl == response.Denial || cl == response.Error || ty == response.Delegation {
w.WriteMsg(nw.Msg)
return 0, nil
}
if ty != response.NoError {
w.WriteMsg(nw.Msg)
return 0, plugin.Error("minimal", fmt.Errorf("unhandled response type %q for %q", ty, nw.Msg.Question[0].Name))
}
// copy over the original Msg params, deep copy not required as RRs are not modified
d := &dns.Msg{
MsgHdr: nw.Msg.MsgHdr,
Compress: nw.Msg.Compress,
Question: nw.Msg.Question,
Answer: nw.Msg.Answer,
Ns: nil,
Extra: nil,
}
w.WriteMsg(d)
return 0, nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/autom-studio/coredns.git
git@gitee.com:autom-studio/coredns.git
autom-studio
coredns
coredns
master

搜索帮助