API works, but it is not very nice (yet)

This commit is contained in:
Miek Gieben 2011-03-28 10:59:06 +02:00
parent 7cc589d52a
commit 5c28696357
3 changed files with 32 additions and 25 deletions

1
TODO
View File

@ -5,6 +5,7 @@ o fast data structures (rb-tree, when they come available)
o api-use should be self documenting
o multiple queries in api
o build simple: just query function, built on the cool stuff
o make questions fqdns -- add last dot
o zone structure -- only as rb-tree or other radix tree
o compression (only ownernames?)

20
dns.go
View File

@ -16,24 +16,30 @@
// The package dns supports querying, incoming/outgoing Axfr/Ixfr, TSIG, EDNS0,
// dynamic updates, notifies and DNSSEC validation/signing.
//
// Querying the DNS is done by using a Resolver structure. Basic use pattern for creating
// Querying the DNS is done by using the Conn structure. Basic use pattern for creating
// a resolver:
//
// res := new(Resolver)
// res.Servers = []string{"127.0.0.1"}
// func handle(d *Conn, m *Msg, q chan Query) { /* handle query */ }
//
// in := make(chan Query)
// out := QueryAndServeUDP(in, handle)
// d := new(Conn)
// d.RemoteAddr = "8.8.8.8:53"
// m := new(Msg)
// m.MsgHdr.Recursion_desired = true
// m.Question = make([]Question, 1)
// m.Question[0] = Question{"miek.nl", TypeSOA, ClassINET}
// in, err := res.Query(m)
//
// Server side programming is also supported.
// in <- Query{Msg: m, Conn: d} // Send query
// reply := <-out // Listen for replie(s)
//
// Server side programming is also supported also by using a Conn structure.
// Basic use pattern for creating an UDP DNS server:
//
// func handle(d *dns.Conn, i *dns.Msg) { /* handle request */ }
// func handle(d *Conn, m *Msg) { /* handle request */ }
//
// func listen(addr string, e chan os.Error) {
// err := dns.ListenAndServeUDP(addr, handle)
// err := ListenAndServeUDP(addr, handle)
// e <- err
// }
// err := make(chan os.Error)