small updates

This commit is contained in:
Miek Gieben 2011-03-15 23:12:20 +01:00
parent 98f1f80088
commit aa7d08bc8a
4 changed files with 82 additions and 49 deletions

View File

@ -7,18 +7,19 @@ include $(GOROOT)/src/Make.inc
TARG=dns
GOFILES=\
dns.go\
msg.go\
types.go\
edns.go\
tsig.go\
dnssec.go\
keygen.go\
string.go\
resolver.go\
config.go\
server.go \
dns.go\
dnssec.go\
edns.go\
keygen.go\
msg.go\
notify.go\
nsec3.go \
resolver.go\
server.go \
string.go\
tsig.go\
types.go\
# y.go\
include $(GOROOT)/src/Make.pkg

20
notify.go Normal file
View File

@ -0,0 +1,20 @@
package dns
// Create a notify request packet.
func (dns *Msg) SetNotifyRequest(z string, class uint16) {
dns.MsgHdr.Opcode = OpcodeNotify
dns.MsgHdr.Authoritative = true
dns.MsgHdr.Id = Id()
dns.Question = make([]Question, 1)
dns.Question[0] = Question{z, TypeSOA, class}
}
// Create a notify reply packet.
func (dns *Msg) SetNotifyReply(z string, class, id uint16) {
dns.MsgHdr.Opcode = OpcodeNotify
dns.MsgHdr.Authoritative = true
dns.MsgHdr.Response = true
dns.MsgHdr.Id = id
dns.Question = make([]Question, 1)
dns.Question[0] = Question{z, TypeSOA, class}
}

View File

@ -5,6 +5,7 @@
// DNS resolver client: see RFC 1035.
package dns
// TODO: refacter this
import (
"os"
@ -31,6 +32,10 @@ type Resolver struct {
Rrb int // Last used server (for round robin)
}
func (res *Resolver) QueryTSIG(q *Msg, secret *string) (d *Msg, err os.Error) {
return nil,nil
}
// Basic usage pattern for setting up a resolver:
//
// res := new(Resolver)

View File

@ -11,6 +11,13 @@ import (
"net"
)
type Server struct {
ServeUDP func(*net.UDPConn, net.Addr, *Msg) os.Error
ServeTCP func(*net.TCPConn, net.Addr, *Msg) os.Error
/* notify stuff here? */
/* tsig here */
}
func ServeUDP(l *net.UDPConn, f func(*net.UDPConn, net.Addr, *Msg)) os.Error {
for {
m := make([]byte, DefaultMsgSize)