Exemplo n.º 1
0
func main() {
	serial := flag.Int("serial", 0, "Perform an IXFR with the given serial")
	nameserver := flag.String("ns", "127.0.0.1:53", "Query this nameserver")
	tsig := flag.String("tsig", "", "request tsig with key: name:key (only hmac-md5)")
	flag.Parse()
	zone := flag.Arg(flag.NArg() - 1)

	client := new(dns.Client)
	client.Net = "tcp"
	m := new(dns.Msg)
	if *serial > 0 {
		m.SetIxfr(zone, uint32(*serial))
	} else {
		m.SetAxfr(zone)
	}
	if *tsig != "" {
		a := strings.SplitN(*tsig, ":", 2)
		name, secret := a[0], a[1]
		client.TsigSecret = map[string]string{name: secret}
		m.SetTsig(name, dns.HmacMD5, 300, time.Now().Unix())
	}

	if t, e := client.XfrReceive(m, *nameserver); e == nil {
		for r := range t {
			if r.Error == nil {
				fmt.Printf("%v\n", r.Reply)
			}
		}
	} else {
		fmt.Printf("Error %v\n", e)
	}
}
Exemplo n.º 2
0
Arquivo: xfr.go Projeto: elazarl/godns
func handleXfrIn(i *dns.Msg) os.Error {
	q := new(dns.Msg)
	q.SetAxfr(i.Question[0].Name)

	m := make(chan *dns.Xfr)
	fmt.Printf("Preparing Xfr for %s\n", i.Question[0].Name)

	d := new(dns.Conn)
	d.RemoteAddr = "127.0.0.1:53"
	err := d.Dial("tcp")
	if err != nil {
		return err
	}
	defer d.Close()

	fmt.Printf("Calling 127.0.0.1 successful\n")
	go d.XfrRead(q, m)

	Zone.name = i.Question[0].Name
	j := 0
	for x := range m {
		Zone.rrs[j] = x.RR
		j++
	}
	fmt.Printf("Success retrieved %s\n", Zone.name)
	Zone.size = j
	return nil
}
Exemplo n.º 3
0
func main() {
	var serial *int = flag.Int("serial", 0, "Perform an IXFR with the given serial")
	var nameserver *string = flag.String("ns", "127.0.0.1:53", "Query this nameserver")
	//	var secret *string = flag.String("secret", "", "Use this secret for TSIG")
	flag.Parse()
	zone := flag.Arg(flag.NArg() - 1)

	client := dns.NewClient()
	client.Net = "tcp"
	m := new(dns.Msg)
	if *serial > 0 {
		m.SetIxfr(zone, uint32(*serial))
	} else {
		m.SetAxfr(zone)
	}
	if err := client.XfrReceive(m, *nameserver); err == nil {
		for r := range client.ReplyChan {
			if r.Error != nil {
				if r.Error == dns.ErrXfrLast {
					fmt.Printf("%v\n", r.Reply)
				}
				break
			}
			fmt.Printf("%v\n", r.Reply)
		}
	} else {
		fmt.Printf("Error %v\n", err)
	}
}
Exemplo n.º 4
0
func main() {
	var serial *int = flag.Int("serial", 0, "Perform an IXFR with the given serial")
	var nameserver *string = flag.String("ns", "127.0.0.1:53", "Query this nameserver")
	flag.Parse()
	zone := flag.Arg(flag.NArg() - 1)

	client := dns.NewClient()
	client.Net = "tcp"
	m := new(dns.Msg)
	if *serial > 0 {
		m.SetIxfr(zone, uint32(*serial))
	} else {
		m.SetAxfr(zone)
	}
	axfr, err := client.XfrReceive(m, *nameserver)
	if err != nil {
		println(err.String())
	}
	for _, v := range axfr {
		fmt.Printf("%v\n", v)
	}
}