2019-06-02 03:18:09 +02:00
|
|
|
// Copyright 2019 Frédéric Guillot. All rights reserved.
|
|
|
|
// Use of this source code is governed by the Apache 2.0
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package config // import "miniflux.app/config"
|
|
|
|
|
2019-06-03 03:20:59 +02:00
|
|
|
import (
|
|
|
|
"fmt"
|
2020-12-30 04:43:37 +01:00
|
|
|
"sort"
|
2019-06-03 03:20:59 +02:00
|
|
|
"strings"
|
2020-12-17 06:16:04 +01:00
|
|
|
|
|
|
|
"miniflux.app/version"
|
2019-06-03 03:20:59 +02:00
|
|
|
)
|
|
|
|
|
2019-06-02 03:18:09 +02:00
|
|
|
const (
|
2020-05-25 23:59:15 +02:00
|
|
|
defaultHTTPS = false
|
|
|
|
defaultLogDateTime = false
|
|
|
|
defaultHSTS = true
|
|
|
|
defaultHTTPService = true
|
|
|
|
defaultSchedulerService = true
|
|
|
|
defaultDebug = false
|
2020-12-19 00:08:17 +01:00
|
|
|
defaultTiming = false
|
2020-05-25 23:59:15 +02:00
|
|
|
defaultBaseURL = "http://localhost"
|
|
|
|
defaultRootURL = "http://localhost"
|
|
|
|
defaultBasePath = ""
|
|
|
|
defaultWorkerPoolSize = 5
|
|
|
|
defaultPollingFrequency = 60
|
|
|
|
defaultBatchSize = 10
|
|
|
|
defaultPollingScheduler = "round_robin"
|
|
|
|
defaultSchedulerEntryFrequencyMinInterval = 5
|
|
|
|
defaultSchedulerEntryFrequencyMaxInterval = 24 * 60
|
2021-01-26 06:41:36 +01:00
|
|
|
defaultPollingParsingErrorLimit = 3
|
2020-05-25 23:59:15 +02:00
|
|
|
defaultRunMigrations = false
|
|
|
|
defaultDatabaseURL = "user=postgres password=postgres dbname=miniflux2 sslmode=disable"
|
|
|
|
defaultDatabaseMaxConns = 20
|
|
|
|
defaultDatabaseMinConns = 1
|
|
|
|
defaultListenAddr = "127.0.0.1:8080"
|
|
|
|
defaultCertFile = ""
|
|
|
|
defaultKeyFile = ""
|
|
|
|
defaultCertDomain = ""
|
|
|
|
defaultCleanupFrequencyHours = 24
|
|
|
|
defaultCleanupArchiveReadDays = 60
|
2020-09-13 05:04:06 +02:00
|
|
|
defaultCleanupArchiveUnreadDays = 180
|
2020-05-25 23:59:15 +02:00
|
|
|
defaultCleanupRemoveSessionsDays = 30
|
|
|
|
defaultProxyImages = "http-only"
|
2021-01-27 13:50:34 +01:00
|
|
|
defaultFetchYouTubeWatchTime = false
|
2020-05-25 23:59:15 +02:00
|
|
|
defaultCreateAdmin = false
|
2020-06-30 05:49:05 +02:00
|
|
|
defaultAdminUsername = ""
|
|
|
|
defaultAdminPassword = ""
|
2020-05-25 23:59:15 +02:00
|
|
|
defaultOAuth2UserCreation = false
|
|
|
|
defaultOAuth2ClientID = ""
|
|
|
|
defaultOAuth2ClientSecret = ""
|
|
|
|
defaultOAuth2RedirectURL = ""
|
|
|
|
defaultOAuth2OidcDiscoveryEndpoint = ""
|
|
|
|
defaultOAuth2Provider = ""
|
|
|
|
defaultPocketConsumerKey = ""
|
|
|
|
defaultHTTPClientTimeout = 20
|
|
|
|
defaultHTTPClientMaxBodySize = 15
|
2020-09-10 08:28:54 +02:00
|
|
|
defaultHTTPClientProxy = ""
|
2020-05-25 23:59:15 +02:00
|
|
|
defaultAuthProxyHeader = ""
|
|
|
|
defaultAuthProxyUserCreation = false
|
2020-09-13 03:31:45 +02:00
|
|
|
defaultMaintenanceMode = false
|
|
|
|
defaultMaintenanceMessage = "Miniflux is currently under maintenance"
|
2020-09-28 01:01:06 +02:00
|
|
|
defaultMetricsCollector = false
|
|
|
|
defaultMetricsRefreshInterval = 60
|
|
|
|
defaultMetricsAllowedNetworks = "127.0.0.1/8"
|
2019-06-02 03:18:09 +02:00
|
|
|
)
|
|
|
|
|
2020-12-17 06:16:04 +01:00
|
|
|
var defaultHTTPClientUserAgent = "Mozilla/5.0 (compatible; Miniflux/" + version.Version + "; +https://miniflux.app)"
|
|
|
|
|
2020-12-30 04:43:37 +01:00
|
|
|
// Option contains a key to value map of a single option. It may be used to output debug strings.
|
|
|
|
type Option struct {
|
|
|
|
Key string
|
|
|
|
Value interface{}
|
|
|
|
}
|
|
|
|
|
2019-06-02 03:18:09 +02:00
|
|
|
// Options contains configuration options.
|
|
|
|
type Options struct {
|
2020-05-25 23:59:15 +02:00
|
|
|
HTTPS bool
|
|
|
|
logDateTime bool
|
|
|
|
hsts bool
|
|
|
|
httpService bool
|
|
|
|
schedulerService bool
|
|
|
|
debug bool
|
2020-12-19 00:08:17 +01:00
|
|
|
serverTimingHeader bool
|
2020-05-25 23:59:15 +02:00
|
|
|
baseURL string
|
|
|
|
rootURL string
|
|
|
|
basePath string
|
|
|
|
databaseURL string
|
|
|
|
databaseMaxConns int
|
|
|
|
databaseMinConns int
|
|
|
|
runMigrations bool
|
|
|
|
listenAddr string
|
|
|
|
certFile string
|
|
|
|
certDomain string
|
|
|
|
certKeyFile string
|
|
|
|
cleanupFrequencyHours int
|
|
|
|
cleanupArchiveReadDays int
|
2020-09-13 05:04:06 +02:00
|
|
|
cleanupArchiveUnreadDays int
|
2020-05-25 23:59:15 +02:00
|
|
|
cleanupRemoveSessionsDays int
|
|
|
|
pollingFrequency int
|
|
|
|
batchSize int
|
|
|
|
pollingScheduler string
|
|
|
|
schedulerEntryFrequencyMinInterval int
|
|
|
|
schedulerEntryFrequencyMaxInterval int
|
2021-01-26 06:41:36 +01:00
|
|
|
pollingParsingErrorLimit int
|
2020-05-25 23:59:15 +02:00
|
|
|
workerPoolSize int
|
|
|
|
createAdmin bool
|
2020-06-30 05:49:05 +02:00
|
|
|
adminUsername string
|
|
|
|
adminPassword string
|
2020-05-25 23:59:15 +02:00
|
|
|
proxyImages string
|
2021-01-27 13:50:34 +01:00
|
|
|
fetchYouTubeWatchTime bool
|
2020-05-25 23:59:15 +02:00
|
|
|
oauth2UserCreationAllowed bool
|
|
|
|
oauth2ClientID string
|
|
|
|
oauth2ClientSecret string
|
|
|
|
oauth2RedirectURL string
|
|
|
|
oauth2OidcDiscoveryEndpoint string
|
|
|
|
oauth2Provider string
|
|
|
|
pocketConsumerKey string
|
|
|
|
httpClientTimeout int
|
|
|
|
httpClientMaxBodySize int64
|
2020-09-10 08:28:54 +02:00
|
|
|
httpClientProxy string
|
2020-11-29 21:11:38 +01:00
|
|
|
httpClientUserAgent string
|
2020-05-25 23:59:15 +02:00
|
|
|
authProxyHeader string
|
|
|
|
authProxyUserCreation bool
|
2020-09-13 03:31:45 +02:00
|
|
|
maintenanceMode bool
|
|
|
|
maintenanceMessage string
|
2020-09-28 01:01:06 +02:00
|
|
|
metricsCollector bool
|
|
|
|
metricsRefreshInterval int
|
|
|
|
metricsAllowedNetworks []string
|
2019-06-02 03:18:09 +02:00
|
|
|
}
|
|
|
|
|
2019-06-03 03:20:59 +02:00
|
|
|
// NewOptions returns Options with default values.
|
|
|
|
func NewOptions() *Options {
|
|
|
|
return &Options{
|
2020-05-25 23:59:15 +02:00
|
|
|
HTTPS: defaultHTTPS,
|
|
|
|
logDateTime: defaultLogDateTime,
|
|
|
|
hsts: defaultHSTS,
|
|
|
|
httpService: defaultHTTPService,
|
|
|
|
schedulerService: defaultSchedulerService,
|
|
|
|
debug: defaultDebug,
|
2020-12-19 00:08:17 +01:00
|
|
|
serverTimingHeader: defaultTiming,
|
2020-05-25 23:59:15 +02:00
|
|
|
baseURL: defaultBaseURL,
|
|
|
|
rootURL: defaultRootURL,
|
|
|
|
basePath: defaultBasePath,
|
|
|
|
databaseURL: defaultDatabaseURL,
|
|
|
|
databaseMaxConns: defaultDatabaseMaxConns,
|
|
|
|
databaseMinConns: defaultDatabaseMinConns,
|
|
|
|
runMigrations: defaultRunMigrations,
|
|
|
|
listenAddr: defaultListenAddr,
|
|
|
|
certFile: defaultCertFile,
|
|
|
|
certDomain: defaultCertDomain,
|
|
|
|
certKeyFile: defaultKeyFile,
|
|
|
|
cleanupFrequencyHours: defaultCleanupFrequencyHours,
|
|
|
|
cleanupArchiveReadDays: defaultCleanupArchiveReadDays,
|
2020-09-13 05:04:06 +02:00
|
|
|
cleanupArchiveUnreadDays: defaultCleanupArchiveUnreadDays,
|
2020-05-25 23:59:15 +02:00
|
|
|
cleanupRemoveSessionsDays: defaultCleanupRemoveSessionsDays,
|
|
|
|
pollingFrequency: defaultPollingFrequency,
|
|
|
|
batchSize: defaultBatchSize,
|
|
|
|
pollingScheduler: defaultPollingScheduler,
|
|
|
|
schedulerEntryFrequencyMinInterval: defaultSchedulerEntryFrequencyMinInterval,
|
|
|
|
schedulerEntryFrequencyMaxInterval: defaultSchedulerEntryFrequencyMaxInterval,
|
2021-01-26 06:41:36 +01:00
|
|
|
pollingParsingErrorLimit: defaultPollingParsingErrorLimit,
|
2020-05-25 23:59:15 +02:00
|
|
|
workerPoolSize: defaultWorkerPoolSize,
|
|
|
|
createAdmin: defaultCreateAdmin,
|
|
|
|
proxyImages: defaultProxyImages,
|
2021-01-27 13:50:34 +01:00
|
|
|
fetchYouTubeWatchTime: defaultFetchYouTubeWatchTime,
|
2020-05-25 23:59:15 +02:00
|
|
|
oauth2UserCreationAllowed: defaultOAuth2UserCreation,
|
|
|
|
oauth2ClientID: defaultOAuth2ClientID,
|
|
|
|
oauth2ClientSecret: defaultOAuth2ClientSecret,
|
|
|
|
oauth2RedirectURL: defaultOAuth2RedirectURL,
|
|
|
|
oauth2OidcDiscoveryEndpoint: defaultOAuth2OidcDiscoveryEndpoint,
|
|
|
|
oauth2Provider: defaultOAuth2Provider,
|
|
|
|
pocketConsumerKey: defaultPocketConsumerKey,
|
|
|
|
httpClientTimeout: defaultHTTPClientTimeout,
|
|
|
|
httpClientMaxBodySize: defaultHTTPClientMaxBodySize * 1024 * 1024,
|
2020-09-10 08:28:54 +02:00
|
|
|
httpClientProxy: defaultHTTPClientProxy,
|
2020-12-17 06:16:04 +01:00
|
|
|
httpClientUserAgent: defaultHTTPClientUserAgent,
|
2020-05-25 23:59:15 +02:00
|
|
|
authProxyHeader: defaultAuthProxyHeader,
|
|
|
|
authProxyUserCreation: defaultAuthProxyUserCreation,
|
2020-09-13 03:31:45 +02:00
|
|
|
maintenanceMode: defaultMaintenanceMode,
|
|
|
|
maintenanceMessage: defaultMaintenanceMessage,
|
2020-09-28 01:01:06 +02:00
|
|
|
metricsCollector: defaultMetricsCollector,
|
|
|
|
metricsRefreshInterval: defaultMetricsRefreshInterval,
|
|
|
|
metricsAllowedNetworks: []string{defaultMetricsAllowedNetworks},
|
2019-06-03 03:20:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-09 02:16:12 +02:00
|
|
|
// LogDateTime returns true if the date/time should be displayed in log messages.
|
|
|
|
func (o *Options) LogDateTime() bool {
|
|
|
|
return o.logDateTime
|
|
|
|
}
|
|
|
|
|
2020-09-13 03:31:45 +02:00
|
|
|
// HasMaintenanceMode returns true if maintenance mode is enabled.
|
|
|
|
func (o *Options) HasMaintenanceMode() bool {
|
|
|
|
return o.maintenanceMode
|
|
|
|
}
|
|
|
|
|
|
|
|
// MaintenanceMessage returns maintenance message.
|
|
|
|
func (o *Options) MaintenanceMessage() string {
|
|
|
|
return o.maintenanceMessage
|
|
|
|
}
|
|
|
|
|
2019-06-02 03:18:09 +02:00
|
|
|
// HasDebugMode returns true if debug mode is enabled.
|
|
|
|
func (o *Options) HasDebugMode() bool {
|
|
|
|
return o.debug
|
|
|
|
}
|
|
|
|
|
2020-12-19 00:08:17 +01:00
|
|
|
// HasServerTimingHeader returns true if server-timing headers enabled.
|
|
|
|
func (o *Options) HasServerTimingHeader() bool {
|
|
|
|
return o.serverTimingHeader
|
|
|
|
}
|
|
|
|
|
2019-06-02 03:18:09 +02:00
|
|
|
// BaseURL returns the application base URL with path.
|
|
|
|
func (o *Options) BaseURL() string {
|
|
|
|
return o.baseURL
|
|
|
|
}
|
|
|
|
|
|
|
|
// RootURL returns the base URL without path.
|
|
|
|
func (o *Options) RootURL() string {
|
|
|
|
return o.rootURL
|
|
|
|
}
|
|
|
|
|
|
|
|
// BasePath returns the application base path according to the base URL.
|
|
|
|
func (o *Options) BasePath() string {
|
|
|
|
return o.basePath
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsDefaultDatabaseURL returns true if the default database URL is used.
|
|
|
|
func (o *Options) IsDefaultDatabaseURL() bool {
|
|
|
|
return o.databaseURL == defaultDatabaseURL
|
|
|
|
}
|
|
|
|
|
|
|
|
// DatabaseURL returns the database URL.
|
|
|
|
func (o *Options) DatabaseURL() string {
|
|
|
|
return o.databaseURL
|
|
|
|
}
|
|
|
|
|
|
|
|
// DatabaseMaxConns returns the maximum number of database connections.
|
|
|
|
func (o *Options) DatabaseMaxConns() int {
|
|
|
|
return o.databaseMaxConns
|
|
|
|
}
|
|
|
|
|
|
|
|
// DatabaseMinConns returns the minimum number of database connections.
|
|
|
|
func (o *Options) DatabaseMinConns() int {
|
|
|
|
return o.databaseMinConns
|
|
|
|
}
|
|
|
|
|
|
|
|
// ListenAddr returns the listen address for the HTTP server.
|
|
|
|
func (o *Options) ListenAddr() string {
|
|
|
|
return o.listenAddr
|
|
|
|
}
|
|
|
|
|
|
|
|
// CertFile returns the SSL certificate filename if any.
|
|
|
|
func (o *Options) CertFile() string {
|
|
|
|
return o.certFile
|
|
|
|
}
|
|
|
|
|
|
|
|
// CertKeyFile returns the private key filename for custom SSL certificate.
|
|
|
|
func (o *Options) CertKeyFile() string {
|
|
|
|
return o.certKeyFile
|
|
|
|
}
|
|
|
|
|
|
|
|
// CertDomain returns the domain to use for Let's Encrypt certificate.
|
|
|
|
func (o *Options) CertDomain() string {
|
|
|
|
return o.certDomain
|
|
|
|
}
|
|
|
|
|
2019-09-15 20:47:39 +02:00
|
|
|
// CleanupFrequencyHours returns the interval in hours for cleanup jobs.
|
|
|
|
func (o *Options) CleanupFrequencyHours() int {
|
|
|
|
return o.cleanupFrequencyHours
|
|
|
|
}
|
|
|
|
|
|
|
|
// CleanupArchiveReadDays returns the number of days after which marking read items as removed.
|
|
|
|
func (o *Options) CleanupArchiveReadDays() int {
|
|
|
|
return o.cleanupArchiveReadDays
|
|
|
|
}
|
|
|
|
|
2020-09-13 05:04:06 +02:00
|
|
|
// CleanupArchiveUnreadDays returns the number of days after which marking unread items as removed.
|
|
|
|
func (o *Options) CleanupArchiveUnreadDays() int {
|
|
|
|
return o.cleanupArchiveUnreadDays
|
|
|
|
}
|
|
|
|
|
2019-09-15 20:47:39 +02:00
|
|
|
// CleanupRemoveSessionsDays returns the number of days after which to remove sessions.
|
|
|
|
func (o *Options) CleanupRemoveSessionsDays() int {
|
|
|
|
return o.cleanupRemoveSessionsDays
|
2019-06-02 03:18:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// WorkerPoolSize returns the number of background worker.
|
|
|
|
func (o *Options) WorkerPoolSize() int {
|
|
|
|
return o.workerPoolSize
|
|
|
|
}
|
|
|
|
|
|
|
|
// PollingFrequency returns the interval to refresh feeds in the background.
|
|
|
|
func (o *Options) PollingFrequency() int {
|
|
|
|
return o.pollingFrequency
|
|
|
|
}
|
|
|
|
|
|
|
|
// BatchSize returns the number of feeds to send for background processing.
|
|
|
|
func (o *Options) BatchSize() int {
|
|
|
|
return o.batchSize
|
|
|
|
}
|
|
|
|
|
2020-05-25 23:59:15 +02:00
|
|
|
// PollingScheduler returns the scheduler used for polling feeds.
|
2020-05-25 23:06:56 +02:00
|
|
|
func (o *Options) PollingScheduler() string {
|
|
|
|
return o.pollingScheduler
|
|
|
|
}
|
|
|
|
|
2020-05-25 23:59:15 +02:00
|
|
|
// SchedulerEntryFrequencyMaxInterval returns the maximum interval in minutes for the entry frequency scheduler.
|
|
|
|
func (o *Options) SchedulerEntryFrequencyMaxInterval() int {
|
|
|
|
return o.schedulerEntryFrequencyMaxInterval
|
2020-05-25 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
2020-05-25 23:59:15 +02:00
|
|
|
// SchedulerEntryFrequencyMinInterval returns the minimum interval in minutes for the entry frequency scheduler.
|
|
|
|
func (o *Options) SchedulerEntryFrequencyMinInterval() int {
|
|
|
|
return o.schedulerEntryFrequencyMinInterval
|
2020-05-25 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
2021-01-26 06:41:36 +01:00
|
|
|
// PollingParsingErrorLimit returns the limit of errors when to stop polling.
|
|
|
|
func (o *Options) PollingParsingErrorLimit() int {
|
|
|
|
return o.pollingParsingErrorLimit
|
|
|
|
}
|
|
|
|
|
2019-06-02 03:18:09 +02:00
|
|
|
// IsOAuth2UserCreationAllowed returns true if user creation is allowed for OAuth2 users.
|
|
|
|
func (o *Options) IsOAuth2UserCreationAllowed() bool {
|
|
|
|
return o.oauth2UserCreationAllowed
|
|
|
|
}
|
|
|
|
|
|
|
|
// OAuth2ClientID returns the OAuth2 Client ID.
|
|
|
|
func (o *Options) OAuth2ClientID() string {
|
|
|
|
return o.oauth2ClientID
|
|
|
|
}
|
|
|
|
|
|
|
|
// OAuth2ClientSecret returns the OAuth2 client secret.
|
|
|
|
func (o *Options) OAuth2ClientSecret() string {
|
|
|
|
return o.oauth2ClientSecret
|
|
|
|
}
|
|
|
|
|
|
|
|
// OAuth2RedirectURL returns the OAuth2 redirect URL.
|
|
|
|
func (o *Options) OAuth2RedirectURL() string {
|
|
|
|
return o.oauth2RedirectURL
|
|
|
|
}
|
|
|
|
|
2020-03-08 03:45:19 +01:00
|
|
|
// OAuth2OidcDiscoveryEndpoint returns the OAuth2 OIDC discovery endpoint.
|
|
|
|
func (o *Options) OAuth2OidcDiscoveryEndpoint() string {
|
|
|
|
return o.oauth2OidcDiscoveryEndpoint
|
|
|
|
}
|
|
|
|
|
2019-06-02 03:18:09 +02:00
|
|
|
// OAuth2Provider returns the name of the OAuth2 provider configured.
|
|
|
|
func (o *Options) OAuth2Provider() string {
|
|
|
|
return o.oauth2Provider
|
|
|
|
}
|
|
|
|
|
|
|
|
// HasHSTS returns true if HTTP Strict Transport Security is enabled.
|
|
|
|
func (o *Options) HasHSTS() bool {
|
|
|
|
return o.hsts
|
|
|
|
}
|
|
|
|
|
|
|
|
// RunMigrations returns true if the environment variable RUN_MIGRATIONS is not empty.
|
|
|
|
func (o *Options) RunMigrations() bool {
|
|
|
|
return o.runMigrations
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateAdmin returns true if the environment variable CREATE_ADMIN is not empty.
|
|
|
|
func (o *Options) CreateAdmin() bool {
|
|
|
|
return o.createAdmin
|
|
|
|
}
|
|
|
|
|
2020-06-30 05:49:05 +02:00
|
|
|
// AdminUsername returns the admin username if defined.
|
|
|
|
func (o *Options) AdminUsername() string {
|
|
|
|
return o.adminUsername
|
|
|
|
}
|
|
|
|
|
|
|
|
// AdminPassword returns the admin password if defined.
|
|
|
|
func (o *Options) AdminPassword() string {
|
|
|
|
return o.adminPassword
|
|
|
|
}
|
|
|
|
|
2021-01-27 13:50:34 +01:00
|
|
|
// FetchYouTubeWatchTime returns true if the YouTube video duration
|
|
|
|
// should be fetched and used as a reading time.
|
|
|
|
func (o *Options) FetchYouTubeWatchTime() bool {
|
|
|
|
return o.fetchYouTubeWatchTime
|
|
|
|
}
|
|
|
|
|
2019-06-02 03:18:09 +02:00
|
|
|
// ProxyImages returns "none" to never proxy, "http-only" to proxy non-HTTPS, "all" to always proxy.
|
|
|
|
func (o *Options) ProxyImages() string {
|
|
|
|
return o.proxyImages
|
|
|
|
}
|
|
|
|
|
|
|
|
// HasHTTPService returns true if the HTTP service is enabled.
|
|
|
|
func (o *Options) HasHTTPService() bool {
|
|
|
|
return o.httpService
|
|
|
|
}
|
|
|
|
|
|
|
|
// HasSchedulerService returns true if the scheduler service is enabled.
|
|
|
|
func (o *Options) HasSchedulerService() bool {
|
|
|
|
return o.schedulerService
|
|
|
|
}
|
|
|
|
|
|
|
|
// PocketConsumerKey returns the Pocket Consumer Key if configured.
|
|
|
|
func (o *Options) PocketConsumerKey(defaultValue string) string {
|
|
|
|
if o.pocketConsumerKey != "" {
|
|
|
|
return o.pocketConsumerKey
|
|
|
|
}
|
|
|
|
return defaultValue
|
|
|
|
}
|
2019-06-02 16:13:35 +02:00
|
|
|
|
|
|
|
// HTTPClientTimeout returns the time limit in seconds before the HTTP client cancel the request.
|
|
|
|
func (o *Options) HTTPClientTimeout() int {
|
|
|
|
return o.httpClientTimeout
|
|
|
|
}
|
|
|
|
|
|
|
|
// HTTPClientMaxBodySize returns the number of bytes allowed for the HTTP client to transfer.
|
|
|
|
func (o *Options) HTTPClientMaxBodySize() int64 {
|
|
|
|
return o.httpClientMaxBodySize
|
|
|
|
}
|
2019-06-03 03:20:59 +02:00
|
|
|
|
2020-09-10 08:28:54 +02:00
|
|
|
// HTTPClientProxy returns the proxy URL for HTTP client.
|
|
|
|
func (o *Options) HTTPClientProxy() string {
|
|
|
|
return o.httpClientProxy
|
|
|
|
}
|
|
|
|
|
|
|
|
// HasHTTPClientProxyConfigured returns true if the HTTP proxy is configured.
|
|
|
|
func (o *Options) HasHTTPClientProxyConfigured() bool {
|
|
|
|
return o.httpClientProxy != ""
|
|
|
|
}
|
|
|
|
|
2020-01-29 11:45:59 +01:00
|
|
|
// AuthProxyHeader returns an HTTP header name that contains username for
|
|
|
|
// authentication using auth proxy.
|
|
|
|
func (o *Options) AuthProxyHeader() string {
|
|
|
|
return o.authProxyHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsAuthProxyUserCreationAllowed returns true if user creation is allowed for
|
|
|
|
// users authenticated using auth proxy.
|
|
|
|
func (o *Options) IsAuthProxyUserCreationAllowed() bool {
|
|
|
|
return o.authProxyUserCreation
|
|
|
|
}
|
|
|
|
|
2020-09-28 01:01:06 +02:00
|
|
|
// HasMetricsCollector returns true if metrics collection is enabled.
|
|
|
|
func (o *Options) HasMetricsCollector() bool {
|
|
|
|
return o.metricsCollector
|
|
|
|
}
|
|
|
|
|
|
|
|
// MetricsRefreshInterval returns the refresh interval in seconds.
|
|
|
|
func (o *Options) MetricsRefreshInterval() int {
|
|
|
|
return o.metricsRefreshInterval
|
|
|
|
}
|
|
|
|
|
|
|
|
// MetricsAllowedNetworks returns the list of networks allowed to connect to the metrics endpoint.
|
|
|
|
func (o *Options) MetricsAllowedNetworks() []string {
|
|
|
|
return o.metricsAllowedNetworks
|
|
|
|
}
|
|
|
|
|
2020-11-29 21:11:38 +01:00
|
|
|
// HTTPClientUserAgent returns the global User-Agent header for miniflux.
|
|
|
|
func (o *Options) HTTPClientUserAgent() string {
|
|
|
|
return o.httpClientUserAgent
|
2020-11-27 17:37:55 +01:00
|
|
|
}
|
|
|
|
|
2020-12-30 04:43:37 +01:00
|
|
|
// SortedOptions returns options as a list of key value pairs, sorted by keys.
|
|
|
|
func (o *Options) SortedOptions() []*Option {
|
|
|
|
var keyValues = map[string]interface{}{
|
|
|
|
"ADMIN_PASSWORD": o.adminPassword,
|
|
|
|
"ADMIN_USERNAME": o.adminUsername,
|
|
|
|
"AUTH_PROXY_HEADER": o.authProxyHeader,
|
|
|
|
"AUTH_PROXY_USER_CREATION": o.authProxyUserCreation,
|
|
|
|
"BASE_PATH": o.basePath,
|
|
|
|
"BASE_URL": o.baseURL,
|
|
|
|
"BATCH_SIZE": o.batchSize,
|
|
|
|
"CERT_DOMAIN": o.certDomain,
|
|
|
|
"CERT_FILE": o.certFile,
|
|
|
|
"CLEANUP_ARCHIVE_READ_DAYS": o.cleanupArchiveReadDays,
|
|
|
|
"CLEANUP_ARCHIVE_UNREAD_DAYS": o.cleanupArchiveUnreadDays,
|
|
|
|
"CLEANUP_FREQUENCY_HOURS": o.cleanupFrequencyHours,
|
|
|
|
"CLEANUP_REMOVE_SESSIONS_DAYS": o.cleanupRemoveSessionsDays,
|
|
|
|
"CREATE_ADMIN": o.createAdmin,
|
|
|
|
"DATABASE_MAX_CONNS": o.databaseMaxConns,
|
|
|
|
"DATABASE_MIN_CONNS": o.databaseMinConns,
|
|
|
|
"DATABASE_URL": o.databaseURL,
|
|
|
|
"DEBUG": o.debug,
|
2021-01-27 13:50:34 +01:00
|
|
|
"FETCH_YOUTUBE_WATCH_TIME": o.fetchYouTubeWatchTime,
|
2020-12-30 04:43:37 +01:00
|
|
|
"HSTS": o.hsts,
|
|
|
|
"HTTPS": o.HTTPS,
|
|
|
|
"HTTP_CLIENT_MAX_BODY_SIZE": o.httpClientMaxBodySize,
|
|
|
|
"HTTP_CLIENT_PROXY": o.httpClientProxy,
|
|
|
|
"HTTP_CLIENT_TIMEOUT": o.httpClientTimeout,
|
|
|
|
"HTTP_CLIENT_USER_AGENT": o.httpClientUserAgent,
|
|
|
|
"HTTP_SERVICE": o.httpService,
|
|
|
|
"KEY_FILE": o.certKeyFile,
|
|
|
|
"LISTEN_ADDR": o.listenAddr,
|
|
|
|
"LOG_DATE_TIME": o.logDateTime,
|
|
|
|
"MAINTENANCE_MESSAGE": o.maintenanceMessage,
|
|
|
|
"MAINTENANCE_MODE": o.maintenanceMode,
|
|
|
|
"METRICS_ALLOWED_NETWORKS": o.metricsAllowedNetworks,
|
|
|
|
"METRICS_COLLECTOR": o.metricsCollector,
|
|
|
|
"METRICS_REFRESH_INTERVAL": o.metricsRefreshInterval,
|
|
|
|
"OAUTH2_CLIENT_ID": o.oauth2ClientID,
|
|
|
|
"OAUTH2_CLIENT_SECRET": o.oauth2ClientSecret,
|
|
|
|
"OAUTH2_OIDC_DISCOVERY_ENDPOINT": o.oauth2OidcDiscoveryEndpoint,
|
|
|
|
"OAUTH2_PROVIDER": o.oauth2Provider,
|
|
|
|
"OAUTH2_REDIRECT_URL": o.oauth2RedirectURL,
|
|
|
|
"OAUTH2_USER_CREATION": o.oauth2UserCreationAllowed,
|
|
|
|
"POCKET_CONSUMER_KEY": o.pocketConsumerKey,
|
|
|
|
"POLLING_FREQUENCY": o.pollingFrequency,
|
2021-01-26 06:41:36 +01:00
|
|
|
"POLLING_PARSING_ERROR_LIMIT": o.pollingParsingErrorLimit,
|
2020-12-30 04:43:37 +01:00
|
|
|
"POLLING_SCHEDULER": o.pollingScheduler,
|
|
|
|
"PROXY_IMAGES": o.proxyImages,
|
|
|
|
"ROOT_URL": o.rootURL,
|
|
|
|
"RUN_MIGRATIONS": o.runMigrations,
|
|
|
|
"SCHEDULER_ENTRY_FREQUENCY_MAX_INTERVAL": o.schedulerEntryFrequencyMaxInterval,
|
|
|
|
"SCHEDULER_ENTRY_FREQUENCY_MIN_INTERVAL": o.schedulerEntryFrequencyMinInterval,
|
|
|
|
"SCHEDULER_SERVICE": o.schedulerService,
|
|
|
|
"SERVER_TIMING_HEADER": o.serverTimingHeader,
|
|
|
|
"WORKER_POOL_SIZE": o.workerPoolSize,
|
|
|
|
}
|
|
|
|
|
|
|
|
keys := make([]string, 0, len(keyValues))
|
|
|
|
for key := range keyValues {
|
|
|
|
keys = append(keys, key)
|
|
|
|
}
|
|
|
|
sort.Strings(keys)
|
|
|
|
|
|
|
|
var sortedOptions []*Option
|
|
|
|
for _, key := range keys {
|
|
|
|
sortedOptions = append(sortedOptions, &Option{Key: key, Value: keyValues[key]})
|
|
|
|
}
|
|
|
|
return sortedOptions
|
|
|
|
}
|
|
|
|
|
2019-06-03 03:20:59 +02:00
|
|
|
func (o *Options) String() string {
|
|
|
|
var builder strings.Builder
|
2020-12-30 04:43:37 +01:00
|
|
|
|
|
|
|
for _, option := range o.SortedOptions() {
|
|
|
|
builder.WriteString(fmt.Sprintf("%s: %v\n", option.Key, option.Value))
|
|
|
|
}
|
|
|
|
|
2019-06-03 03:20:59 +02:00
|
|
|
return builder.String()
|
|
|
|
}
|