Fix examples and add notify prog
Show how simple a dns-notify becomes.
This commit is contained in:
parent
b5de7e1745
commit
fc8e6345af
2
TODO
2
TODO
|
@ -1,6 +1,8 @@
|
|||
Todo:
|
||||
Short term:
|
||||
* Create example notify
|
||||
* NSEC(3) secure denial of existence, support the type bitmap
|
||||
- need base32 for Nsec3
|
||||
* TKEY -- RFC 2930 - validation
|
||||
* TSIG -- RFC 4635 - validation
|
||||
* Parsing from strings
|
||||
|
|
|
@ -4,6 +4,7 @@ all:
|
|||
gomake -C chaos
|
||||
gomake -C dnssectest
|
||||
gomake -C axfr
|
||||
gomake -C notify
|
||||
gomake -C zlutser
|
||||
|
||||
clean:
|
||||
|
@ -12,4 +13,5 @@ clean:
|
|||
gomake -C chaos clean
|
||||
gomake -C dnssectest clean
|
||||
gomake -C axfr clean
|
||||
gomake -C notify clean
|
||||
gomake -C zlutser clean
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# Copyright 2009 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
include $(GOROOT)/src/Make.inc
|
||||
TARG=notify
|
||||
GOFILES=notify.go
|
||||
include $(GOROOT)/src/Make.cmd
|
|
@ -0,0 +1,40 @@
|
|||
package main
|
||||
|
||||
// Send a DNS notify
|
||||
// (c) Miek Gieben - 2011
|
||||
import (
|
||||
"dns"
|
||||
"dns/resolver"
|
||||
"os"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := new(resolver.Resolver)
|
||||
qr := r.NewQuerier()
|
||||
r.Servers = []string{"127.0.0.1"}
|
||||
r.Timeout = 2
|
||||
r.Attempts = 1
|
||||
var in resolver.DnsMsg
|
||||
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Printf("%s NAMESERVER\n", os.Args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
m := new(dns.Msg)
|
||||
m.Question = make([]dns.Question, 1)
|
||||
m.Question[0] = dns.Question{"miek.nl", dns.TypeSOA, dns.ClassINET}
|
||||
m.MsgHdr.Opcode = dns.OpcodeNotify
|
||||
qr <- resolver.DnsMsg{m, nil}
|
||||
in = <-qr
|
||||
// if in.Dns != nil && in.Dns.Answer != nil {
|
||||
if in.Dns != nil {
|
||||
// fmt.Printf("%v\n", in.Dns.Answer[0])
|
||||
fmt.Printf("%v\n", in.Dns)
|
||||
}
|
||||
|
||||
// Stop the resolver, send it a null mesg
|
||||
qr <- resolver.DnsMsg{nil, nil}
|
||||
<-qr
|
||||
}
|
|
@ -80,9 +80,9 @@ FLAGS:
|
|||
if *dnssec {
|
||||
opt := new(dns.RR_OPT)
|
||||
opt.Hdr = dns.RR_Header{Name: "", Rrtype: dns.TypeOPT}
|
||||
opt.Version(0, true)
|
||||
opt.DoBit(true, true)
|
||||
opt.UDPSize(4096, true)
|
||||
opt.SetVersion(0)
|
||||
opt.SetDo()
|
||||
opt.SetUDPSize(4096)
|
||||
m.Extra = make([]dns.RR, 1)
|
||||
m.Extra[0] = opt
|
||||
}
|
||||
|
|
|
@ -81,9 +81,9 @@ FLAGS:
|
|||
// set the do bit
|
||||
opt := new(dns.RR_OPT)
|
||||
opt.Hdr = dns.RR_Header{Name: "", Rrtype: dns.TypeOPT}
|
||||
opt.Version(0, true)
|
||||
opt.DoBit(true, true)
|
||||
opt.UDPSize(4096, true)
|
||||
opt.SetVersion(0)
|
||||
opt.SetDo()
|
||||
opt.SetUDPSize(4096)
|
||||
m.Extra = make([]dns.RR, 1)
|
||||
m.Extra[0] = opt
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ func TestResolverEdns(t *testing.T) {
|
|||
m := new(dns.Msg)
|
||||
m.MsgHdr.RecursionDesired = true //only set this bit
|
||||
m.Question = make([]dns.Question, 1)
|
||||
m.Extra = make([]dns.RR, 1)
|
||||
|
||||
// Add EDNS rr
|
||||
edns := new(dns.RR_OPT)
|
||||
|
@ -25,13 +24,14 @@ func TestResolverEdns(t *testing.T) {
|
|||
edns.Hdr.Rrtype = dns.TypeOPT
|
||||
// You can handle an OTP RR as any other, but there
|
||||
// are some convience functions
|
||||
edns.SetUDPSize(4096)
|
||||
edns.SetUDPSize(2048)
|
||||
edns.SetDo()
|
||||
edns.Option = make([]dns.Option, 1)
|
||||
edns.SetNsidToHex("") // Empty to request it
|
||||
|
||||
// ask something
|
||||
m.Question[0] = dns.Question{"miek.nl", dns.TypeA, dns.ClassINET}
|
||||
m.Question[0] = dns.Question{"powerdns.nl", dns.TypeDNSKEY, dns.ClassINET}
|
||||
m.Extra = make([]dns.RR, 1)
|
||||
m.Extra[0] = edns
|
||||
|
||||
ch <- DnsMsg{m, nil}
|
||||
|
|
Loading…
Reference in New Issue