more sane logging
This commit is contained in:
parent
5e5d1228a0
commit
1e58ea2d5f
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"dns"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -24,10 +23,15 @@ func config(w dns.ResponseWriter, req *dns.Msg, c *Config) {
|
|||
// SUBSYSTEM. IN TXT "OPERATION<SPACE>OPTIONS..."
|
||||
// ZONE. IN TXT "READ origin /z/bloep" - absolute path in fs
|
||||
|
||||
// TODO: check tsig
|
||||
if *l {
|
||||
log.Printf("fksd: config commmand")
|
||||
if !req.IsUpdate() {
|
||||
logPrintf("non config command")
|
||||
m := new(dns.Msg)
|
||||
w.Write(m.SetRcode(req, dns.RcodeFormatError))
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: check tsig
|
||||
logPrintf("config commmand")
|
||||
for _, rr := range req.Ns {
|
||||
t, ok := rr.(*dns.RR_TXT)
|
||||
|
||||
|
@ -53,13 +57,9 @@ func configZONE(t *dns.RR_TXT, c *Config) error {
|
|||
}
|
||||
switch strings.ToUpper(sx[0]) {
|
||||
case "READ":
|
||||
if *l {
|
||||
log.Printf("fksd: config: READ %s %s\n", dns.Fqdn(sx[1]), sx[2])
|
||||
}
|
||||
logPrintf("config: READ %s %s\n", dns.Fqdn(sx[1]), sx[2])
|
||||
if e := c.ReadZone(dns.Fqdn(sx[1]), sx[2]); e != nil {
|
||||
if *l {
|
||||
log.Printf("fksd: failed to read %s: %s\n", sx[2], e.Error())
|
||||
}
|
||||
logPrintf("failed to read %s: %s\n", sx[2], e.Error())
|
||||
return e
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "log"
|
||||
|
||||
const NAME = "fksd: "
|
||||
|
||||
func logPrintf(format string, a ...interface{}) {
|
||||
if *l {
|
||||
log.Printf(NAME + format, a...)
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ forever:
|
|||
for {
|
||||
select {
|
||||
case <-sig:
|
||||
log.Printf("fksd: signal received, stopping\n")
|
||||
logPrintf("signal received, stopping")
|
||||
break forever
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"dns"
|
||||
"log"
|
||||
)
|
||||
|
||||
// Create skeleton edns opt RR from the query and
|
||||
|
@ -21,9 +20,7 @@ func serve(w dns.ResponseWriter, req *dns.Msg, z *dns.Zone) {
|
|||
if z == nil {
|
||||
panic("fksd: no zone")
|
||||
}
|
||||
if *l {
|
||||
log.Printf("fksd: [zone %s] incoming %s %s %d from %s\n", z.Origin, req.Question[0].Name, dns.Rr_str[req.Question[0].Qtype], req.MsgHdr.Id, w.RemoteAddr())
|
||||
}
|
||||
logPrintf("[zone %s] incoming %s %s %d from %s\n", z.Origin, req.Question[0].Name, dns.Rr_str[req.Question[0].Qtype], req.MsgHdr.Id, w.RemoteAddr())
|
||||
// Ds Handling
|
||||
// Referral
|
||||
// if we find something with NonAuth = true, it means
|
||||
|
|
1
msg.go
1
msg.go
|
@ -81,6 +81,7 @@ type Msg struct {
|
|||
MsgHdr
|
||||
Compress bool // If true, the message will be compressed when converted to wire format.
|
||||
Size int // Number of octects in the message received from the wire.
|
||||
// Remote addr? back
|
||||
Question []Question // Holds the RR(s) of the question section.
|
||||
Answer []RR // Holds the RR(s) of the answer section.
|
||||
Ns []RR // Holds the RR(s) of the authority section.
|
||||
|
|
Loading…
Reference in New Issue