本文整理汇总了Golang中github.com/miekg/dns.PTR类的典型用法代码示例。如果您正苦于以下问题:Golang PTR类的具体用法?Golang PTR怎么用?Golang PTR使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PTR类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: handlePTRRequest
func (s *DNSServer) handlePTRRequest(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.queryIp(query) {
var ttl int
if service.Ttl != -1 {
ttl = service.Ttl
} else {
ttl = s.config.ttl
}
for domain := range s.listDomains(service) {
rr := new(dns.PTR)
rr.Hdr = dns.RR_Header{
Name: r.Question[0].Name,
Rrtype: dns.TypePTR,
Class: dns.ClassINET,
Ttl: uint32(ttl),
}
rr.Ptr = domain
m.Answer = append(m.Answer, rr)
}
}
}
开发者ID:jverdeyen-forks,项目名称:dnsdock,代码行数:30,代码来源:dnsserver.go
示例2: handlePTRQuery
func (r *resolver) handlePTRQuery(ptr string, query *dns.Msg) (*dns.Msg, error) {
parts := []string{}
if strings.HasSuffix(ptr, ptrIPv4domain) {
parts = strings.Split(ptr, ptrIPv4domain)
} else if strings.HasSuffix(ptr, ptrIPv6domain) {
parts = strings.Split(ptr, ptrIPv6domain)
} else {
return nil, fmt.Errorf("invalid PTR query, %v", ptr)
}
host := r.backend.ResolveIP(parts[0])
if len(host) == 0 {
return nil, nil
}
logrus.Debugf("Lookup for IP %s: name %s", parts[0], host)
fqdn := dns.Fqdn(host)
resp := new(dns.Msg)
resp.SetReply(query)
setCommonFlags(resp)
rr := new(dns.PTR)
rr.Hdr = dns.RR_Header{Name: ptr, Rrtype: dns.TypePTR, Class: dns.ClassINET, Ttl: respTTL}
rr.Ptr = fqdn
resp.Answer = append(resp.Answer, rr)
return resp, nil
}
开发者ID:jwhonce,项目名称:docker,代码行数:30,代码来源:resolver.go
示例3: PtrRecord
func PtrRecord(pv *usage.ProjectVersion) *dns.PTR {
latest := usage.FormatV1(&usage.ProjectVersion{pv.Project, "latest"})
rr := new(dns.PTR)
rr.Hdr = dns.RR_Header{Name: latest, Rrtype: dns.TypePTR, Ttl: 0}
rr.Ptr = usage.FormatV1(pv)
return rr
}
开发者ID:gliderlabs,项目名称:pkg,代码行数:7,代码来源:main.go
示例4: handleReverseRequest
func (s *DNSServer) handleReverseRequest(w dns.ResponseWriter, r *dns.Msg) {
m := new(dns.Msg)
m.SetReply(r)
// Send empty response for empty requests
if len(r.Question) == 0 {
m.Ns = s.createSOA()
w.WriteMsg(m)
return
}
m.Answer = make([]dns.RR, 0, 2)
query := r.Question[0].Name
// trim off any trailing dot
if query[len(query)-1] == '.' {
query = query[:len(query)-1]
}
for service := range s.queryIp(query) {
if r.Question[0].Qtype != dns.TypePTR {
m.Ns = s.createSOA()
w.WriteMsg(m)
return
}
var ttl int
if service.Ttl != -1 {
ttl = service.Ttl
} else {
ttl = s.config.ttl
}
for domain := range s.listDomains(service) {
rr := new(dns.PTR)
rr.Hdr = dns.RR_Header{
Name: r.Question[0].Name,
Rrtype: dns.TypePTR,
Class: dns.ClassINET,
Ttl: uint32(ttl),
}
rr.Ptr = domain
m.Answer = append(m.Answer, rr)
}
}
if len(m.Answer) != 0 {
w.WriteMsg(m)
} else {
// We didn't find a record corresponding to the query,
// try forwarding
s.handleForward(w, r)
}
}
开发者ID:clinta,项目名称:dnsdock,代码行数:55,代码来源:dnsserver.go
示例5: dnsPtrRecord
func dnsPtrRecord(query *dns.Msg, name string, hosts []string) *dns.Msg {
resp := new(dns.Msg)
resp.SetReply(query)
for _, host := range hosts {
rr := new(dns.PTR)
rr.Hdr = dns.RR_Header{Name: name, Rrtype: dns.TypePTR, Class: dns.ClassINET, Ttl: 0}
rr.Ptr = host
resp.Answer = append(resp.Answer, rr)
}
return resp
}
开发者ID:spikeekips,项目名称:resolvable,代码行数:12,代码来源:resolver.go
示例6: PTRRecords
func (s *server) PTRRecords(q dns.Question) (records []dns.RR, err error) {
name := strings.ToLower(q.Name)
result, err := s.hosts.FindReverse(name)
if err != nil {
return nil, err
}
if result != "" {
r := new(dns.PTR)
r.Hdr = dns.RR_Header{Name: q.Name, Rrtype: dns.TypePTR,
Class: dns.ClassINET, Ttl: s.config.HostsTtl}
r.Ptr = result
records = append(records, r)
}
return records, nil
}
开发者ID:janeczku,项目名称:go-dnsmasq,代码行数:15,代码来源:server.go
示例7: answerPTR
func answerPTR(q *dns.Question, v *DNSValue) dns.RR {
answer := new(dns.PTR)
answer.Header().Name = q.Name
answer.Header().Rrtype = dns.TypePTR
answer.Header().Class = dns.ClassINET
answer.Ptr = strings.TrimSuffix(v.Value, ".") + "."
return answer
}
开发者ID:guilhem,项目名称:netcore,代码行数:8,代码来源:dns.go
注:本文中的github.com/miekg/dns.PTR类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论