Documentation ¶
Overview ¶
Copyright © 2022 Roberto Hidalgo <coredns-consul@un.rob.mx> Contributions by Charles Powell, 2023 SPDX-License-Identifier: Apache-2.0
Copyright © 2022 Roberto Hidalgo <coredns-consul@un.rob.mx> Contributions by Charles Powell, 2023 SPDX-License-Identifier: Apache-2.0
Copyright © 2022 Roberto Hidalgo <coredns-consul@un.rob.mx> SPDX-License-Identifier: Apache-2.0
Copyright © 2022 Roberto Hidalgo <coredns-consul@un.rob.mx> SPDX-License-Identifier: Apache-2.0
Copyright © 2022 Roberto Hidalgo <coredns-consul@un.rob.mx> SPDX-License-Identifier: Apache-2.0
Copyright © 2022 Roberto Hidalgo <coredns-consul@un.rob.mx> Contributions by Charles Powell, 2023 SPDX-License-Identifier: Apache-2.0
Copyright © 2022 Roberto Hidalgo <coredns-consul@un.rob.mx> Contributions by Charles Powell, 2023 SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- func CreateClient(scheme, endpoint, token string) (catalog Client, kv KVClient, err error)
- func ProxiedAddressesByProximity(source net.IP, svc *Service, target *Service, header dns.RR_Header) []dns.RR
- type Catalog
- func (c *Catalog) LastUpdated() time.Time
- func (c *Catalog) Name() string
- func (c *Catalog) Ready() bool
- func (c *Catalog) ReloadAll() error
- func (c *Catalog) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)
- func (c *Catalog) ServiceFor(name string) *Service
- func (c *Catalog) Services() ServiceMap
- func (c *Catalog) SetClients(client Client, kv KVClient)
- type Client
- type KVClient
- type Service
- type ServiceACL
- type ServiceMap
- type StaticEntries
- type StaticEntry
- type WatcKVPrefix
- type Watch
- type WatchConsulCatalog
- type WatchKVPath
- type WatchType
Constants ¶
const ServiceProxyTag = "@service_proxy"
Variables ¶
var ( // RequestBlockCount is the number of DNS requests being blocked. RequestBlockCount = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: pluginName, Name: "blocked_requests_total", Help: "Counter of DNS requests being blocked.", }, []string{"server", "view"}) // RequestACLDeniedCount is the number of DNS requests being filtered. RequestACLDeniedCount = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: pluginName, Name: "denied_requests_total", Help: "Counter of DNS requests being filtered.", }, []string{"server", "view"}) // RequestServedCount is the number of DNS requests being Allowed. RequestServedCount = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: pluginName, Name: "served_requests_total", Help: "Counter of DNS requests being served by plugin.", }, []string{"server", "view", "source"}) // RequestDropCount is the number of DNS requests being dropped. RequestDropCount = promauto.NewCounterVec(prometheus.CounterOpts{ Namespace: plugin.Namespace, Subsystem: pluginName, Name: "dropped_requests_total", Help: "Counter of DNS requests being dropped.", }, []string{"server", "view"}) )
var DefaultLookup = func(ctx context.Context, state request.Request, target string) (*dns.Msg, error) { recursor := upstream.New() req := state.NewWithQuestion(target, dns.TypeA) return recursor.Lookup(ctx, req, target, dns.TypeA) }
var Log = clog.NewWithPlugin(pluginName)
Functions ¶
func CreateClient ¶
CreateClient initializes the consul catalog client.
Types ¶
type Catalog ¶
type Catalog struct { sync.RWMutex Endpoint string Scheme string FQDN []string TTL uint32 Token string ProxyService string ProxyTag string Networks map[string][]*net.IPNet ACLTag string AliasTag string Next plugin.Handler Zone string Sources []*Watch // contains filtered or unexported fields }
Catalog holds published Consul Catalog services.
func (*Catalog) LastUpdated ¶
LastUpdated returns the last time services changed.
func (*Catalog) ServiceFor ¶
func (*Catalog) Services ¶
func (c *Catalog) Services() ServiceMap
Services returns a map of services to their target.
func (*Catalog) SetClients ¶
SetClient sets a consul client for a catalog.
type Client ¶
type Client interface { Service(string, string, *api.QueryOptions) ([]*api.CatalogService, *api.QueryMeta, error) Services(*api.QueryOptions) (map[string][]string, *api.QueryMeta, error) }
Client is implemented by github.com/hashicorp/consul/api.Catalog.
type KVClient ¶
type KVClient interface { Get(key string, opts *api.QueryOptions) (*api.KVPair, *api.QueryMeta, error) List(prefix string, opts *api.QueryOptions) (api.KVPairs, *api.QueryMeta, error) }
KVClient is implemented by github.com/hashicorp/consul/api.Catalog.
type Service ¶
type Service struct { Name string Target string ACL []*ServiceACL Addresses []net.IP }
Service has a target and ACL rules.
func NewService ¶
type ServiceACL ¶
ServiceACL holds an action and corresponding network range.
type ServiceMap ¶
func (ServiceMap) Find ¶
func (s ServiceMap) Find(query string) *Service
type StaticEntries ¶
type StaticEntries map[string]*StaticEntry
type StaticEntry ¶
type StaticEntry struct { Target string `json:"target"` Addresses []string `json:"addresses"` ACL []string `json:"acl"` Aliases []string `json:"aliases"` }
StaticEntry represents a consul value, json encoded.
type WatcKVPrefix ¶
type WatcKVPrefix struct { Prefix string // contains filtered or unexported fields }
func (*WatcKVPrefix) Fetch ¶
func (src *WatcKVPrefix) Fetch(catalog *Catalog, qo *api.QueryOptions) (uint64, error)
func (*WatcKVPrefix) Name ¶
func (src *WatcKVPrefix) Name() string
func (*WatcKVPrefix) Process ¶
func (src *WatcKVPrefix) Process(catalog *Catalog) (ServiceMap, []string, error)
type WatchConsulCatalog ¶
type WatchConsulCatalog struct { Tag string // contains filtered or unexported fields }
func (*WatchConsulCatalog) Fetch ¶
func (src *WatchConsulCatalog) Fetch(catalog *Catalog, qo *api.QueryOptions) (uint64, error)
func (*WatchConsulCatalog) Name ¶
func (src *WatchConsulCatalog) Name() string
func (*WatchConsulCatalog) Process ¶
func (src *WatchConsulCatalog) Process(catalog *Catalog) (ServiceMap, []string, error)
type WatchKVPath ¶
type WatchKVPath struct { Key string // contains filtered or unexported fields }
func (*WatchKVPath) Fetch ¶
func (src *WatchKVPath) Fetch(catalog *Catalog, qo *api.QueryOptions) (uint64, error)
func (*WatchKVPath) Name ¶
func (src *WatchKVPath) Name() string
func (*WatchKVPath) Process ¶
func (src *WatchKVPath) Process(catalog *Catalog) (ServiceMap, []string, error)