Files
postmoogle/config/types.go
Slavi Pantaleev 8ad2e29930 Add support for configuring user whitelisting
This does not do anything useful just yet.
It will be hooked to access control checks later on.

Wildcards are converted to regular expressions, because it was simpler
to do that than to write (or include) some ugly wildcard matcher library.
It also provides more flexibility, should we wish to use it later.
Regular expressions should also work well performance-wise.

We compile wildcards to regexes early on (during configuration
processing) and fail if we detect a bad pattern. This is meant to
catch various problems (typos or other mistakes) that could happen.

For this to work, configuration building had to be redone, since it can
now return an error. This may be useful in the future for validating
other configuration settings.

Related to https://gitlab.com/etke.cc/postmoogle/-/issues/1
2022-08-27 07:50:41 +03:00

56 lines
1.3 KiB
Go

package config
import "regexp"
// Config of Postmoogle
type Config struct {
// Homeserver url
Homeserver string
// Login is a MXID localpart (scheduler - OK, @scheduler:example.com - wrong)
Login string
// Password for login/password auth only
Password string
// Domain for SMTP
Domain string
// Port for SMTP
Port string
// RoomID of the admin room
LogLevel string
// NoEncryption disabled encryption support
NoEncryption bool
// NoOwner allows room settings change by any participant
NoOwner bool
// Federation allows usage of Postmoogle by users from other homeservers
Federation bool
// Prefix for commands
Prefix string
// MaxSize of an email (including attachments)
MaxSize int
// StatusMsg of the bot
StatusMsg string
// Users holds regular expression patterns of users that are allowed to use the bridge.
// The regular expression patterns are compiled from wildcard patterns like:
// `@someone:example.com`, `@*:example.com`, `@bot.*:example.com`, `@someone:*`, `@someone:*.example.com`
// An empty list means that "everyone is allowed".
Users []*regexp.Regexp
// DB config
DB DB
// Sentry config
Sentry Sentry
}
// DB config
type DB struct {
// DSN is a database connection string
DSN string
// Dialect of database, one of sqlite3, postgres
Dialect string
}
// Sentry config
type Sentry struct {
DSN string
}