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) {
|
func (handler localDoHHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
|
||||||
proxy := handler.proxy
|
proxy := handler.proxy
|
||||||
|
if !proxy.clientsCountInc() {
|
||||||
|
dlog.Warnf("Too many incoming connections (max=%d)", proxy.maxClients)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer proxy.clientsCountDec()
|
||||||
dataType := "application/dns-message"
|
dataType := "application/dns-message"
|
||||||
writer.Header().Set("Server", "dnscrypt-proxy")
|
writer.Header().Set("Server", "dnscrypt-proxy")
|
||||||
if request.URL.Path != proxy.localDoHPath {
|
if request.URL.Path != proxy.localDoHPath {
|
||||||
|
|
|
@ -264,7 +264,7 @@ func (proxy *Proxy) udpListener(clientPc *net.UDPConn) {
|
||||||
go func() {
|
go func() {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
if !proxy.clientsCountInc() {
|
if !proxy.clientsCountInc() {
|
||||||
dlog.Warnf("Too many connections (max=%d)", proxy.maxClients)
|
dlog.Warnf("Too many incoming connections (max=%d)", proxy.maxClients)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer proxy.clientsCountDec()
|
defer proxy.clientsCountDec()
|
||||||
|
@ -294,7 +294,7 @@ func (proxy *Proxy) tcpListener(acceptPc *net.TCPListener) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
defer clientPc.Close()
|
defer clientPc.Close()
|
||||||
if !proxy.clientsCountInc() {
|
if !proxy.clientsCountInc() {
|
||||||
dlog.Warnf("Too many connections (max=%d)", proxy.maxClients)
|
dlog.Warnf("Too many incoming connections (max=%d)", proxy.maxClients)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer proxy.clientsCountDec()
|
defer proxy.clientsCountDec()
|
||||||
|
|
Loading…
Reference in New Issue