mirror of
https://github.com/miekg/dns.git
synced 2025-10-20 14:21:01 +02:00
small updates
This commit is contained in:
parent
98f1f80088
commit
aa7d08bc8a
21
Makefile
21
Makefile
@ -7,18 +7,19 @@ include $(GOROOT)/src/Make.inc
|
|||||||
|
|
||||||
TARG=dns
|
TARG=dns
|
||||||
GOFILES=\
|
GOFILES=\
|
||||||
dns.go\
|
|
||||||
msg.go\
|
|
||||||
types.go\
|
|
||||||
edns.go\
|
|
||||||
tsig.go\
|
|
||||||
dnssec.go\
|
|
||||||
keygen.go\
|
|
||||||
string.go\
|
|
||||||
resolver.go\
|
|
||||||
config.go\
|
config.go\
|
||||||
server.go \
|
dns.go\
|
||||||
|
dnssec.go\
|
||||||
|
edns.go\
|
||||||
|
keygen.go\
|
||||||
|
msg.go\
|
||||||
|
notify.go\
|
||||||
nsec3.go \
|
nsec3.go \
|
||||||
|
resolver.go\
|
||||||
|
server.go \
|
||||||
|
string.go\
|
||||||
|
tsig.go\
|
||||||
|
types.go\
|
||||||
# y.go\
|
# y.go\
|
||||||
|
|
||||||
include $(GOROOT)/src/Make.pkg
|
include $(GOROOT)/src/Make.pkg
|
||||||
|
20
notify.go
Normal file
20
notify.go
Normal 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}
|
||||||
|
}
|
@ -5,6 +5,7 @@
|
|||||||
// DNS resolver client: see RFC 1035.
|
// DNS resolver client: see RFC 1035.
|
||||||
|
|
||||||
package dns
|
package dns
|
||||||
|
// TODO: refacter this
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
@ -31,6 +32,10 @@ type Resolver struct {
|
|||||||
Rrb int // Last used server (for round robin)
|
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:
|
// Basic usage pattern for setting up a resolver:
|
||||||
//
|
//
|
||||||
// res := new(Resolver)
|
// res := new(Resolver)
|
||||||
|
11
server.go
11
server.go
@ -11,6 +11,13 @@ import (
|
|||||||
"net"
|
"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 {
|
func ServeUDP(l *net.UDPConn, f func(*net.UDPConn, net.Addr, *Msg)) os.Error {
|
||||||
for {
|
for {
|
||||||
m := make([]byte, DefaultMsgSize)
|
m := make([]byte, DefaultMsgSize)
|
||||||
@ -20,7 +27,7 @@ func ServeUDP(l *net.UDPConn, f func(*net.UDPConn, net.Addr, *Msg)) os.Error {
|
|||||||
}
|
}
|
||||||
m = m[:n]
|
m = m[:n]
|
||||||
msg := new(Msg)
|
msg := new(Msg)
|
||||||
if ! msg.Unpack(m) {
|
if !msg.Unpack(m) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
go f(l, radd, msg)
|
go f(l, radd, msg)
|
||||||
@ -59,7 +66,7 @@ func ServeTCP(l *net.TCPListener, f func(*net.TCPConn, net.Addr, *Msg)) os.Error
|
|||||||
i += n
|
i += n
|
||||||
}
|
}
|
||||||
msg := new(Msg)
|
msg := new(Msg)
|
||||||
if ! msg.Unpack(m) {
|
if !msg.Unpack(m) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
go f(c, c.RemoteAddr(), msg)
|
go f(c, c.RemoteAddr(), msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user