当前位置: 首页>>代码示例>>Golang>>正文


Golang OPT.SetExtendedRcode方法代码示例

本文整理汇总了Golang中github.com/miekg/dns.OPT.SetExtendedRcode方法的典型用法代码示例。如果您正苦于以下问题:Golang OPT.SetExtendedRcode方法的具体用法?Golang OPT.SetExtendedRcode怎么用?Golang OPT.SetExtendedRcode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/miekg/dns.OPT的用法示例。


在下文中一共展示了OPT.SetExtendedRcode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Edns0Version

// Edns0Version checks the EDNS version in the request. If error
// is nil everything is OK and we can invoke the middleware. If non-nil, the
// returned Msg is valid to be returned to the client (and should). For some
// reason this response should not contain a question RR in the question section.
func Edns0Version(req *dns.Msg) (*dns.Msg, error) {
	opt := req.IsEdns0()
	if opt == nil {
		return nil, nil
	}
	if opt.Version() == 0 {
		return nil, nil
	}
	m := new(dns.Msg)
	m.SetReply(req)
	// zero out question section, wtf.
	m.Question = nil

	o := new(dns.OPT)
	o.Hdr.Name = "."
	o.Hdr.Rrtype = dns.TypeOPT
	o.SetVersion(0)
	o.SetExtendedRcode(dns.RcodeBadVers)
	m.Extra = []dns.RR{o}

	return m, errors.New("EDNS0 BADVERS")
}
开发者ID:yuewko,项目名称:coredns,代码行数:26,代码来源:edns.go


注:本文中的github.com/miekg/dns.OPT.SetExtendedRcode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。