add err check

master
dingjun 2 years ago
parent 9d3d523309
commit f8a6b1bb0a

@ -52,7 +52,9 @@ func (srv *server) handleHTTPReq(w http.ResponseWriter, r *http.Request) {
} }
w.Header().Set("content-type", dnsMsgType) w.Header().Set("content-type", dnsMsgType)
d, _ := m.Pack() d, _ := m.Pack()
w.Write(d) if _, err := w.Write(d); err != nil {
log.Errorln(err)
}
} }
func (srv *server) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (srv *server) ServeHTTP(w http.ResponseWriter, r *http.Request) {

@ -27,6 +27,9 @@ func (srv *server) handleTCP(c net.Conn) {
for _, a := range m.Answer { for _, a := range m.Answer {
log.Debugln("result", a.String()) log.Debugln("result", a.String())
} }
conn.WriteMsg(m) if err := conn.WriteMsg(m); err != nil {
log.Errorln(err)
break
}
} }
} }

@ -24,5 +24,7 @@ func (srv *server) handleUDP(buf []byte, addr net.Addr, conn *net.UDPConn) {
log.Debugln("result", a.String()) log.Debugln("result", a.String())
} }
d, _ := m.Pack() d, _ := m.Pack()
conn.WriteTo(d, addr) if _, err := conn.WriteTo(d, addr); err != nil {
log.Errorln(err)
}
} }

Loading…
Cancel
Save