Skip to content

Commit 2d8cfeb

Browse files
committed
Add some debugging helpers
1 parent f052e0c commit 2d8cfeb

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

dnscrypt-proxy/xtransport.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func (xTransport *XTransport) saveCachedIP(host string, ip net.IP, ttl time.Dura
117117
xTransport.cachedIPs.Lock()
118118
xTransport.cachedIPs.cache[host] = item
119119
xTransport.cachedIPs.Unlock()
120+
dlog.Debugf("[%s] IP address [%s] stored to the cache, valid for %v", host, ip, ttl)
120121
}
121122

122123
// Mark an entry as being updated
@@ -128,6 +129,7 @@ func (xTransport *XTransport) markUpdatingCachedIP(host string) {
128129
until := now.Add(xTransport.timeout)
129130
item.updatingUntil = &until
130131
xTransport.cachedIPs.cache[host] = item
132+
dlog.Debugf("[%s] IP addresss marked as updating", host)
131133
}
132134
xTransport.cachedIPs.Unlock()
133135
}
@@ -138,6 +140,7 @@ func (xTransport *XTransport) loadCachedIP(host string) (ip net.IP, expired bool
138140
item, ok := xTransport.cachedIPs.cache[host]
139141
xTransport.cachedIPs.RUnlock()
140142
if !ok {
143+
dlog.Debugf("[%s] IP address not found in the cache", host)
141144
return
142145
}
143146
ip = item.ip
@@ -146,6 +149,9 @@ func (xTransport *XTransport) loadCachedIP(host string) (ip net.IP, expired bool
146149
expired = true
147150
if item.updatingUntil != nil && time.Until(*item.updatingUntil) > 0 {
148151
updating = true
152+
dlog.Debugf("[%s] IP address is being updated", host)
153+
} else {
154+
dlog.Debugf("[%s] IP address expired, not being updated yet", host)
149155
}
150156
}
151157
return

0 commit comments

Comments
 (0)