config

package
v1.0.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: 3 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 (
	// 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"
)

Variables

This section is empty.

Functions

This section is 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
}

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