mirror of
https://github.com/AdguardTeam/dnsproxy.git
synced 2026-10-12 10:09:55 +00:00
Merge in GO/dnsproxy from AGDNS-3523-use-ratelimit to master
Squashed commit of the following:
commit a0c0d529cfd73efc907c60e7d69782104478363d
Merge: f18c897 68457db
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Feb 18 09:36:55 2026 +0700
Merge remote-tracking branch 'origin/master' into AGDNS-3523-use-ratelimit
# Conflicts:
# proxy/serverquic_internal_test.go
commit f18c897aa76cb1b989ff9c49d31c3c0712ae3502
Author: Dimitry Kolyshev <[email protected]>
Date: Wed Feb 18 09:31:02 2026 +0700
proxy: imp code
commit 13774cd2ada5fdd9c74175f5a072035e5d0fc808
Author: Dimitry Kolyshev <[email protected]>
Date: Tue Feb 17 09:04:46 2026 +0700
proxy: mv req validation
commit 8ab8031e1640b26e9ad82a1b6997d6e8b408fc2c
Author: Dimitry Kolyshev <[email protected]>
Date: Tue Feb 17 08:51:55 2026 +0700
cmd: imp code
commit bfa1c9e769e4739800df86ad6a590474a742e56f
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Feb 16 13:00:42 2026 +0700
ratelimit: imp
commit f7ae7e789f9b8c4e976b3fbb3f7356071cb2ccb9
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Feb 16 11:40:45 2026 +0700
proxy: imp tests
commit 29ed8323b2ca98a1623b50409223877a385d624b
Author: Dimitry Kolyshev <[email protected]>
Date: Mon Feb 16 11:30:20 2026 +0700
all: use ratelimit mw
41 lines
1.3 KiB
Go
41 lines
1.3 KiB
Go
package proxy
|
|
|
|
import "github.com/AdguardTeam/golibs/errors"
|
|
|
|
// ErrDrop is returned by a [Handler] to signal that the proxy should not send
|
|
// any response to the client.
|
|
const ErrDrop errors.Error = "drop response"
|
|
|
|
// Handler is an interface for handling DNS requests.
|
|
type Handler interface {
|
|
// ServeDNS resolves the DNS request within *DNSContext.
|
|
//
|
|
// TODO(e.burkov): Use the [context.Context] instead of [*DNSContext].
|
|
ServeDNS(p *Proxy, dctx *DNSContext) (err error)
|
|
}
|
|
|
|
// DefaultHandler implements [Handler] by calling [Proxy.Resolve]. It is used
|
|
// as a default handler if no other handler is specified.
|
|
type DefaultHandler struct{}
|
|
|
|
// type check
|
|
var _ Handler = DefaultHandler{}
|
|
|
|
// ServeDNS implements the [Handler] interface for DefaultHandler.
|
|
func (DefaultHandler) ServeDNS(p *Proxy, proxyCtx *DNSContext) (err error) {
|
|
return p.Resolve(proxyCtx)
|
|
}
|
|
|
|
// The HandlerFunc type is an adapter to allow the use of ordinary functions as
|
|
// [Handler]. If f is a function with the appropriate signature, HandlerFunc(f)
|
|
// is a [Handler] that calls f.
|
|
type HandlerFunc func(p *Proxy, dctx *DNSContext) (err error)
|
|
|
|
// type check
|
|
var _ Handler = HandlerFunc(nil)
|
|
|
|
// ServeDNS implements the [Handler] interface for HandlerFunc.
|
|
func (f HandlerFunc) ServeDNS(p *Proxy, dctx *DNSContext) (err error) {
|
|
return f(p, dctx)
|
|
}
|