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