Documentation
¶
Overview ¶
Package config provides configuration loading and management.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BrowserUAMap = map[string]string{
"chrome_133": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36",
"chrome_144": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36",
"chrome_146": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36",
"firefox_135": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0",
"firefox_147": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:147.0) Gecko/20100101 Firefox/147.0",
}
BrowserUAMap maps browser fingerprint names to their paired User-Agent strings. Browser and UA must always be used as a pair.
Functions ¶
func EffectiveBlockedParallelEnabled ¶
func EffectiveBlockedParallelEnabled(cfg *ImageConfig) bool
EffectiveBlockedParallelEnabled resolves the image toggle with the runtime default.
Types ¶
type AppConfig ¶
type AppConfig struct {
AppKey string `toml:"app_key"`
MediaGenerationEnabled bool `toml:"media_generation_enabled"`
Temporary bool `toml:"temporary"`
DisableMemory bool `toml:"disable_memory"`
Stream bool `toml:"stream"`
Thinking bool `toml:"thinking"`
DynamicStatsig bool `toml:"dynamic_statsig"`
CustomInstruction string `toml:"custom_instruction"`
FilterTags []string `toml:"filter_tags"`
// Model catalog settings
ModelsFile string `toml:"models_file"` // optional external model catalog file path
// Server settings
Host string `toml:"host"`
Port int `toml:"port"`
LogJSON bool `toml:"log_json"`
LogLevel string `toml:"log_level"`
LogFilePath string `toml:"log_file_path"`
LogMaxSizeMB int `toml:"log_max_size_mb"`
LogMaxBackups int `toml:"log_max_backups"`
// Database settings
DBDriver string `toml:"db_driver"`
DBPath string `toml:"db_path"`
DBDSN string `toml:"db_dsn"`
RequestTimeout int `toml:"request_timeout"` // default request timeout in seconds (non-LLM routes)
// Security settings
ReadHeaderTimeout int `toml:"read_header_timeout"` // seconds, max time to read request headers
MaxHeaderBytes int `toml:"max_header_bytes"` // max size of request headers in bytes
BodyLimit int64 `toml:"body_limit"` // default max request body size in bytes
ChatBodyLimit int64 `toml:"chat_body_limit"` // max body size for chat completions in bytes
AdminMaxFails int `toml:"admin_max_fails"` // max auth failures before temporary IP lockout
AdminWindowSec int `toml:"admin_window_sec"` // time window in seconds for counting admin auth failures
}
AppConfig contains application settings.
type Config ¶
type Config struct {
App AppConfig `toml:"app"`
Image ImageConfig `toml:"image"`
Proxy ProxyConfig `toml:"proxy"`
Retry RetryConfig `toml:"retry"`
Token TokenConfig `toml:"token"`
}
Config is the root configuration structure.
type ImageConfig ¶
type ImageConfig struct {
NSFW bool `toml:"nsfw"`
BlockedParallelAttempts int `toml:"blocked_parallel_attempts"`
BlockedParallelEnabled *bool `toml:"blocked_parallel_enabled"`
}
ImageConfig contains image-generation behavior flags.
type ProxyConfig ¶
type ProxyConfig struct {
BaseProxyURL string `toml:"base_proxy_url"`
AssetProxyURL string `toml:"asset_proxy_url"`
CFCookies string `toml:"cf_cookies"`
SkipProxySSLVerify bool `toml:"skip_proxy_ssl_verify"`
Enabled bool `toml:"enabled"`
FlareSolverrURL string `toml:"flaresolverr_url"`
RefreshInterval int `toml:"refresh_interval"`
Timeout int `toml:"timeout"`
CFClearance string `toml:"cf_clearance"`
Browser string `toml:"browser"`
UserAgent string `toml:"user_agent"`
}
ProxyConfig contains proxy settings.
type RetryConfig ¶
type RetryConfig struct {
MaxTokens int `toml:"max_tokens"`
PerTokenRetries int `toml:"per_token_retries"`
ResetSessionStatusCodes []int `toml:"reset_session_status_codes"`
CoolingStatusCodes []int `toml:"cooling_status_codes"`
RetryBackoffBase float64 `toml:"retry_backoff_base"`
RetryBackoffFactor float64 `toml:"retry_backoff_factor"`
RetryBackoffMax float64 `toml:"retry_backoff_max"`
RetryBudget float64 `toml:"retry_budget"`
}
RetryConfig contains retry policy settings.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime provides atomic access to the live configuration snapshot.
func NewRuntime ¶
NewRuntime creates a runtime config container initialized with a deep copy.
type TokenConfig ¶
type TokenConfig struct {
FailThreshold int `toml:"fail_threshold"`
UsageFlushIntervalSec int `toml:"usage_flush_interval_sec"`
CoolCheckIntervalSec int `toml:"cool_check_interval_sec"`
BasicCoolDurationMin int `toml:"basic_cool_duration_min"`
SuperCoolDurationMin int `toml:"super_cool_duration_min"`
HeavyCoolDurationMin int `toml:"heavy_cool_duration_min"`
DefaultChatQuota int `toml:"default_chat_quota"`
DefaultImageQuota int `toml:"default_image_quota"`
DefaultVideoQuota int `toml:"default_video_quota"`
QuotaRecoveryMode string `toml:"quota_recovery_mode"`
SelectionAlgorithm string `toml:"selection_algorithm" json:"selection_algorithm"`
}
TokenConfig contains token pool settings.