本文整理汇总了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)
}
}
示例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)
}
}
示例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)
}
}