@@ -32,6 +32,9 @@ func NewDNSCache(forwardTTL int, reverseTTL int, backend store.Interface) *DnsCa
3232}
3333
3434func (d * Dns ) getCachedForward (host string ) ([]string , bool ) {
35+ if d .cache == nil {
36+ return nil , false
37+ }
3538 if cached , err := d .cache .forward .Get (d .ctx , host ); err == nil {
3639 slog .Debug ("DNS: forward cache hit" , "name" , host , "ips" , cached )
3740 return cached , true
@@ -41,6 +44,9 @@ func (d *Dns) getCachedForward(host string) ([]string, bool) {
4144}
4245
4346func (d * Dns ) getCachedReverse (addr string ) ([]string , bool ) {
47+ if d .cache == nil {
48+ return nil , false
49+ }
4450 if cached , err := d .cache .reverse .Get (d .ctx , addr ); err == nil {
4551 slog .Debug ("DNS: reverse cache hit" , "addr" , addr , "names" , cached )
4652 return cached , true
@@ -50,9 +56,15 @@ func (d *Dns) getCachedReverse(addr string) ([]string, bool) {
5056}
5157
5258func (d * Dns ) forwardCachePut (host string , entries []string ) {
59+ if d .cache == nil {
60+ return
61+ }
5362 d .cache .forward .Set (d .ctx , host , entries , d .cache .forwardTTL )
5463}
5564
5665func (d * Dns ) reverseCachePut (addr string , entries []string ) {
66+ if d .cache == nil {
67+ return
68+ }
5769 d .cache .reverse .Set (d .ctx , addr , entries , d .cache .reverseTTL )
5870}
0 commit comments