Update fks-shield and remove ListenAndServeTsig

ListenAndServeTsig can be handled much more easier
if you create your own server object
This commit is contained in:
Miek Gieben 2012-08-08 09:19:14 +02:00
parent fadc0b3a95
commit 8646c8c6e6
4 changed files with 14 additions and 18 deletions

View File

@ -31,6 +31,8 @@ type Cache struct {
*radix.Radix
}
// Make an as-is copy, except for the first two bytes, as these hold
// the DNS id.
func quickCopy(p []byte) []byte {
q := make([]byte, 2)
q = append(q, p[2:]...)

View File

@ -42,12 +42,6 @@ func serve(w dns.ResponseWriter, r *dns.Msg, c *Cache) {
}
}
func listenAndServe(add, net string) {
if err := dns.ListenAndServe(add, net, nil); err != nil {
log.Fatal("fks-shield: failed to setup %s %s", net, add)
}
}
func main() {
flag.Usage = func() {
flag.PrintDefaults()
@ -55,11 +49,14 @@ func main() {
flag.Parse()
cache := NewCache()
dns.HandleFunc(".", func(w dns.ResponseWriter, r *dns.Msg) { serve(w, r, cache) })
go listenAndServe(*listen, "tcp")
go listenAndServe(*listen, "udp")
// Only listen on UDP
go func() {
if err := dns.ListenAndServe(*listen, "udp", nil); err != nil {
log.Fatal("fks-shield: failed to setup %s %s", net, add)
}
}
sig := make(chan os.Signal)
forever:

View File

@ -8,6 +8,7 @@ We have defined the following groups:
* `SYSTEM`: for system management?
* `...`: ...
Better stuff then add and set
# ZONE
@ -27,7 +28,11 @@ Zones are listed in the additional section of the reply packet
# USER
USER. TXT "ADD miekg base64-tsig-secret"
USER. TXT "ADD miekg"
USER. TXT "DROP miekg"
USER. TXT "ADDTSIG miekg base64-tsig-secret"
USER. TXT "ADDPOWER miekg list" // list/write/drop
USER. TXT "DROPPOWER miekg list"
The config is internally stored in some memory structure

View File

@ -93,14 +93,6 @@ func ListenAndServe(addr string, network string, handler Handler) error {
return server.ListenAndServe()
}
// Start a server on addresss and network speficied. Use the tsig
// secrets for Tsig validation.
// Invoke handler for any incoming queries.
func ListenAndServeTsig(addr string, network string, handler Handler, tsig map[string]string) error {
server := &Server{Addr: addr, Net: network, Handler: handler, TsigSecret: tsig}
return server.ListenAndServe()
}
func (mux *ServeMux) match(zone string, t uint16) Handler {
// Exact match
zone = toRadixName(zone)