Handle clientsCount in the local DoH handler, too
This commit is contained in:
parent
0de2246af2
commit
3a4bc98073
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue