adapt chaos.go to the new api
This commit is contained in:
parent
7b4a5eca06
commit
dd2b4e5b35
46
TODO
46
TODO
|
@ -2,17 +2,13 @@ Issues:
|
|||
* FunkenSturm is kaput.
|
||||
* Check the network order, it works now, but this is on Intel??
|
||||
* Make the testsuite work with public DNS servers
|
||||
* pack/Unpack smaller. EDNS 'n stuff can be folded in
|
||||
* pack/Unpack smaller. EDNS 'n stuff can be folded in???
|
||||
* Compression. Take stuff from Jan Mercl
|
||||
o Tsig will probably become an interface which has all configuration
|
||||
stuff, but this will come later. Config which has Tsig function
|
||||
-- get TSIG working in xfrprx and see how that impact the package.
|
||||
|
||||
responseWriter with tsig/axfr/ixfr
|
||||
requestWriter
|
||||
TsigReader
|
||||
|
||||
XfrWriter ??? XfrReader???
|
||||
XfrWriter
|
||||
|
||||
Todo:
|
||||
* Parsing from strings, going with goyacc and .cz lexer?
|
||||
|
@ -23,41 +19,3 @@ Todo:
|
|||
|
||||
Examples:
|
||||
* Test impl of nameserver, with a small zone, 1 KSK and online signing
|
||||
|
||||
ListenAndServer(addr, Handler, map[string]string, tsig secrets)
|
||||
|
||||
add tis record to mesag when sending -> tsig will be calculated
|
||||
up to the aolloer .Msg TsigGenerate
|
||||
|
||||
handler Handler === interface that
|
||||
|
||||
Hanlder interface {
|
||||
ServeDNS
|
||||
|
||||
QueryDNS
|
||||
}
|
||||
|
||||
ResponseWriter
|
||||
UsingTsig() domain/ip/key
|
||||
UsingTCP()
|
||||
|
||||
RemoteAddr string
|
||||
|
||||
Write(byte) n os.Error
|
||||
|
||||
|
||||
125 // Create new connection from rwc.
|
||||
126 func newConn(rwc net.Conn, handler Handler) (c *conn, err os.Error) {
|
||||
127 c = new(conn)
|
||||
128 c.remoteAddr = rwc.RemoteAddr().String()
|
||||
129 c.handler = handler
|
||||
130 c.rwc = rwc
|
||||
131 _, c.usingTLS = rwc.(*tls.Conn)
|
||||
132 br := bufio.NewReader(rwc)
|
||||
133 bw := bufio.NewWriter(rwc)
|
||||
134 c.buf = bufio.NewReadWriter(br, bw)
|
||||
135 return c, nil
|
||||
|
||||
func HelloServer(w dns.ResponseWriter, req *dns.Msg)
|
||||
|
||||
dns.HandleFunc("zonename", HelloServer)
|
||||
|
|
|
@ -10,66 +10,65 @@ import (
|
|||
)
|
||||
|
||||
func main() {
|
||||
config, _ := dns.ClientConfigFromFile("/etc/resolv.conf")
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Printf("%s DOMAIN\n", os.Args[0])
|
||||
fmt.Printf("%s NAMESERVER\n", os.Args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
conf, _ := dns.ClientConfigFromFile("/etc/resolv.conf")
|
||||
|
||||
m := new(dns.Msg)
|
||||
m.SetQuestion(
|
||||
m.Question = make([]dns.Question, 1)
|
||||
for _, a := range addresses(config, os.Args[0]) {
|
||||
d.RemoteAddr = a
|
||||
if err := d.Dial("udp"); err != nil {
|
||||
fmt.Printf("%v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
c := dns.NewClient()
|
||||
|
||||
// Todo: in parallel
|
||||
addr := addresses(conf, c, os.Args[0])
|
||||
if len(addr) == 0 {
|
||||
fmt.Printf("No address found for %s\n", os.Args[1])
|
||||
os.Exit(1)
|
||||
}
|
||||
for _, a := range addr {
|
||||
m.Question[0] = dns.Question{"version.bind.", dns.TypeTXT, dns.ClassCHAOS}
|
||||
in, _ := dns.SimpleQuery("udp", d, m)
|
||||
in := c.Exchange(m, a)
|
||||
if in != nil && in.Answer != nil {
|
||||
fmt.Printf("%v\n", in.Answer[0])
|
||||
}
|
||||
m.Question[0] = dns.Question{"hostname.bind.", dns.TypeTXT, dns.ClassCHAOS}
|
||||
in, _ = dns.SimpleQuery("udp", d, m)
|
||||
in = c.Exchange(m, a)
|
||||
if in != nil && in.Answer != nil {
|
||||
fmt.Printf("%v\n", in.Answer[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func addresses(config *dns.ClientConfig, name string) []string {
|
||||
func addresses(conf *dns.ClientConfig, c *dns.Client, name string) []string {
|
||||
m := new(dns.Msg)
|
||||
m.SetQuestion(os.Args[1], dns.TypeA)
|
||||
m.MsgHdr.RecursionDesired = true //only set this bit
|
||||
m.SetQuestion(os.Args[1], dns.TypeA) // Allocates space
|
||||
var ips []string
|
||||
|
||||
in, err := dns.SimpleQuery("udp", d, m)
|
||||
if in == nil {
|
||||
fmt.Printf("Nothing recevied: %s\n", err.String())
|
||||
r := c.Exchange(m, conf.Servers[0])
|
||||
if r == nil {
|
||||
fmt.Printf("Nothing recevied for %s\n", name)
|
||||
return nil
|
||||
}
|
||||
|
||||
if in.Rcode != dns.RcodeSuccess {
|
||||
if r.Rcode != dns.RcodeSuccess {
|
||||
return nil
|
||||
}
|
||||
// Stuff must be in the answer section
|
||||
for _, a := range in.Answer {
|
||||
for _, a := range r.Answer {
|
||||
ips = append(ips, a.(*dns.RR_A).A.String()+":53")
|
||||
}
|
||||
m.Question[0] = dns.Question{os.Args[1], dns.TypeAAAA, dns.ClassINET}
|
||||
in, err = dns.SimpleQuery("udp", d, m)
|
||||
if in == nil {
|
||||
fmt.Printf("Nothing recevied: %s\n", err.String())
|
||||
return ips
|
||||
}
|
||||
|
||||
if in.Rcode != dns.RcodeSuccess {
|
||||
m.SetQuestion(os.Args[1], dns.TypeAAAA)
|
||||
r = c.Exchange(m, conf.Servers[0])
|
||||
if r == nil {
|
||||
fmt.Printf("Nothing recevied for %s\n", name)
|
||||
return ips
|
||||
}
|
||||
for _, a := range in.Answer {
|
||||
if r.Rcode != dns.RcodeSuccess {
|
||||
return ips
|
||||
}
|
||||
for _, a := range r.Answer {
|
||||
ips = append(ips, "["+a.(*dns.RR_AAAA).AAAA.String()+"]:53")
|
||||
}
|
||||
|
||||
return ips
|
||||
}
|
||||
|
|
|
@ -211,10 +211,11 @@ func (c *Client) Exchange(m *Msg, a string) *Msg {
|
|||
return nil
|
||||
}
|
||||
p = p[:n]
|
||||
if ok := m.Unpack(p); !ok {
|
||||
r := new(Msg)
|
||||
if ok := r.Unpack(p); !ok {
|
||||
return nil
|
||||
}
|
||||
return m
|
||||
return r
|
||||
}
|
||||
|
||||
func (w *reply) WriteMessages(m []*Msg) {
|
||||
|
|
|
@ -9,7 +9,6 @@ func TestClientSync(t *testing.T) {
|
|||
m.SetQuestion("miek.nl", TypeSOA)
|
||||
|
||||
c := NewClient()
|
||||
c.Net = "udp"
|
||||
r := c.Exchange(m, "85.223.71.124:53")
|
||||
|
||||
if r != nil && r.Rcode != RcodeSuccess {
|
||||
|
|
Loading…
Reference in New Issue