예제 #1
0
파일: q.go 프로젝트: raybejjani/dns
func doXfr(c *dns.Client, m *dns.Msg, nameserver string) {
	if t, e := c.TransferIn(m, nameserver); e == nil {
		for r := range t {
			if r.Error == nil {
				for _, rr := range r.RR {
					if *short {
						rr = shortRR(rr)
					}
					fmt.Printf("%v\n", rr)
				}
			} else {
				fmt.Fprintf(os.Stderr, "Failure to read XFR: %s\n", r.Error.Error())
			}
		}
	} else {
		fmt.Fprintf(os.Stderr, "Failure to read XFR: %s\n", e.Error())
	}
}
예제 #2
0
파일: zone.go 프로젝트: valm0unt/fks
// 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
}