| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032 |
- // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
- // SPDX-License-Identifier: Apache-2.0
- package config // import "miniflux.app/v2/internal/config"
- import (
- "maps"
- "net"
- "net/url"
- "slices"
- "strings"
- "time"
- )
- type optionPair struct {
- Key string
- Value string
- }
- type configValueType int
- const (
- stringType configValueType = iota
- stringListType
- boolType
- intType
- int64Type
- urlType
- secondType
- minuteType
- hourType
- dayType
- secretFileType
- bytesType
- )
- type configValue struct {
- parsedStringValue string
- parsedBoolValue bool
- parsedIntValue int
- parsedInt64Value int64
- parsedDuration time.Duration
- parsedStringList []string
- parsedURLValue *url.URL
- parsedBytesValue []byte
- rawValue string
- valueType configValueType
- secret bool
- targetKey string
- validator func(string) error
- }
- type configOptions struct {
- rootURL string
- basePath string
- youTubeEmbedDomain string
- options map[string]*configValue
- }
- // NewConfigOptions creates a new instance of ConfigOptions with default values.
- func NewConfigOptions() *configOptions {
- return &configOptions{
- rootURL: "http://localhost",
- basePath: "",
- youTubeEmbedDomain: "www.youtube-nocookie.com",
- options: map[string]*configValue{
- "ADMIN_PASSWORD": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- secret: true,
- },
- "ADMIN_PASSWORD_FILE": {
- parsedStringValue: "",
- rawValue: "",
- valueType: secretFileType,
- targetKey: "ADMIN_PASSWORD",
- },
- "ADMIN_USERNAME": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- },
- "ADMIN_USERNAME_FILE": {
- parsedStringValue: "",
- rawValue: "",
- valueType: secretFileType,
- targetKey: "ADMIN_USERNAME",
- },
- "AUTH_PROXY_HEADER": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- },
- "AUTH_PROXY_USER_CREATION": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "BASE_URL": {
- parsedStringValue: "http://localhost",
- rawValue: "http://localhost",
- valueType: stringType,
- },
- "BATCH_SIZE": {
- parsedIntValue: 100,
- rawValue: "100",
- valueType: intType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "CERT_DOMAIN": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- },
- "CERT_FILE": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- },
- "CLEANUP_ARCHIVE_BATCH_SIZE": {
- parsedIntValue: 10000,
- rawValue: "10000",
- valueType: intType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "CLEANUP_ARCHIVE_READ_DAYS": {
- parsedDuration: time.Hour * 24 * 60,
- rawValue: "60",
- valueType: dayType,
- },
- "CLEANUP_ARCHIVE_UNREAD_DAYS": {
- parsedDuration: time.Hour * 24 * 180,
- rawValue: "180",
- valueType: dayType,
- },
- "CLEANUP_FREQUENCY_HOURS": {
- parsedDuration: time.Hour * 24,
- rawValue: "24",
- valueType: hourType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "CLEANUP_REMOVE_SESSIONS_DAYS": {
- parsedDuration: time.Hour * 24 * 30,
- rawValue: "30",
- valueType: dayType,
- },
- "CREATE_ADMIN": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "DATABASE_CONNECTION_LIFETIME": {
- parsedDuration: time.Minute * 5,
- rawValue: "5",
- valueType: minuteType,
- validator: func(rawValue string) error {
- return validateGreaterThan(rawValue, 0)
- },
- },
- "DATABASE_MAX_CONNS": {
- parsedIntValue: 20,
- rawValue: "20",
- valueType: intType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "DATABASE_MIN_CONNS": {
- parsedIntValue: 1,
- rawValue: "1",
- valueType: intType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 0)
- },
- },
- "DATABASE_URL": {
- parsedStringValue: "user=postgres password=postgres dbname=miniflux2 sslmode=disable",
- rawValue: "user=postgres password=postgres dbname=miniflux2 sslmode=disable",
- valueType: stringType,
- secret: true,
- },
- "DATABASE_URL_FILE": {
- parsedStringValue: "",
- rawValue: "",
- valueType: secretFileType,
- targetKey: "DATABASE_URL",
- },
- "DISABLE_API": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "DISABLE_HSTS": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "DISABLE_HTTP_SERVICE": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "DISABLE_LOCAL_AUTH": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "DISABLE_SCHEDULER_SERVICE": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "FETCHER_ALLOW_PRIVATE_NETWORKS": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "FETCH_BILIBILI_WATCH_TIME": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "FETCH_NEBULA_WATCH_TIME": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "FETCH_ODYSEE_WATCH_TIME": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "FETCH_YOUTUBE_WATCH_TIME": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "FORCE_REFRESH_INTERVAL": {
- parsedDuration: 30 * time.Minute,
- rawValue: "30",
- valueType: minuteType,
- validator: func(rawValue string) error {
- return validateGreaterThan(rawValue, 0)
- },
- },
- "HTTP_CLIENT_MAX_BODY_SIZE": {
- parsedInt64Value: 15,
- rawValue: "15",
- valueType: int64Type,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "HTTP_CLIENT_PROXIES": {
- parsedStringList: []string{},
- rawValue: "",
- valueType: stringListType,
- secret: true,
- },
- "HTTP_CLIENT_PROXY": {
- parsedURLValue: nil,
- rawValue: "",
- valueType: urlType,
- secret: true,
- },
- "HTTP_CLIENT_TIMEOUT": {
- parsedDuration: 20 * time.Second,
- rawValue: "20",
- valueType: secondType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "HTTP_CLIENT_USER_AGENT": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- },
- "HTTP_SERVER_TIMEOUT": {
- parsedDuration: 300 * time.Second,
- rawValue: "300",
- valueType: secondType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "HTTPS": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "INTEGRATION_ALLOW_PRIVATE_NETWORKS": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "INVIDIOUS_INSTANCE": {
- parsedStringValue: "yewtu.be",
- rawValue: "yewtu.be",
- valueType: stringType,
- },
- "KEY_FILE": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- },
- "LISTEN_ADDR": {
- parsedStringList: []string{"127.0.0.1:8080"},
- rawValue: "127.0.0.1:8080",
- valueType: stringListType,
- },
- "LOG_DATE_TIME": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "LOG_FILE": {
- parsedStringValue: "stderr",
- rawValue: "stderr",
- valueType: stringType,
- },
- "LOG_FORMAT": {
- parsedStringValue: "text",
- rawValue: "text",
- valueType: stringType,
- validator: func(rawValue string) error {
- return validateChoices(rawValue, []string{"text", "json"})
- },
- },
- "LOG_LEVEL": {
- parsedStringValue: "info",
- rawValue: "info",
- valueType: stringType,
- validator: func(rawValue string) error {
- return validateChoices(rawValue, []string{"debug", "info", "warning", "error"})
- },
- },
- "MAINTENANCE_MESSAGE": {
- parsedStringValue: "Miniflux is currently under maintenance",
- rawValue: "Miniflux is currently under maintenance",
- valueType: stringType,
- },
- "MAINTENANCE_MODE": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "MEDIA_PROXY_CUSTOM_URL": {
- rawValue: "",
- valueType: urlType,
- },
- "MEDIA_PROXY_HTTP_CLIENT_TIMEOUT": {
- parsedDuration: 120 * time.Second,
- rawValue: "120",
- valueType: secondType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "MEDIA_PROXY_MODE": {
- parsedStringValue: "http-only",
- rawValue: "http-only",
- valueType: stringType,
- validator: func(rawValue string) error {
- return validateChoices(rawValue, []string{"none", "http-only", "all"})
- },
- },
- "MEDIA_PROXY_PRIVATE_KEY": {
- valueType: bytesType,
- secret: true,
- },
- "MEDIA_PROXY_RESOURCE_TYPES": {
- parsedStringList: []string{"image"},
- rawValue: "image",
- valueType: stringListType,
- validator: func(rawValue string) error {
- return validateListChoices(strings.Split(rawValue, ","), []string{"image", "video", "audio"})
- },
- },
- "METRICS_ALLOWED_NETWORKS": {
- parsedStringList: []string{"127.0.0.1/8"},
- rawValue: "127.0.0.1/8",
- valueType: stringListType,
- },
- "METRICS_COLLECTOR": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "METRICS_PASSWORD": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- secret: true,
- },
- "METRICS_PASSWORD_FILE": {
- parsedStringValue: "",
- rawValue: "",
- valueType: secretFileType,
- targetKey: "METRICS_PASSWORD",
- },
- "METRICS_REFRESH_INTERVAL": {
- parsedDuration: 60 * time.Second,
- rawValue: "60",
- valueType: secondType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "METRICS_USERNAME": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- },
- "METRICS_USERNAME_FILE": {
- parsedStringValue: "",
- rawValue: "",
- valueType: secretFileType,
- targetKey: "METRICS_USERNAME",
- },
- "OAUTH2_CLIENT_ID": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- secret: true,
- },
- "OAUTH2_CLIENT_ID_FILE": {
- parsedStringValue: "",
- rawValue: "",
- valueType: secretFileType,
- targetKey: "OAUTH2_CLIENT_ID",
- },
- "OAUTH2_CLIENT_SECRET": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- secret: true,
- },
- "OAUTH2_CLIENT_SECRET_FILE": {
- parsedStringValue: "",
- rawValue: "",
- valueType: secretFileType,
- targetKey: "OAUTH2_CLIENT_SECRET",
- },
- "OAUTH2_OIDC_DISCOVERY_ENDPOINT": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- },
- "OAUTH2_OIDC_PROVIDER_NAME": {
- parsedStringValue: "OpenID Connect",
- rawValue: "OpenID Connect",
- valueType: stringType,
- },
- "OAUTH2_PROVIDER": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- validator: func(rawValue string) error {
- return validateChoices(rawValue, []string{"oidc", "google"})
- },
- },
- "OAUTH2_REDIRECT_URL": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- },
- "OAUTH2_USER_CREATION": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "POLLING_FREQUENCY": {
- parsedDuration: 60 * time.Minute,
- rawValue: "60",
- valueType: minuteType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "POLLING_LIMIT_PER_HOST": {
- parsedIntValue: 0,
- rawValue: "0",
- valueType: intType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 0)
- },
- },
- "POLLING_PARSING_ERROR_LIMIT": {
- parsedIntValue: 3,
- rawValue: "3",
- valueType: intType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 0)
- },
- },
- "POLLING_SCHEDULER": {
- parsedStringValue: "round_robin",
- rawValue: "round_robin",
- valueType: stringType,
- validator: func(rawValue string) error {
- return validateChoices(rawValue, []string{"round_robin", "entry_frequency"})
- },
- },
- "PORT": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- validator: func(rawValue string) error {
- return validateRange(rawValue, 1, 65535)
- },
- },
- "RUN_MIGRATIONS": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "SCHEDULER_ENTRY_FREQUENCY_FACTOR": {
- parsedIntValue: 1,
- rawValue: "1",
- valueType: intType,
- },
- "SCHEDULER_ENTRY_FREQUENCY_MAX_INTERVAL": {
- parsedDuration: 24 * time.Hour,
- rawValue: "1440",
- valueType: minuteType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "SCHEDULER_ENTRY_FREQUENCY_MIN_INTERVAL": {
- parsedDuration: 5 * time.Minute,
- rawValue: "5",
- valueType: minuteType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "SCHEDULER_ROUND_ROBIN_MAX_INTERVAL": {
- parsedDuration: 1440 * time.Minute,
- rawValue: "1440",
- valueType: minuteType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "SCHEDULER_ROUND_ROBIN_MIN_INTERVAL": {
- parsedDuration: 60 * time.Minute,
- rawValue: "60",
- valueType: minuteType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "TRUSTED_REVERSE_PROXY_NETWORKS": {
- parsedStringList: []string{},
- rawValue: "",
- valueType: stringListType,
- validator: func(rawValue string) error {
- for ip := range strings.SplitSeq(rawValue, ",") {
- if _, _, err := net.ParseCIDR(ip); err != nil {
- return err
- }
- }
- return nil
- },
- },
- "WATCHDOG": {
- parsedBoolValue: true,
- rawValue: "1",
- valueType: boolType,
- },
- "WEBAUTHN": {
- parsedBoolValue: false,
- rawValue: "0",
- valueType: boolType,
- },
- "WORKER_POOL_SIZE": {
- parsedIntValue: 16,
- rawValue: "16",
- valueType: intType,
- validator: func(rawValue string) error {
- return validateGreaterOrEqualThan(rawValue, 1)
- },
- },
- "YOUTUBE_API_KEY": {
- parsedStringValue: "",
- rawValue: "",
- valueType: stringType,
- secret: true,
- },
- "YOUTUBE_EMBED_URL_OVERRIDE": {
- parsedStringValue: "https://www.youtube-nocookie.com/embed/",
- rawValue: "https://www.youtube-nocookie.com/embed/",
- valueType: stringType,
- },
- },
- }
- }
- func (c *configOptions) AdminPassword() string {
- return c.options["ADMIN_PASSWORD"].parsedStringValue
- }
- func (c *configOptions) AdminUsername() string {
- return c.options["ADMIN_USERNAME"].parsedStringValue
- }
- func (c *configOptions) AuthProxyHeader() string {
- return c.options["AUTH_PROXY_HEADER"].parsedStringValue
- }
- func (c *configOptions) AuthProxyUserCreation() bool {
- return c.options["AUTH_PROXY_USER_CREATION"].parsedBoolValue
- }
- func (c *configOptions) BasePath() string {
- return c.basePath
- }
- func (c *configOptions) BaseURL() string {
- return c.options["BASE_URL"].parsedStringValue
- }
- func (c *configOptions) RootURL() string {
- return c.rootURL
- }
- func (c *configOptions) BatchSize() int {
- return c.options["BATCH_SIZE"].parsedIntValue
- }
- func (c *configOptions) CertDomain() string {
- return c.options["CERT_DOMAIN"].parsedStringValue
- }
- func (c *configOptions) CertFile() string {
- return c.options["CERT_FILE"].parsedStringValue
- }
- func (c *configOptions) CleanupArchiveBatchSize() int {
- return c.options["CLEANUP_ARCHIVE_BATCH_SIZE"].parsedIntValue
- }
- func (c *configOptions) CleanupArchiveReadInterval() time.Duration {
- return c.options["CLEANUP_ARCHIVE_READ_DAYS"].parsedDuration
- }
- func (c *configOptions) CleanupArchiveUnreadInterval() time.Duration {
- return c.options["CLEANUP_ARCHIVE_UNREAD_DAYS"].parsedDuration
- }
- func (c *configOptions) CleanupFrequency() time.Duration {
- return c.options["CLEANUP_FREQUENCY_HOURS"].parsedDuration
- }
- func (c *configOptions) CleanupRemoveSessionsInterval() time.Duration {
- return c.options["CLEANUP_REMOVE_SESSIONS_DAYS"].parsedDuration
- }
- func (c *configOptions) CreateAdmin() bool {
- return c.options["CREATE_ADMIN"].parsedBoolValue
- }
- func (c *configOptions) DatabaseConnectionLifetime() time.Duration {
- return c.options["DATABASE_CONNECTION_LIFETIME"].parsedDuration
- }
- func (c *configOptions) DatabaseMaxConns() int {
- return c.options["DATABASE_MAX_CONNS"].parsedIntValue
- }
- func (c *configOptions) DatabaseMinConns() int {
- return c.options["DATABASE_MIN_CONNS"].parsedIntValue
- }
- func (c *configOptions) DatabaseURL() string {
- return c.options["DATABASE_URL"].parsedStringValue
- }
- func (c *configOptions) DisableHSTS() bool {
- return c.options["DISABLE_HSTS"].parsedBoolValue
- }
- func (c *configOptions) DisableHTTPService() bool {
- return c.options["DISABLE_HTTP_SERVICE"].parsedBoolValue
- }
- func (c *configOptions) DisableLocalAuth() bool {
- return c.options["DISABLE_LOCAL_AUTH"].parsedBoolValue
- }
- func (c *configOptions) DisableSchedulerService() bool {
- return c.options["DISABLE_SCHEDULER_SERVICE"].parsedBoolValue
- }
- func (c *configOptions) FetchBilibiliWatchTime() bool {
- return c.options["FETCH_BILIBILI_WATCH_TIME"].parsedBoolValue
- }
- func (c *configOptions) FetchNebulaWatchTime() bool {
- return c.options["FETCH_NEBULA_WATCH_TIME"].parsedBoolValue
- }
- func (c *configOptions) FetchOdyseeWatchTime() bool {
- return c.options["FETCH_ODYSEE_WATCH_TIME"].parsedBoolValue
- }
- func (c *configOptions) FetchYouTubeWatchTime() bool {
- return c.options["FETCH_YOUTUBE_WATCH_TIME"].parsedBoolValue
- }
- func (c *configOptions) ForceRefreshInterval() time.Duration {
- return c.options["FORCE_REFRESH_INTERVAL"].parsedDuration
- }
- func (c *configOptions) HasHTTPClientProxiesConfigured() bool {
- return len(c.options["HTTP_CLIENT_PROXIES"].parsedStringList) > 0
- }
- func (c *configOptions) HasAPI() bool {
- return !c.options["DISABLE_API"].parsedBoolValue
- }
- func (c *configOptions) HasHTTPService() bool {
- return !c.options["DISABLE_HTTP_SERVICE"].parsedBoolValue
- }
- func (c *configOptions) HasHSTS() bool {
- return !c.options["DISABLE_HSTS"].parsedBoolValue
- }
- func (c *configOptions) HasHTTPClientProxyURLConfigured() bool {
- return c.options["HTTP_CLIENT_PROXY"].parsedURLValue != nil
- }
- func (c *configOptions) HasMaintenanceMode() bool {
- return c.options["MAINTENANCE_MODE"].parsedBoolValue
- }
- func (c *configOptions) HasMetricsCollector() bool {
- return c.options["METRICS_COLLECTOR"].parsedBoolValue
- }
- func (c *configOptions) HasSchedulerService() bool {
- return !c.options["DISABLE_SCHEDULER_SERVICE"].parsedBoolValue
- }
- func (c *configOptions) HasWatchdog() bool {
- return c.options["WATCHDOG"].parsedBoolValue
- }
- func (c *configOptions) HTTPClientMaxBodySize() int64 {
- return c.options["HTTP_CLIENT_MAX_BODY_SIZE"].parsedInt64Value * 1024 * 1024
- }
- func (c *configOptions) HTTPClientProxies() []string {
- return c.options["HTTP_CLIENT_PROXIES"].parsedStringList
- }
- func (c *configOptions) HTTPClientProxyURL() *url.URL {
- return c.options["HTTP_CLIENT_PROXY"].parsedURLValue
- }
- func (c *configOptions) HTTPClientTimeout() time.Duration {
- return c.options["HTTP_CLIENT_TIMEOUT"].parsedDuration
- }
- func (c *configOptions) HTTPClientUserAgent() string {
- if c.options["HTTP_CLIENT_USER_AGENT"].parsedStringValue != "" {
- return c.options["HTTP_CLIENT_USER_AGENT"].parsedStringValue
- }
- return defaultHTTPClientUserAgent
- }
- func (c *configOptions) HTTPServerTimeout() time.Duration {
- return c.options["HTTP_SERVER_TIMEOUT"].parsedDuration
- }
- func (c *configOptions) HTTPS() bool {
- return c.options["HTTPS"].parsedBoolValue
- }
- func (c *configOptions) FetcherAllowPrivateNetworks() bool {
- return c.options["FETCHER_ALLOW_PRIVATE_NETWORKS"].parsedBoolValue
- }
- func (c *configOptions) IntegrationAllowPrivateNetworks() bool {
- if c == nil {
- return false
- }
- return c.options["INTEGRATION_ALLOW_PRIVATE_NETWORKS"].parsedBoolValue
- }
- func (c *configOptions) InvidiousInstance() string {
- return c.options["INVIDIOUS_INSTANCE"].parsedStringValue
- }
- func (c *configOptions) IsAuthProxyUserCreationAllowed() bool {
- return c.options["AUTH_PROXY_USER_CREATION"].parsedBoolValue
- }
- func (c *configOptions) IsDefaultDatabaseURL() bool {
- return c.options["DATABASE_URL"].rawValue == "user=postgres password=postgres dbname=miniflux2 sslmode=disable"
- }
- func (c *configOptions) IsOAuth2UserCreationAllowed() bool {
- return c.options["OAUTH2_USER_CREATION"].parsedBoolValue
- }
- func (c *configOptions) CertKeyFile() string {
- return c.options["KEY_FILE"].parsedStringValue
- }
- func (c *configOptions) ListenAddr() []string {
- return c.options["LISTEN_ADDR"].parsedStringList
- }
- func (c *configOptions) LogFile() string {
- return c.options["LOG_FILE"].parsedStringValue
- }
- func (c *configOptions) LogDateTime() bool {
- return c.options["LOG_DATE_TIME"].parsedBoolValue
- }
- func (c *configOptions) LogFormat() string {
- return c.options["LOG_FORMAT"].parsedStringValue
- }
- func (c *configOptions) LogLevel() string {
- return c.options["LOG_LEVEL"].parsedStringValue
- }
- func (c *configOptions) MaintenanceMessage() string {
- return c.options["MAINTENANCE_MESSAGE"].parsedStringValue
- }
- func (c *configOptions) MaintenanceMode() bool {
- return c.options["MAINTENANCE_MODE"].parsedBoolValue
- }
- func (c *configOptions) MediaCustomProxyURL() *url.URL {
- return c.options["MEDIA_PROXY_CUSTOM_URL"].parsedURLValue
- }
- func (c *configOptions) MediaProxyHTTPClientTimeout() time.Duration {
- return c.options["MEDIA_PROXY_HTTP_CLIENT_TIMEOUT"].parsedDuration
- }
- func (c *configOptions) MediaProxyMode() string {
- return c.options["MEDIA_PROXY_MODE"].parsedStringValue
- }
- func (c *configOptions) MediaProxyPrivateKey() []byte {
- return c.options["MEDIA_PROXY_PRIVATE_KEY"].parsedBytesValue
- }
- func (c *configOptions) MediaProxyResourceTypes() []string {
- return c.options["MEDIA_PROXY_RESOURCE_TYPES"].parsedStringList
- }
- func (c *configOptions) MetricsAllowedNetworks() []string {
- return c.options["METRICS_ALLOWED_NETWORKS"].parsedStringList
- }
- func (c *configOptions) MetricsCollector() bool {
- return c.options["METRICS_COLLECTOR"].parsedBoolValue
- }
- func (c *configOptions) MetricsPassword() string {
- return c.options["METRICS_PASSWORD"].parsedStringValue
- }
- func (c *configOptions) MetricsRefreshInterval() time.Duration {
- return c.options["METRICS_REFRESH_INTERVAL"].parsedDuration
- }
- func (c *configOptions) MetricsUsername() string {
- return c.options["METRICS_USERNAME"].parsedStringValue
- }
- func (c *configOptions) OAuth2ClientID() string {
- return c.options["OAUTH2_CLIENT_ID"].parsedStringValue
- }
- func (c *configOptions) OAuth2ClientSecret() string {
- return c.options["OAUTH2_CLIENT_SECRET"].parsedStringValue
- }
- func (c *configOptions) OAuth2OIDCDiscoveryEndpoint() string {
- return c.options["OAUTH2_OIDC_DISCOVERY_ENDPOINT"].parsedStringValue
- }
- func (c *configOptions) OAuth2OIDCProviderName() string {
- return c.options["OAUTH2_OIDC_PROVIDER_NAME"].parsedStringValue
- }
- func (c *configOptions) OAuth2Provider() string {
- return c.options["OAUTH2_PROVIDER"].parsedStringValue
- }
- func (c *configOptions) OAuth2RedirectURL() string {
- return c.options["OAUTH2_REDIRECT_URL"].parsedStringValue
- }
- func (c *configOptions) OAuth2UserCreation() bool {
- return c.options["OAUTH2_USER_CREATION"].parsedBoolValue
- }
- func (c *configOptions) PollingFrequency() time.Duration {
- return c.options["POLLING_FREQUENCY"].parsedDuration
- }
- func (c *configOptions) PollingLimitPerHost() int {
- return c.options["POLLING_LIMIT_PER_HOST"].parsedIntValue
- }
- func (c *configOptions) PollingParsingErrorLimit() int {
- return c.options["POLLING_PARSING_ERROR_LIMIT"].parsedIntValue
- }
- func (c *configOptions) PollingScheduler() string {
- return c.options["POLLING_SCHEDULER"].parsedStringValue
- }
- func (c *configOptions) Port() string {
- return c.options["PORT"].parsedStringValue
- }
- func (c *configOptions) RunMigrations() bool {
- return c.options["RUN_MIGRATIONS"].parsedBoolValue
- }
- func (c *configOptions) SetLogLevel(level string) {
- c.options["LOG_LEVEL"].parsedStringValue = level
- c.options["LOG_LEVEL"].rawValue = level
- }
- func (c *configOptions) SetHTTPSValue(value bool) {
- c.options["HTTPS"].parsedBoolValue = value
- if value {
- c.options["HTTPS"].rawValue = "1"
- } else {
- c.options["HTTPS"].rawValue = "0"
- }
- }
- func (c *configOptions) SchedulerEntryFrequencyFactor() int {
- return c.options["SCHEDULER_ENTRY_FREQUENCY_FACTOR"].parsedIntValue
- }
- func (c *configOptions) SchedulerEntryFrequencyMaxInterval() time.Duration {
- return c.options["SCHEDULER_ENTRY_FREQUENCY_MAX_INTERVAL"].parsedDuration
- }
- func (c *configOptions) SchedulerEntryFrequencyMinInterval() time.Duration {
- return c.options["SCHEDULER_ENTRY_FREQUENCY_MIN_INTERVAL"].parsedDuration
- }
- func (c *configOptions) SchedulerRoundRobinMaxInterval() time.Duration {
- return c.options["SCHEDULER_ROUND_ROBIN_MAX_INTERVAL"].parsedDuration
- }
- func (c *configOptions) SchedulerRoundRobinMinInterval() time.Duration {
- return c.options["SCHEDULER_ROUND_ROBIN_MIN_INTERVAL"].parsedDuration
- }
- func (c *configOptions) TrustedReverseProxyNetworks() []string {
- return c.options["TRUSTED_REVERSE_PROXY_NETWORKS"].parsedStringList
- }
- func (c *configOptions) Watchdog() bool {
- return c.options["WATCHDOG"].parsedBoolValue
- }
- func (c *configOptions) WebAuthn() bool {
- return c.options["WEBAUTHN"].parsedBoolValue
- }
- func (c *configOptions) WorkerPoolSize() int {
- return c.options["WORKER_POOL_SIZE"].parsedIntValue
- }
- func (c *configOptions) YouTubeAPIKey() string {
- return c.options["YOUTUBE_API_KEY"].parsedStringValue
- }
- func (c *configOptions) YouTubeEmbedUrlOverride() string {
- return c.options["YOUTUBE_EMBED_URL_OVERRIDE"].parsedStringValue
- }
- func (c *configOptions) YouTubeEmbedDomain() string {
- return c.youTubeEmbedDomain
- }
- func (c *configOptions) ConfigMap(redactSecret bool) []*optionPair {
- sortedKeys := slices.Sorted(maps.Keys(c.options))
- sortedOptions := make([]*optionPair, 0, len(sortedKeys))
- for _, key := range sortedKeys {
- value := c.options[key]
- displayValue := value.rawValue
- if displayValue != "" && redactSecret && value.secret {
- displayValue = "<redacted>"
- }
- sortedOptions = append(sortedOptions, &optionPair{Key: key, Value: displayValue})
- }
- return sortedOptions
- }
- func (c *configOptions) String() string {
- var builder strings.Builder
- for _, option := range c.ConfigMap(false) {
- builder.WriteString(option.Key)
- builder.WriteByte('=')
- builder.WriteString(option.Value)
- builder.WriteByte('\n')
- }
- return builder.String()
- }
|