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


Golang Msg.SetAxfr方法代码示例

本文整理汇总了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
}
开发者ID:ozym,项目名称:zone,代码行数:25,代码来源:service.go

示例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
}
开发者ID:rackerlabs,项目名称:slappy,代码行数:26,代码来源:slapdns.go

示例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
}
开发者ID:ozym,项目名称:zone,代码行数:30,代码来源:equipment.go

示例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
}
开发者ID:rancher,项目名称:external-dns,代码行数:25,代码来源:rfc2136.go

示例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
}
开发者ID:yuewko,项目名称:coredns,代码行数:51,代码来源:secondary.go

示例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
}
开发者ID:ionrock,项目名称:mario-dns,代码行数:16,代码来源:dns.go

示例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()
}
开发者ID:jrozner,项目名称:sonar,代码行数:40,代码来源:zonetransfer.go

示例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
}
开发者ID:valm0unt,项目名称:fks,代码行数:24,代码来源:zone.go


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