config

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: BSD-3-Clause Imports: 8 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"
	// DefaultMaxCalls is the most calls that one process holds at once (SPEC
	// D64).
	DefaultMaxCalls = 20
	// DefaultCallRingTimeout is how long a call rings before it is missed
	// (SPEC §7.18).
	DefaultCallRingTimeout = 45 * time.Second
)

Defaults of the settings (SPEC §11).

View Source
const (
	// TagMetricsAddrInvalid is the tag of a metrics address that is not host:port.
	TagMetricsAddrInvalid = "MetricsAddrInvalid"
	// TagMediaAddrInvalid is the tag of a media address that is not host:port.
	TagMediaAddrInvalid = "MediaAddrInvalid"
	// TagMediaPublicIPInvalid is the tag of a public media IP that is not an IP address.
	TagMediaPublicIPInvalid = "MediaPublicIPInvalid"
	// TagMaxCallsInvalid is the tag of a maximum number of calls below 1.
	TagMaxCallsInvalid = "MaxCallsInvalid"
	// TagCallRingTimeoutInvalid is the tag of a ring timeout below one second.
	TagCallRingTimeoutInvalid = "CallRingTimeoutInvalid"
	// TagSSHAddrInvalid is the tag of an SSH address that is not host:port.
	TagSSHAddrInvalid = "SSHAddrInvalid"
	// TagSSHHostKeyDirMissing is the tag of an SSH host key path in a directory that does not exist.
	TagSSHHostKeyDirMissing = "SSHHostKeyDirMissing"
	// TagSSHPublicHostInvalid is the tag of a public SSH host that is not a host name or an IP address.
	TagSSHPublicHostInvalid = "SSHPublicHostInvalid"
	// 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 DefaultSSHHostKeyFile = "ssh_host_ed25519_key"

DefaultSSHHostKeyFile is the name of the host key inside the data directory when SSHHostKey is empty.

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
	// SSHAddr is the address of the SSH server of the sign-in codes (SPEC
	// §7.16, D52), as host:port, such as ":2222". Empty means the server is
	// off.
	SSHAddr string
	// SSHHostKey is the path of the host key of the SSH server. Empty means
	// ssh_host_ed25519_key in DataDir; see SSHHostKeyPath. The key is made on
	// the first start when the file does not exist.
	SSHHostKey string
	// SSHPublicHost is the host shown in the ssh command of the settings
	// page: a host name or an IP address, without a scheme or a path. Empty
	// means the host of BaseURL; see SSHPublicHostOrDefault.
	SSHPublicHost string
	// MediaAddr is the address of the media server of the calls (SPEC §7.18,
	// D63, D64), as host:port, such as ":7882": one UDP port and one TCP port
	// with that number. Empty means calls are off.
	MediaAddr string
	// MediaPublicIP is the IP address, IPv4 or IPv6, that the media server
	// announces as its own to the browsers when it runs behind NAT (D64).
	// Empty announces the addresses of the machine.
	MediaPublicIP string
	// MetricsAddr is the address of the listener that serves the metrics at
	// GET /metrics (SPEC D60), as host:port, such as "127.0.0.1:9090". Empty
	// means there is no such listener and no metrics. The listener has no
	// login: bind it to a private address.
	MetricsAddr string
	// MaxCalls is the most calls (ringing or in progress) that one process
	// holds at once; at least 1.
	MaxCalls int
	// CallRingTimeout is how long a call rings before nobody answered it and
	// it becomes a missed call (SPEC §7.18); at least one second. The default
	// of 45 seconds is what people expect; a shorter time is for the tests of
	// the pages.
	CallRingTimeout time.Duration
}

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) SSHHostKeyPath added in v1.2.0

func (c Config) SSHHostKeyPath() string

SSHHostKeyPath returns the path of the host key: SSHHostKey, or ssh_host_ed25519_key in the data directory.

func (Config) SSHPublicHostOrDefault added in v1.2.0

func (c Config) SSHPublicHostOrDefault() string

SSHPublicHostOrDefault returns the host of the ssh command: SSHPublicHost, or the host name of the base URL.

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