// Copyright 2026 Moko Consulting // SPDX-License-Identifier: GPL-3.0-or-later package setting import "time" // CDN holds configuration for the built-in CDN asset delivery system. var CDN = struct { Enabled bool Domain string // e.g. "cdn.mokoconsulting.tech" CacheTTL time.Duration // Cache-Control max-age for CDN responses AllowedOrigins []string // CORS origins allowed to fetch CDN assets AllowedIPs []string // IP/CIDR allowlist (empty = allow all) AllowedDomains []string // Referrer domain allowlist (empty = allow all) MaxFileSize int64 // max file size to serve (bytes) }{ Enabled: false, Domain: "", CacheTTL: 24 * time.Hour, MaxFileSize: 100 * 1024 * 1024, // 100MB } func loadCDNFrom(cfg ConfigProvider) { sec := cfg.Section("cdn") CDN.Enabled = sec.Key("ENABLED").MustBool(false) CDN.Domain = sec.Key("DOMAIN").String() CDN.CacheTTL = sec.Key("CACHE_TTL").MustDuration(CDN.CacheTTL) CDN.MaxFileSize = sec.Key("MAX_FILE_SIZE").MustInt64(CDN.MaxFileSize) CDN.AllowedOrigins = sec.Key("ALLOWED_ORIGINS").Strings(",") CDN.AllowedIPs = sec.Key("ALLOWED_IPS").Strings(",") CDN.AllowedDomains = sec.Key("ALLOWED_DOMAINS").Strings(",") }