github.com/elfadel/cilium@v1.6.12/pkg/fqdn/config.go (about) 1 // Copyright 2018 Authors of Cilium 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package fqdn 16 17 import ( 18 "context" 19 "net" 20 "sync" 21 "time" 22 23 "github.com/cilium/cilium/pkg/policy/api" 24 "github.com/miekg/dns" 25 ) 26 27 // Config is a simple configuration structure to set how pkg/fqdn subcomponents 28 // behave. 29 // DNSPoller relies on LookupDNSNames to control how DNS lookups are done, and 30 // UpdateSelectors to control how generated policy rules are emitted. 31 type Config struct { 32 // MinTTL is the time used by the poller to cache information. 33 // When set to 0, 2*DNSPollerInterval is used. 34 MinTTL int 35 36 // OverLimit is the number of max entries that a host can have in the DNS cache. 37 OverLimit int 38 39 // Cache is where the poller stores DNS data used to generate rules. 40 // When set to nil, it uses fqdn.DefaultDNSCache, a global cache instance. 41 Cache *DNSCache 42 43 // DNSConfig includes the Resolver IPs, port, timeout and retry count. It is 44 // expected to be generated from /etc/resolv.conf. 45 DNSConfig *dns.ClientConfig 46 47 // LookupDNSNames is a callback to run the provided DNS lookups. 48 // When set to nil, fqdn.DNSLookupDefaultResolver is used. 49 LookupDNSNames func(dnsNames []string) (DNSIPs map[string]*DNSIPRecords, errorDNSNames map[string]error) 50 51 // UpdateSelectors is a callback to update the mapping of FQDNSelector to 52 // sets of IPs. 53 UpdateSelectors func(ctx context.Context, selectorsWithIPs map[api.FQDNSelector][]net.IP, selectorsWithoutIPs []api.FQDNSelector) (*sync.WaitGroup, error) 54 55 // PollerResponseNotify is used when the poller receives DNS data in response 56 // to a successful poll. 57 // Note: This function doesn't do much, as the poller is still wired to 58 // NameManager directly right now. 59 PollerResponseNotify func(lookupTime time.Time, qname string, response *DNSIPRecords) 60 }