config

package
v0.0.0-...-5cfdc92 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAuthMethod     = errors.New("invalid auth method")
	ErrInvalidConnectionType = errors.New("invalid address protocol")
)
View Source
var ErrInvalidLogFormat = errors.New("invalid log format")
View Source
var (
	ErrUnserializing = errors.New("error unserializing conf")
)

Functions

func BuildLogger

func BuildLogger(conf Log, stdout, stderr zapcore.WriteSyncer) (*zaplog.Logger, error)

func CobraInitialize

func CobraInitialize(cfgFile string)

func ConfigureLogger

func ConfigureLogger(conf Log, stdout, stderr zapcore.WriteSyncer) (err error)

func GetDefaultInt

func GetDefaultInt(name string) int

func GetDefaultString

func GetDefaultString(name string) string

func Hook

func Hook(dataType reflect.Type, targetDataType reflect.Type, rawData interface{}) (interface{}, error)

func Init

func Init(cfgFile string)

func LoadConfigFile

func LoadConfigFile(cfgFile string)

func LogHook

func LogHook(dataType reflect.Type, targetDataType reflect.Type, rawData interface{}) (interface{}, error)

func RelayHook

func RelayHook(dataType reflect.Type, targetDataType reflect.Type, rawData interface{}) (interface{}, error)

func Reload

func Reload()

func SMTPHook

func SMTPHook(dataType reflect.Type, targetDataType reflect.Type, rawData interface{}) (interface{}, error)

func SetDefaults

func SetDefaults(force bool)

func SetDefaultsForViper

func SetDefaultsForViper(force bool, v *viper.Viper)

Types

type Config

type Config struct {
	Log   Log
	Relay Relay
	SMTP  SMTP
}

func Get

func Get() Config

type Log

type Log struct {
	Color           bool
	Format          LogFormat
	Level           zapcore.Level
	StacktraceLevel zapcore.Level
}

type LogFormat

type LogFormat int
const (
	Console LogFormat = iota
	JSON
	Logfmt
)

type Relay

type Relay struct {
	OutgoingServer RelayOutgoingServer
}

type RelayAuthMethod

type RelayAuthMethod int
const (
	AuthNone RelayAuthMethod = iota
	AuthPlain
	AuthCramMD5
)

type RelayConnectionType

type RelayConnectionType int
const (
	ConnectionPlain RelayConnectionType = iota
	ConnectionStartTLS
	ConnectionTLS
)

type RelayOutgoingServer

type RelayOutgoingServer struct {
	AuthMethod     RelayAuthMethod
	ConnectionType RelayConnectionType
	FromEmail      string
	Host           string
	Password       string
	Port           int
	Username       string
	VerifyTLS      bool
}

type SMTP

type SMTP struct {
	Auth      SMTPAuth
	Hostname  string
	Limit     SMTPLimit
	Listen    []SMTPListen
	Timeout   SMTPTimeout
	TLS       SMTPTLS
	Whitelist []string
}

type SMTPAuth

type SMTPAuth struct {
	Enabled bool
	Users   []SMTPAuthUser
}

type SMTPAuthUser

type SMTPAuthUser struct {
	Email        string
	PasswordHash string
}

type SMTPLimit

type SMTPLimit struct {
	Connections int
	MessageSize int
	Recipients  int
}

type SMTPListen

type SMTPListen struct {
	Proto string
	Host  string
	Port  string
}

type SMTPTLS

type SMTPTLS struct {
	Key              string
	Certificate      string
	KeyFile          string
	CertificateFile  string
	ForceForStartTLS bool
}

type SMTPTimeout

type SMTPTimeout struct {
	Read  time.Duration
	Write time.Duration
	Data  time.Duration
}

Jump to

Keyboard shortcuts

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