fqdn the handlers
This commit is contained in:
parent
54360034e0
commit
7a885b0c6b
3
dns.go
3
dns.go
|
@ -185,6 +185,7 @@ func (h *RR_Header) Len() int {
|
|||
return l
|
||||
}
|
||||
|
||||
// find best matching pattern for zone
|
||||
func zoneMatch(pattern, zone string) (ok bool) {
|
||||
if len(pattern) == 0 {
|
||||
return
|
||||
|
@ -192,7 +193,7 @@ func zoneMatch(pattern, zone string) (ok bool) {
|
|||
if len(zone) == 0 {
|
||||
zone = "."
|
||||
}
|
||||
pattern = Fqdn(pattern)
|
||||
// pattern = Fqdn(pattern) // should already be a fqdn
|
||||
zone = Fqdn(zone)
|
||||
i := 0
|
||||
for {
|
||||
|
|
|
@ -24,7 +24,7 @@ func main() {
|
|||
if e := addZone(Z, *o, *z); e != nil {
|
||||
log.Fatal("Huh %s\n", e.Error())
|
||||
}
|
||||
dns.HandleFunc(*o, func(w dns.ResponseWriter, req *dns.Msg) { serve(w, req, Z[dns.Fqdn(*o)]) })
|
||||
dns.HandleFunc(*o, func(w dns.ResponseWriter, req *dns.Msg) { serve(w, req, Z[*o]) })
|
||||
go func() {
|
||||
err := dns.ListenAndServe(":8053", "udp", nil)
|
||||
if err != nil {
|
||||
|
|
|
@ -116,7 +116,7 @@ func (mux *ServeMux) Handle(pattern string, handler Handler) {
|
|||
if pattern == "" {
|
||||
panic("dns: invalid pattern " + pattern)
|
||||
}
|
||||
mux.m[pattern] = handler
|
||||
mux.m[dns.Fqdn(pattern)] = handler
|
||||
}
|
||||
|
||||
// Handle adds a handler to the ServeMux for pattern.
|
||||
|
@ -130,7 +130,7 @@ func (mux *ServeMux) HandleRemove(pattern string) {
|
|||
panic("dns: invalid pattern " + pattern)
|
||||
}
|
||||
// if its there, its gone
|
||||
delete(mux.m, pattern)
|
||||
delete(mux.m, Fqdn(pattern))
|
||||
}
|
||||
|
||||
// ServeDNS dispatches the request to the handler whose
|
||||
|
|
Loading…
Reference in New Issue