mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 02:33:14 -04:00
plugin/view: Advanced routing interface and new 'view' plugin (#5538)
* introduce new interface "dnsserver.Viewer", that allows a plugin implementing it to decide if a query should be routed into its server block. * add new plugin "view", that uses the new interface to enable a user to define expression based conditions that must be met for a query to be routed to its server block. Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package dnsserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/coredns/caddy"
|
||||
"github.com/coredns/coredns/plugin"
|
||||
"github.com/coredns/coredns/request"
|
||||
)
|
||||
|
||||
// Config configuration for a single server.
|
||||
@@ -40,6 +42,14 @@ type Config struct {
|
||||
// may depend on it.
|
||||
HTTPRequestValidateFunc func(*http.Request) bool
|
||||
|
||||
// FilterFuncs is used to further filter access
|
||||
// to this handler. E.g. to limit access to a reverse zone
|
||||
// on a non-octet boundary, i.e. /17
|
||||
FilterFuncs []FilterFunc
|
||||
|
||||
// ViewName is the name of the Viewer PLugin defined in the Config
|
||||
ViewName string
|
||||
|
||||
// TLSConfig when listening for encrypted connections (gRPC, DNS-over-TLS).
|
||||
TLSConfig *tls.Config
|
||||
|
||||
@@ -60,8 +70,14 @@ type Config struct {
|
||||
// firstConfigInBlock is used to reference the first config in a server block, for the
|
||||
// purpose of sharing single instance of each plugin among all zones in a server block.
|
||||
firstConfigInBlock *Config
|
||||
|
||||
// metaCollector references the first MetadataCollector plugin, if one exists
|
||||
metaCollector MetadataCollector
|
||||
}
|
||||
|
||||
// FilterFunc is a function that filters requests from the Config
|
||||
type FilterFunc func(context.Context, *request.Request) bool
|
||||
|
||||
// keyForConfig builds a key for identifying the configs during setup time
|
||||
func keyForConfig(blocIndex int, blocKeyIndex int) string {
|
||||
return fmt.Sprintf("%d:%d", blocIndex, blocKeyIndex)
|
||||
|
||||
Reference in New Issue
Block a user