Skip to content

Commit 3a4bc98

Browse files
committed
Handle clientsCount in the local DoH handler, too
1 parent 0de2246 commit 3a4bc98

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

dnscrypt-proxy/local-doh.go

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ type localDoHHandler struct {
1818

1919
func (handler localDoHHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
2020
proxy := handler.proxy
21+
if !proxy.clientsCountInc() {
22+
dlog.Warnf("Too many incoming connections (max=%d)", proxy.maxClients)
23+
return
24+
}
25+
defer proxy.clientsCountDec()
2126
dataType := "application/dns-message"
2227
writer.Header().Set("Server", "dnscrypt-proxy")
2328
if request.URL.Path != proxy.localDoHPath {

dnscrypt-proxy/proxy.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func (proxy *Proxy) udpListener(clientPc *net.UDPConn) {
264264
go func() {
265265
start := time.Now()
266266
if !proxy.clientsCountInc() {
267-
dlog.Warnf("Too many connections (max=%d)", proxy.maxClients)
267+
dlog.Warnf("Too many incoming connections (max=%d)", proxy.maxClients)
268268
return
269269
}
270270
defer proxy.clientsCountDec()
@@ -294,7 +294,7 @@ func (proxy *Proxy) tcpListener(acceptPc *net.TCPListener) {
294294
start := time.Now()
295295
defer clientPc.Close()
296296
if !proxy.clientsCountInc() {
297-
dlog.Warnf("Too many connections (max=%d)", proxy.maxClients)
297+
dlog.Warnf("Too many incoming connections (max=%d)", proxy.maxClients)
298298
return
299299
}
300300
defer proxy.clientsCountDec()

0 commit comments

Comments
 (0)