You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gdns/server_tcp.go

33 lines
579 B
Go

package main
import (
"net"
log "github.com/fangdingjun/go-log/v5"
"github.com/miekg/dns"
)
func (srv *server) handleTCP(c net.Conn) {
defer c.Close()
log.Debugln("tcp from", c.RemoteAddr())
conn := dns.Conn{Conn: c}
for {
msg, err := conn.ReadMsg()
if err != nil {
log.Debugln("tcp read message", err)
break
}
m, err := getResponseFromUpstream(msg, srv.upstreams)
if err != nil {
log.Debugln("query", msg.Question[0].String(), "timeout")
break
}
for _, a := range m.Answer {
log.Debugln("result", a.String())
}
conn.WriteMsg(m)
}
}