Skip to content

Commit b4607cf

Browse files
committed
Pull request: AGDNS-3523-imp-proxy
Merge in GO/dnsproxy from AGDNS-3523-imp-proxy to master Squashed commit of the following: commit c60921e Author: Dimitry Kolyshev <dkolyshev@adguard.com> Date: Thu Feb 19 12:09:12 2026 +0700 proxy: rm BeforeRequestHandler
1 parent 7b2e2e4 commit b4607cf

5 files changed

Lines changed: 2 additions & 227 deletions

File tree

proxy/beforerequest.go

Lines changed: 0 additions & 84 deletions
This file was deleted.

proxy/beforerequest_internal_test.go

Lines changed: 0 additions & 122 deletions
This file was deleted.

proxy/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ type Config struct {
5555
// performing a single lookup. If nil, it will be enabled by default.
5656
PendingRequests *PendingRequestsConfig
5757

58-
// BeforeRequestHandler is an optional custom handler called before each DNS
59-
// request is started processing, see [BeforeRequestHandler]. The default
60-
// no-op implementation is used, if it's nil.
61-
BeforeRequestHandler BeforeRequestHandler
62-
6358
// RequestHandler is an optional custom handler for DNS requests. It's used
6459
// instead of DefaultHandler if set. In case of [ErrDrop] error returned
6560
// from this handler, the proxy will not send any response to the client.

proxy/proxy.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,7 @@ type Proxy struct {
8787
// messages constructs DNS messages.
8888
messages MessageConstructor
8989

90-
// beforeRequestHandler handles the request's context before it is resolved.
91-
beforeRequestHandler BeforeRequestHandler
92-
93-
// requestHandler handles the DNS request after it's been processed by the
94-
// beforeRequestHandler. It is never nil.
90+
// requestHandler handles the DNS request. It is never nil.
9591
requestHandler Handler
9692

9793
// dnsCryptServer serves DNSCrypt queries.
@@ -219,10 +215,6 @@ func New(c *Config) (p *Proxy, err error) {
219215
c.PrivateSubnets,
220216
netutil.SubnetSetFunc(netutil.IsLocallyServed),
221217
),
222-
beforeRequestHandler: cmp.Or[BeforeRequestHandler](
223-
c.BeforeRequestHandler,
224-
noopRequestHandler{},
225-
),
226218
requestHandler: cmp.Or[Handler](c.RequestHandler, DefaultHandler{}),
227219
upstreamRTTStats: map[string]upstreamRTTStats{},
228220
rttLock: sync.Mutex{},

proxy/server.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ func (p *Proxy) serveListeners() {
8989
}
9090

9191
// handleDNSRequest processes the context. The only error it returns is the one
92-
// from the [Handler], or [Resolve] if the [Handler] is not set. d is left
93-
// without a response as the documentation to [BeforeRequestHandler] says, and
94-
// if it's ratelimited.
92+
// from the [Handler], or [Resolve] if the [Handler] is not set.
9593
func (p *Proxy) handleDNSRequest(d *DNSContext) (err error) {
9694
p.logDNSMessage(d.Req)
9795

@@ -104,10 +102,6 @@ func (p *Proxy) handleDNSRequest(d *DNSContext) (err error) {
104102
ip := d.Addr.Addr()
105103
d.IsPrivateClient = p.privateNets.Contains(ip)
106104

107-
if !p.handleBefore(d) {
108-
return nil
109-
}
110-
111105
// TODO(d.kolyshev): Consider moving validation to a new middleware.
112106
d.Res = p.validateRequest(d)
113107
if d.Res == nil {

0 commit comments

Comments
 (0)