本文整理汇总了Golang中github.com/miekg/dns.MX类的典型用法代码示例。如果您正苦于以下问题:Golang MX类的具体用法?Golang MX怎么用?Golang MX使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MX类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: handleMXRequest
func (s *DNSServer) handleMXRequest(r *dns.Msg, m *dns.Msg) {
m.Answer = make([]dns.RR, 0, 2)
query := r.Question[0].Name
if query[len(query)-1] == '.' {
query = query[:len(query)-1]
}
for service := range s.queryServices(query) {
rr := new(dns.MX)
var ttl int
if service.Ttl != -1 {
ttl = service.Ttl
} else {
ttl = s.config.ttl
}
rr.Hdr = dns.RR_Header{
Name: r.Question[0].Name,
Rrtype: dns.TypeMX,
Class: dns.ClassINET,
Ttl: uint32(ttl),
}
rr.Mx = r.Question[0].Name
m.Answer = append(m.Answer, rr)
}
}
开发者ID:jverdeyen-forks,项目名称:dnsdock,代码行数:28,代码来源:dnsserver.go
示例2: handleDnsMX
// handleDnsMX writes a MX record pointing to s.host into m for host name.
func (s *server) handleDnsMX(name host, m *dns.Msg) {
r := new(dns.MX)
r.Hdr = dns.RR_Header{
Name: name.dns(),
Rrtype: dns.TypeMX,
Class: dns.ClassINET,
Ttl: 3600,
}
r.Preference = 10
r.Mx = s.self.dns()
m.Answer = make([]dns.RR, 1)
m.Answer[0] = r
}
开发者ID:dullgiulio,项目名称:kuradns,代码行数:14,代码来源:dns.go
示例3: answerMX
func answerMX(q *dns.Question, v *DNSValue) dns.RR {
answer := new(dns.MX)
answer.Header().Name = q.Name
answer.Header().Rrtype = dns.TypeMX
answer.Header().Class = dns.ClassINET
answer.Preference = 50 // default if not defined
priority, err := strconv.Atoi(v.Attr["priority"])
if err == nil {
answer.Preference = uint16(priority)
}
if target, ok := v.Attr["target"]; ok {
answer.Mx = strings.TrimSuffix(target, ".") + "."
} else if v.Value != "" { // allows for simplified setting
answer.Mx = strings.TrimSuffix(v.Value, ".") + "."
}
return answer
}
开发者ID:guilhem,项目名称:netcore,代码行数:17,代码来源:dns.go
示例4: makeServiceMX
func (s *DNSServer) makeServiceMX(n string, service *Service) dns.RR {
rr := new(dns.MX)
var ttl int
if service.Ttl != -1 {
ttl = service.Ttl
} else {
ttl = s.config.ttl
}
rr.Hdr = dns.RR_Header{
Name: n,
Rrtype: dns.TypeMX,
Class: dns.ClassINET,
Ttl: uint32(ttl),
}
rr.Mx = n
return rr
}
开发者ID:clinta,项目名称:dnsdock,代码行数:21,代码来源:dnsserver.go
示例5: TestRRsToMapStrsWithOPTRecord
func TestRRsToMapStrsWithOPTRecord(t *testing.T) {
o := new(mkdns.OPT)
o.Hdr.Name = "." // MUST be the root zone, per definition.
o.Hdr.Rrtype = mkdns.TypeOPT
r := new(mkdns.MX)
r.Hdr = mkdns.RR_Header{Name: "miek.nl.", Rrtype: mkdns.TypeMX,
Class: mkdns.ClassINET, Ttl: 3600}
r.Preference = 10
r.Mx = "mx.miek.nl."
// The OPT record is a psuedo-record so it doesn't become a real record
// in our conversion, and there will be 1 entry instead of 2.
mapStrs := rrsToMapStrs([]mkdns.RR{o, r})
assert.Len(t, mapStrs, 1)
mapStr := mapStrs[0]
assert.Equal(t, "IN", mapStr["class"])
assert.Equal(t, "MX", mapStr["type"])
assert.Equal(t, "mx.miek.nl.", mapStr["data"])
assert.Equal(t, "miek.nl.", mapStr["name"])
assert.EqualValues(t, 10, mapStr["preference"])
}
开发者ID:ruflin,项目名称:beats,代码行数:23,代码来源:dns_test.go
注:本文中的github.com/miekg/dns.MX类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论