本文整理汇总了Golang中github.com/miekg/dns.Msg.SetAxfr方法的典型用法代码示例。如果您正苦于以下问题:Golang Msg.SetAxfr方法的具体用法?Golang Msg.SetAxfr怎么用?Golang Msg.SetAxfr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/miekg/dns.Msg
的用法示例。
在下文中一共展示了Msg.SetAxfr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Transfer
func (s *Service) Transfer(zone string) ([]dns.RR, error) {
m := new(dns.Msg)
m.SetAxfr(zone)
h, err := s.ServerPort()
if err != nil {
return nil, err
}
tr := new(dns.Transfer)
a, err := tr.In(m, h)
if err != nil {
return nil, err
}
var res []dns.RR
for ex := range a {
if ex.Error != nil {
return nil, ex.Error
}
res = append(res, ex.RR...)
}
return res, nil
}
示例2: do_axfr
func do_axfr(zone_name string) ([]dns.RR, error) {
result := []dns.RR{}
message := new(dns.Msg)
message.SetAxfr(zone_name)
transfer := &dns.Transfer{DialTimeout: conf.Query_timeout, ReadTimeout: conf.Query_timeout}
if conf.Transfer_source != nil {
d := net.Dialer{LocalAddr: conf.Transfer_source}
c, err := d.Dial("tcp", conf.Master)
if err != nil {
logger.Debug("AXFR ERROR : problem dialing master")
return result, err
}
dnscon := &dns.Conn{Conn: c}
transfer = &dns.Transfer{Conn: dnscon, DialTimeout: conf.Query_timeout, ReadTimeout: conf.Query_timeout}
}
channel, err := transfer.In(message, conf.Master)
if err != nil {
return result, err
}
for envelope := range channel {
result = append(result, envelope.RR...)
}
return result, nil
}
示例3: transfer
func (e *Equipment) transfer() ([]dns.RR, error) {
m := new(dns.Msg)
m.SetAxfr(e.Zone)
port := e.Port
if port == "" {
port = DEF_PORT
}
s, err := net.LookupHost(e.Server)
if err != nil {
return nil, err
}
tr := new(dns.Transfer)
a, err := tr.In(m, net.JoinHostPort(s[0], port))
if err != nil {
return nil, err
}
var res []dns.RR
for ex := range a {
if ex.Error != nil {
return nil, ex.Error
}
res = append(res, ex.RR...)
}
return res, nil
}
示例4: list
func (r *RFC2136Provider) list() ([]dns.RR, error) {
logrus.Debugf("Fetching records for '%s'", r.zoneName)
t := new(dns.Transfer)
t.TsigSecret = map[string]string{r.tsigKeyName: r.tsigSecret}
m := new(dns.Msg)
m.SetAxfr(r.zoneName)
m.SetTsig(r.tsigKeyName, dns.HmacMD5, 300, time.Now().Unix())
env, err := t.In(m, r.nameserver)
if err != nil {
return nil, fmt.Errorf("Failed to fetch records via AXFR: %v", err)
}
records := make([]dns.RR, 0)
for e := range env {
if e.Error != nil {
logrus.Errorf("AXFR envelope error: %v", e.Error)
continue
}
records = append(records, e.RR...)
}
return records, nil
}
示例5: TransferIn
// TransferIn retrieves the zone from the masters, parses it and sets it live.
func (z *Zone) TransferIn() error {
if len(z.TransferFrom) == 0 {
return nil
}
m := new(dns.Msg)
m.SetAxfr(z.origin)
z1 := z.Copy()
var (
Err error
tr string
)
Transfer:
for _, tr = range z.TransferFrom {
t := new(dns.Transfer)
c, err := t.In(m, tr)
if err != nil {
log.Printf("[ERROR] Failed to setup transfer `%s' with `%s': %v", z.origin, tr, err)
Err = err
continue Transfer
}
for env := range c {
if env.Error != nil {
log.Printf("[ERROR] Failed to parse transfer `%s': %v", z.origin, env.Error)
Err = env.Error
continue Transfer
}
for _, rr := range env.RR {
if err := z1.Insert(rr); err != nil {
log.Printf("[ERROR] Failed to parse transfer `%s': %v", z.origin, err)
Err = err
continue Transfer
}
}
}
Err = nil
break
}
if Err != nil {
log.Printf("[ERROR] Failed to transfer %s: %s", z.origin, Err)
return Err
}
z.Tree = z1.Tree
z.Apex = z1.Apex
*z.Expired = false
log.Printf("[INFO] Transferred: %s from %s", z.origin, tr)
return nil
}
示例6: do_axfr
func do_axfr(zone_name string) ([]dns.RR, error) {
result := []dns.RR{}
message := new(dns.Msg)
message.SetAxfr(zone_name)
transfer := &dns.Transfer{DialTimeout: 10 * time.Second, ReadTimeout: 10 * time.Second}
channel, err := transfer.In(message, master)
if err != nil {
return result, err
}
for envelope := range channel {
result = append(result, envelope.RR...)
}
return result, nil
}
示例7: ZoneTransfer
func ZoneTransfer(domain string) Results {
results := NewResultSet()
fqdn := dns.Fqdn(domain)
servers, err := net.LookupNS(domain)
if err != nil {
log.Fatal(err)
}
for _, server := range servers {
msg := new(dns.Msg)
msg.SetAxfr(fqdn)
transfer := new(dns.Transfer)
answerChan, err := transfer.In(msg, net.JoinHostPort(server.Host, "53"))
if err != nil {
log.Println(err)
continue
}
for envelope := range answerChan {
if envelope.Error != nil {
log.Println(envelope.Error)
break
}
for _, rr := range envelope.RR {
switch v := rr.(type) {
case *dns.A:
results.Add(strings.TrimRight(v.Header().Name, "."), v.A.String())
case *dns.AAAA:
results.Add(strings.TrimRight(v.Header().Name, "."), v.AAAA.String())
default:
}
}
}
}
return results.Results()
}
示例8: ReadZoneXfr
// ReadZoneXfr reads a zone from an axfr.
func (c *Config) ReadZoneXfr(origin, master string) error {
client := new(dns.Client)
client.Net = "tcp"
m := new(dns.Msg)
m.SetAxfr(origin)
z := dns.NewZone(origin)
t, e := client.TransferIn(m, master)
if e == nil {
for r := range t {
if r.Error == nil {
// Loop answer section
for _, rr := range r.RR {
z.Insert(rr)
}
}
}
c.Zones[origin] = z
dns.HandleFunc(origin, func(w dns.ResponseWriter, req *dns.Msg) { serve(w, req, c.Zones[origin]) })
return nil
}
return e
}