Browse Source

Improve logging output

master
Lyndsay Roger 9 years ago
parent
commit
0a8740b01d
  1. 3
      crawler.go
  2. 12
      server.go

3
crawler.go

@ -52,9 +52,10 @@ func crawlTwistee(tw *Twistee) {
// no more to do so return which will shutdown the goroutine & call // no more to do so return which will shutdown the goroutine & call
// the deffered cleanup // the deffered cleanup
if config.verbose { if config.verbose {
log.Printf("debug - failed crawl: twistee %s newstatus: %v:%v\n", log.Printf("debug - failed crawl: twistee %s failcount: %v newstatus: %v:%v\n",
net.JoinHostPort(tw.na.IP.String(), net.JoinHostPort(tw.na.IP.String(),
strconv.Itoa(int(tw.na.Port))), strconv.Itoa(int(tw.na.Port))),
tw.connectFails,
tw.status, tw.status,
tw.rating) tw.rating)
} }

12
server.go

@ -143,21 +143,25 @@ func handleDNSStd(w dns.ResponseWriter, r *dns.Msg) {
}} }}
m.SetReply(r) m.SetReply(r)
var qtype string
switch r.Question[0].Qtype { switch r.Question[0].Qtype {
case dns.TypeA: case dns.TypeA:
latest.mtx.RLock() latest.mtx.RLock()
m.Answer = getv4stdRR() m.Answer = getv4stdRR()
latest.mtx.RUnlock() latest.mtx.RUnlock()
qtype = "A"
case dns.TypeAAAA: case dns.TypeAAAA:
latest.mtx.RLock() latest.mtx.RLock()
m.Answer = getv6stdRR() m.Answer = getv6stdRR()
latest.mtx.RUnlock() latest.mtx.RUnlock()
qtype = "AAAA"
default: default:
// return no answer to all other queries // return no answer to all other queries
} }
if config.verbose { if config.verbose {
log.Printf("debug - standard port DNS response to ip: %s\n", w.RemoteAddr().String()) log.Printf("debug - standard port DNS response to ip: %s Query Type: %s\n", w.RemoteAddr().String(), qtype)
} }
// FIXME - add stats and query counts // FIXME - add stats and query counts
@ -175,21 +179,25 @@ func handleDNSNon(w dns.ResponseWriter, r *dns.Msg) {
}} }}
m.SetReply(r) m.SetReply(r)
var qtype string
switch r.Question[0].Qtype { switch r.Question[0].Qtype {
case dns.TypeA: case dns.TypeA:
latest.mtx.RLock() latest.mtx.RLock()
m.Answer = getv4nonRR() m.Answer = getv4nonRR()
latest.mtx.RUnlock() latest.mtx.RUnlock()
qtype = "A"
case dns.TypeAAAA: case dns.TypeAAAA:
latest.mtx.RLock() latest.mtx.RLock()
m.Answer = getv6nonRR() m.Answer = getv6nonRR()
latest.mtx.RUnlock() latest.mtx.RUnlock()
qtype = "AAAA"
default: default:
// return no answer to all other queries // return no answer to all other queries
} }
if config.verbose { if config.verbose {
log.Printf("debug - non standard port DNS response to ip: %s\n", w.RemoteAddr().String()) log.Printf("debug - non standard port DNS response to ip: %s Query Type: %s\n", w.RemoteAddr().String(), qtype)
} }
// FIXME - add stats and query counts // FIXME - add stats and query counts

Loading…
Cancel
Save