From 7a1bca95382aa9f1c2fad350d9bf8f75d0edd5de Mon Sep 17 00:00:00 2001 From: IrineSistiana <49315432+IrineSistiana@users.noreply.github.com> Date: Tue, 9 Feb 2021 00:04:19 +0800 Subject: [PATCH] remove server max_concurrent_queries_pre_client --- .../pkg/server_handler/server_handler.go | 27 +------------------ dispatcher/plugin/server/server.go | 14 +++++----- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/dispatcher/pkg/server_handler/server_handler.go b/dispatcher/pkg/server_handler/server_handler.go index e0de06372..37b3ba493 100644 --- a/dispatcher/pkg/server_handler/server_handler.go +++ b/dispatcher/pkg/server_handler/server_handler.go @@ -53,15 +53,8 @@ type DefaultServerHandlerConfig struct { // If ConcurrentLimit <= 0, means no limit. // When calling DefaultServerHandler.ServeDNS(), if a query exceeds the limit, it will wait on a FIFO queue until // - its ctx is done -> The query will be dropped silently. - // - it can be proceed -> Normal procedure. + // - it can be proceeded -> Normal procedure. ConcurrentLimit int - - // ConcurrentLimitPreClient controls the max concurrent queries for the pre client. - // If ConcurrentLimitPreClient <= 0, means no limit. - // It uses qCtx.From() as the identification of clients. - // When calling DefaultServerHandler.ServeDNS(), if a client query exceeds the limit, - // an REFUSED response will be returned to client. - ConcurrentLimitPreClient int } // NewDefaultServerHandler @@ -73,9 +66,6 @@ func NewDefaultServerHandler(config *DefaultServerHandlerConfig) *DefaultServerH h.limiter = concurrent_limiter.NewConcurrentLimiter(config.ConcurrentLimit) } - if config.ConcurrentLimitPreClient > 0 { - h.clientLimiter = concurrent_limiter.NewClientQueryLimiter(config.ConcurrentLimitPreClient) - } return h } @@ -89,21 +79,6 @@ func (h *DefaultServerHandler) ServeDNS(ctx context.Context, qCtx *handler.Conte } } - if h.clientLimiter != nil { - addr := qCtx.From() - if addr != nil { - key := addr.String() - if h.clientLimiter.Acquire(key) != true { - r := new(dns.Msg) - r.SetReply(qCtx.Q()) - r.Rcode = dns.RcodeRefused - write(r) - return - } - defer h.clientLimiter.Done(key) - } - } - if h.limiter != nil { select { case <-h.limiter.Wait(): diff --git a/dispatcher/plugin/server/server.go b/dispatcher/plugin/server/server.go index 816dbd051..d204a47ab 100644 --- a/dispatcher/plugin/server/server.go +++ b/dispatcher/plugin/server/server.go @@ -51,10 +51,9 @@ type ServerGroup struct { } type Args struct { - Server []*Server `yaml:"server"` - Entry []interface{} `yaml:"entry"` - MaxConcurrentQueries int `yaml:"max_concurrent_queries"` - MaxConcurrentQueriesPreClient int `yaml:"max_concurrent_queries_pre_client"` + Server []*Server `yaml:"server"` + Entry []interface{} `yaml:"entry"` + MaxConcurrentQueries int `yaml:"max_concurrent_queries"` } // Server is not safe for concurrent use. @@ -106,10 +105,9 @@ func newServerPlugin(bp *handler.BP, args *Args) (*ServerGroup, error) { } sh := server_handler.NewDefaultServerHandler(&server_handler.DefaultServerHandlerConfig{ - Logger: bp.L(), - Entry: ecs, - ConcurrentLimit: args.MaxConcurrentQueries, - ConcurrentLimitPreClient: args.MaxConcurrentQueriesPreClient, + Logger: bp.L(), + Entry: ecs, + ConcurrentLimit: args.MaxConcurrentQueries, }) sg := NewServerGroup(bp, sh, args.Server)