diff --git a/dnscrypt-proxy/local-doh.go b/dnscrypt-proxy/local-doh.go index 4b64b3b1..50e0265c 100644 --- a/dnscrypt-proxy/local-doh.go +++ b/dnscrypt-proxy/local-doh.go @@ -18,6 +18,11 @@ type localDoHHandler struct { func (handler localDoHHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) { proxy := handler.proxy + if !proxy.clientsCountInc() { + dlog.Warnf("Too many incoming connections (max=%d)", proxy.maxClients) + return + } + defer proxy.clientsCountDec() dataType := "application/dns-message" writer.Header().Set("Server", "dnscrypt-proxy") if request.URL.Path != proxy.localDoHPath { diff --git a/dnscrypt-proxy/proxy.go b/dnscrypt-proxy/proxy.go index 6109ccf6..ba3822da 100644 --- a/dnscrypt-proxy/proxy.go +++ b/dnscrypt-proxy/proxy.go @@ -264,7 +264,7 @@ func (proxy *Proxy) udpListener(clientPc *net.UDPConn) { go func() { start := time.Now() if !proxy.clientsCountInc() { - dlog.Warnf("Too many connections (max=%d)", proxy.maxClients) + dlog.Warnf("Too many incoming connections (max=%d)", proxy.maxClients) return } defer proxy.clientsCountDec() @@ -294,7 +294,7 @@ func (proxy *Proxy) tcpListener(acceptPc *net.TCPListener) { start := time.Now() defer clientPc.Close() if !proxy.clientsCountInc() { - dlog.Warnf("Too many connections (max=%d)", proxy.maxClients) + dlog.Warnf("Too many incoming connections (max=%d)", proxy.maxClients) return } defer proxy.clientsCountDec()