package app import resolverpkg "selective-vpn-api/app/resolver" func newDomainCacheState() domainCacheState { return domainCacheState(resolverpkg.NewDomainCacheState()) } func normalizeCacheIPs(raw []string) []string { return resolverpkg.NormalizeCacheIPs(raw) } func normalizeCacheErrorKind(raw string) (dnsErrorKind, bool) { kind, ok := resolverpkg.NormalizeCacheErrorKind(raw) return dnsErrorKind(kind), ok } func normalizeDomainCacheEntry(in *domainCacheEntry) *domainCacheEntry { return resolverpkg.NormalizeDomainCacheEntry(in) } func loadDomainCacheState(path string, logf func(string, ...any)) domainCacheState { return domainCacheState(resolverpkg.LoadDomainCacheState(path, logf)) } func getCacheEntryBySource(rec domainCacheRecord, source domainCacheSource) *domainCacheEntry { return resolverpkg.GetCacheEntryBySource(rec, source) } func clampDomainScore(v int) int { return resolverpkg.ClampDomainScore(v) } func domainStateFromScore(score int) string { return resolverpkg.DomainStateFromScore(score) } func normalizeDomainState(raw string, score int) string { return resolverpkg.NormalizeDomainState(raw, score) } func domainScorePenalty(stats dnsMetrics) int { return resolverpkg.DomainScorePenalty(stats) } func (s domainCacheState) get(domain string, source domainCacheSource, now, ttl int) ([]string, bool) { return resolverpkg.DomainCacheState(s).Get(domain, source, now, ttl) } func (s domainCacheState) getNegative(domain string, source domainCacheSource, now, nxTTL, timeoutTTL, temporaryTTL, otherTTL int) (dnsErrorKind, int, bool) { kind, age, ok := resolverpkg.DomainCacheState(s).GetNegative(domain, source, now, nxTTL, timeoutTTL, temporaryTTL, otherTTL) return dnsErrorKind(kind), age, ok } func (s domainCacheState) getStoredIPs(domain string, source domainCacheSource) []string { return resolverpkg.DomainCacheState(s).GetStoredIPs(domain, source) } func (s domainCacheState) getLastErrorKind(domain string, source domainCacheSource) (dnsErrorKind, bool) { kind, ok := resolverpkg.DomainCacheState(s).GetLastErrorKind(domain, source) return dnsErrorKind(kind), ok } func (s domainCacheState) getQuarantine(domain string, source domainCacheSource, now int) (string, int, bool) { return resolverpkg.DomainCacheState(s).GetQuarantine(domain, source, now) } func (s domainCacheState) getStale(domain string, source domainCacheSource, now, maxAge int) ([]string, int, bool) { return resolverpkg.DomainCacheState(s).GetStale(domain, source, now, maxAge) } func (s *domainCacheState) set(domain string, source domainCacheSource, ips []string, now int) { state := resolverpkg.DomainCacheState(*s) state.Set(domain, source, ips, now) *s = domainCacheState(state) } func (s *domainCacheState) setErrorWithStats(domain string, source domainCacheSource, stats dnsMetrics, now int) { state := resolverpkg.DomainCacheState(*s) state.SetErrorWithStats(domain, source, stats, now) *s = domainCacheState(state) } func (s domainCacheState) toMap() map[string]any { return resolverpkg.DomainCacheState(s).ToMap() } func (s domainCacheState) formatStateSummary(now int) string { return resolverpkg.DomainCacheState(s).FormatStateSummary(now) }