當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Msg.SetIxfr方法代碼示例

本文整理匯總了Golang中dns.Msg.SetIxfr方法的典型用法代碼示例。如果您正苦於以下問題:Golang Msg.SetIxfr方法的具體用法?Golang Msg.SetIxfr怎麽用?Golang Msg.SetIxfr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在dns.Msg的用法示例。


在下文中一共展示了Msg.SetIxfr方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: main

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)
	}
}
開發者ID:niltonkummer,項目名稱:dns,代碼行數:32,代碼來源:axfr.go

示例2: main

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)
	}
}
開發者ID:davecheney,項目名稱:godns,代碼行數:29,代碼來源:axfr.go

示例3: main

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)
	}
}
開發者ID:elazarl,項目名稱:godns,代碼行數:22,代碼來源:axfr.go


注:本文中的dns.Msg.SetIxfr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。