config

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package config holds the configuration of Clowder and its validation.

Index

Constants

View Source
const (
	// DefaultListenAddr is the address the server listens on.
	DefaultListenAddr = ":8080"
	// DefaultDataDir is the directory that holds clowder.db and files/.
	DefaultDataDir = "./data"
	// DefaultBaseURL is the URL used to build invitation links.
	DefaultBaseURL = "http://localhost:8080"
	// DefaultMaxAttachmentSize is the largest attachment accepted, in bytes (25 MB).
	DefaultMaxAttachmentSize int64 = 25 << 20
	// DefaultMaxAttachmentsPerPost is the most attachments one post may carry.
	DefaultMaxAttachmentsPerPost = 10
	// DefaultSessionLifetime is how long a login session lasts (30 days).
	DefaultSessionLifetime = 30 * 24 * time.Hour
	// DefaultInvitationLifetime is how long an invitation stays valid (7 days).
	DefaultInvitationLifetime = 7 * 24 * time.Hour
	// DefaultLogLevel is the log level.
	DefaultLogLevel = "info"
)

Defaults of the settings (SPEC §11).

View Source
const (
	// TagRedisURLInvalid is the tag of a Redis URL that is not empty and not a redis:// or rediss:// URL with a host.
	TagRedisURLInvalid = "RedisURLInvalid"
	// TagRedisNeedsPostgres is the tag of a Redis URL given without a PostgreSQL database URL.
	TagRedisNeedsPostgres = "RedisNeedsPostgres"
	// TagDatabaseURLInvalid is the tag of a database URL that is not empty and not a postgres:// or postgresql:// URL with a host.
	TagDatabaseURLInvalid = "DatabaseURLInvalid"
	// TagListenAddrEmpty is the tag of a listen address that is empty.
	TagListenAddrEmpty = "ListenAddrEmpty"
	// TagDataDirEmpty is the tag of a data directory that is empty.
	TagDataDirEmpty = "DataDirEmpty"
	// TagBaseURLInvalid is the tag of a base URL that is not an absolute http or https URL.
	TagBaseURLInvalid = "BaseURLInvalid"
	// TagMaxAttachmentSizeInvalid is the tag of a maximum attachment size that is not positive.
	TagMaxAttachmentSizeInvalid = "MaxAttachmentSizeInvalid"
	// TagMaxAttachmentsPerPostInvalid is the tag of a maximum number of attachments per post that is not positive.
	TagMaxAttachmentsPerPostInvalid = "MaxAttachmentsPerPostInvalid"
	// TagSessionLifetimeInvalid is the tag of a session lifetime that is not positive.
	TagSessionLifetimeInvalid = "SessionLifetimeInvalid"
	// TagInvitationLifetimeInvalid is the tag of an invitation lifetime that is not positive.
	TagInvitationLifetimeInvalid = "InvitationLifetimeInvalid"
	// TagLogLevelUnknown is the tag of a log level that is not debug, info, warn or error.
	TagLogLevelUnknown = "LogLevelUnknown"
)
View Source
const RedactedPassword = "xxxxx"

RedactedPassword replaces a password in the output of RedactURL.

Variables

This section is empty.

Functions

func RedactURL added in v1.1.0

func RedactURL(raw string) string

RedactURL returns raw with its password replaced by "xxxxx", for logs and error metadata. The password of the user info and the query parameters password and sslpassword are replaced. A string that does not parse as a URL is replaced altogether. An empty string stays empty.

Types

type Config

type Config struct {
	// ListenAddr is the address the server listens on, as host:port.
	ListenAddr string
	// DataDir is the directory that holds clowder.db and files/.
	DataDir string
	// BaseURL is the absolute http or https URL used to build invitation links.
	BaseURL string
	// MaxAttachmentSize is the largest attachment accepted, in bytes.
	MaxAttachmentSize int64
	// MaxAttachmentsPerPost is the most attachments one post may carry.
	MaxAttachmentsPerPost int
	// SessionLifetime is how long a login session lasts.
	SessionLifetime time.Duration
	// InvitationLifetime is how long an invitation stays valid.
	InvitationLifetime time.Duration
	// LogLevel is one of debug, info, warn and error.
	LogLevel string
	// TrustProxyHeaders says that Clowder runs behind a reverse proxy of our
	// own: the client address is then the last address of X-Forwarded-For (the
	// one the proxy appended) and not the address of the connection. Leave it
	// off when clients can reach Clowder directly, or they can forge the header.
	TrustProxyHeaders bool
	// DatabaseURL is the URL of the PostgreSQL database (postgres:// or
	// postgresql://, SPEC D38). Empty means SQLite in DataDir/clowder.db. It
	// holds a password: print it only through RedactURL.
	DatabaseURL string
	// RedisURL is the URL of the Redis server (redis:// or rediss://, SPEC
	// D41) that carries the live events between several Clowder processes.
	// Empty means one process with in-process events. It needs DatabaseURL
	// (PostgreSQL) and may hold a password: print it only through RedactURL.
	RedisURL string
}

Config holds the settings of a Clowder process (SPEC §11).

func Default

func Default() Config

Default returns the configuration with every setting at its default.

func (Config) SecureCookies

func (c Config) SecureCookies() bool

SecureCookies reports whether cookies get the Secure attribute: always, except when the base URL is plain http://.

func (Config) Validate

func (c Config) Validate() error

Validate checks every setting and returns a tagged error for the first one that is not usable, or nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL