platform: modularize api/gui, add docs-tests-web foundation, and refresh root config

This commit is contained in:
beckline
2026-03-26 22:40:54 +03:00
parent 0e2d7f61ea
commit 6a56d734c2
562 changed files with 70151 additions and 16423 deletions

View File

@@ -0,0 +1,86 @@
package app
import (
"time"
resolverpkg "selective-vpn-api/app/resolver"
)
func executeResolverBatch(
toResolve []string,
workers int,
now int,
staleKeepSec int,
resolved map[string][]string,
domainCache *domainCacheState,
cacheSourceForHost func(string) domainCacheSource,
resolveHost func(string) ([]string, dnsMetrics),
logf func(string, ...any),
) resolverResolveBatchResult {
if domainCache == nil {
return resolverResolveBatchResult{}
}
sourceFn := func(host string) resolverpkg.DomainCacheSource {
if cacheSourceForHost == nil {
return resolverpkg.DomainCacheSourceDirect
}
return resolverpkg.DomainCacheSource(cacheSourceForHost(host))
}
resolveFn := func(host string) ([]string, resolverpkg.DNSMetrics) {
if resolveHost == nil {
return nil, resolverpkg.DNSMetrics{}
}
return resolveHost(host)
}
return resolverpkg.ExecuteResolveBatch(
resolverpkg.ResolveBatchInput{
ToResolve: toResolve,
Workers: workers,
Now: now,
StaleKeepSec: staleKeepSec,
},
resolved,
(*resolverpkg.DomainCacheState)(domainCache),
sourceFn,
resolveFn,
logf,
)
}
func runTimeoutQuarantineRecheck(
domains []string,
cfg dnsConfig,
metaSpecial []string,
wildcards wildcardMatcher,
timeout time.Duration,
domainCache *domainCacheState,
cacheSourceForHost func(string) domainCacheSource,
now int,
limit int,
workers int,
) resolverTimeoutRecheckStats {
if domainCache == nil {
return resolverTimeoutRecheckStats{}
}
sourceFn := func(host string) resolverpkg.DomainCacheSource {
if cacheSourceForHost == nil {
return resolverpkg.DomainCacheSourceDirect
}
return resolverpkg.DomainCacheSource(cacheSourceForHost(host))
}
return resolverpkg.RunTimeoutQuarantineRecheck(
domains,
now,
limit,
workers,
(*resolverpkg.DomainCacheState)(domainCache),
sourceFn,
func(host string) ([]string, resolverpkg.DNSMetrics) {
return resolveHostGo(host, cfg, metaSpecial, wildcards, timeout, nil, nil)
},
)
}
func buildResolverArtifacts(resolved map[string][]string, staticLabels map[string][]string, isWildcardHost func(string) bool) resolverpkg.ResolverArtifacts {
return resolverpkg.BuildResolverArtifacts(resolved, staticLabels, isWildcardHost)
}