mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2024-12-11 22:35:40 +01:00
On overflow, only respond to cached/synthesized queries
This commit is contained in:
parent
da69583bd2
commit
e64425b5e7
@ -52,7 +52,7 @@ func (handler localDoHHandler) ServeHTTP(writer http.ResponseWriter, request *ht
|
|||||||
writer.WriteHeader(400)
|
writer.WriteHeader(400)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
response := proxy.processIncomingQuery("local_doh", proxy.mainProto, packet, &xClientAddr, nil, start)
|
response := proxy.processIncomingQuery("local_doh", proxy.mainProto, packet, &xClientAddr, nil, start, false)
|
||||||
if len(response) == 0 {
|
if len(response) == 0 {
|
||||||
writer.WriteHeader(500)
|
writer.WriteHeader(500)
|
||||||
return
|
return
|
||||||
|
@ -87,7 +87,7 @@ func (plugin *PluginDNS64) Eval(pluginsState *PluginsState, msg *dns.Msg) error
|
|||||||
if !plugin.proxy.clientsCountInc() {
|
if !plugin.proxy.clientsCountInc() {
|
||||||
return errors.New("Too many concurrent connections to handle DNS64 subqueries")
|
return errors.New("Too many concurrent connections to handle DNS64 subqueries")
|
||||||
}
|
}
|
||||||
respPacket := plugin.proxy.processIncomingQuery("trampoline", plugin.proxy.mainProto, msgAPacket, nil, nil, time.Now())
|
respPacket := plugin.proxy.processIncomingQuery("trampoline", plugin.proxy.mainProto, msgAPacket, nil, nil, time.Now(), false)
|
||||||
plugin.proxy.clientsCountDec()
|
plugin.proxy.clientsCountDec()
|
||||||
resp := dns.Msg{}
|
resp := dns.Msg{}
|
||||||
if err := resp.Unpack(respPacket); err != nil {
|
if err := resp.Unpack(respPacket); err != nil {
|
||||||
|
@ -371,12 +371,12 @@ func (proxy *Proxy) udpListener(clientPc *net.UDPConn) {
|
|||||||
packet := buffer[:length]
|
packet := buffer[:length]
|
||||||
if !proxy.clientsCountInc() {
|
if !proxy.clientsCountInc() {
|
||||||
dlog.Warnf("Too many incoming connections (max=%d)", proxy.maxClients)
|
dlog.Warnf("Too many incoming connections (max=%d)", proxy.maxClients)
|
||||||
proxy.processIncomingQuery("udp", proxy.mainProto, packet, &clientAddr, clientPc, time.Now()) // handle synchronously
|
proxy.processIncomingQuery("udp", proxy.mainProto, packet, &clientAddr, clientPc, time.Now(), true) // handle synchronously
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
defer proxy.clientsCountDec()
|
defer proxy.clientsCountDec()
|
||||||
proxy.processIncomingQuery("udp", proxy.mainProto, packet, &clientAddr, clientPc, time.Now())
|
proxy.processIncomingQuery("udp", proxy.mainProto, packet, &clientAddr, clientPc, time.Now(), false)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -405,7 +405,7 @@ func (proxy *Proxy) tcpListener(acceptPc *net.TCPListener) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
clientAddr := clientPc.RemoteAddr()
|
clientAddr := clientPc.RemoteAddr()
|
||||||
proxy.processIncomingQuery("tcp", "tcp", packet, &clientAddr, clientPc, start)
|
proxy.processIncomingQuery("tcp", "tcp", packet, &clientAddr, clientPc, start, false)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -573,7 +573,7 @@ func (proxy *Proxy) clientsCountDec() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string, query []byte, clientAddr *net.Addr, clientPc net.Conn, start time.Time) (response []byte) {
|
func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string, query []byte, clientAddr *net.Addr, clientPc net.Conn, start time.Time, onlyCached bool) (response []byte) {
|
||||||
if len(query) < MinDNSPacketSize {
|
if len(query) < MinDNSPacketSize {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -603,6 +603,9 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if onlyCached && len(response) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
if len(response) == 0 && serverInfo != nil {
|
if len(response) == 0 && serverInfo != nil {
|
||||||
var ttl *uint32
|
var ttl *uint32
|
||||||
pluginsState.serverName = serverName
|
pluginsState.serverName = serverName
|
||||||
|
Loading…
Reference in New Issue
Block a user