diff options
| author | Shulhan <ms@kilabit.info> | 2023-08-06 17:30:50 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-08-06 17:38:56 +0700 |
| commit | 3075672ef742e5612e82009711dab4fa70626516 (patch) | |
| tree | 05cab72fb833e62d5692ac247cc84783c808009c /lib/dns | |
| parent | a20aaf1f220821574ea41de52d5aa61fa598cd43 (diff) | |
| download | pakakeh.go-3075672ef742e5612e82009711dab4fa70626516.tar.xz | |
lib/dns: add method to populate internal caches by Zone
The InternalPopulateZone populate the internal caches from Zone's
messages.
Diffstat (limited to 'lib/dns')
| -rw-r--r-- | lib/dns/caches.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/dns/caches.go b/lib/dns/caches.go index b4b15f6c..5a49e762 100644 --- a/lib/dns/caches.go +++ b/lib/dns/caches.go @@ -37,6 +37,9 @@ type Caches struct { // by is domain name. external map[string]*answers + // zone contains internal zones, with its origin as the key. + zone map[string]*Zone + // lru contains list of external answers, ordered by access time in // ascending order (the least recently used, LRU, record will be on // the top). @@ -79,6 +82,7 @@ func (c *Caches) init(pruneDelay, pruneThreshold time.Duration, debug int) { c.internal = make(map[string]*answers) c.external = make(map[string]*answers) + c.zone = make(map[string]*Zone) c.lru = list.New() c.debug = debug @@ -308,6 +312,18 @@ func (c *Caches) InternalPopulateRecords(listRR []*ResourceRecord, from string) return nil } +// InternalPopulateZone populate the internal caches from Zone. +func (c *Caches) InternalPopulateZone(zone *Zone) { + if zone == nil { + return + } + if len(zone.Origin) == 0 { + return + } + c.zone[zone.Origin] = zone + c.InternalPopulate(zone.Messages(), zone.Path) +} + // InternalRemoveNames remove internal caches by domain names. func (c *Caches) InternalRemoveNames(names []string) { var ( |
