Commit 6617a300 authored by Jiří Helebrant's avatar Jiří Helebrant

Add cache busting to resolver capability checks

parent 61ea6080
import config from '../../config.json'
import storage from './storage'
import config from '../../config.json'
const getDnssecStatus = async domain =>
fetch(`https://${domain}`, {
fetch(`https://${domain}/?_=${Date.now()}`, {
cache: 'no-cache',
method: 'HEAD'
})
.then(() => false)
.catch(() => true)
const updateResolverStatus = async () => {
const domains = config.defaultSettings.dnssecDomains
const status = {
rsa: await getDnssecStatus(config.domains.badRsa),
ecdsa: await getDnssecStatus(config.domains.badEcdsa),
rsa: await getDnssecStatus(domains.badRsa),
ecdsa: await getDnssecStatus(domains.badEcdsa),
timestamp: +new Date()
}
storage('resolver', 'set', status)
......@@ -22,7 +24,8 @@ const getResolverStatus = async () => {
const result = await storage('resolver', 'get')
if (result.timestamp) {
const age = +new Date() - result.timestamp
if (age > config.resolverStatus.maxAge * 1000) {
const cacheTime = config.defaultSettings.cacheTime.resolver
if (age > cacheTime * 1000) {
return updateResolverStatus()
}
return result
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment