Allow setting pre-generated DKIM keypair
This commit is contained in:
parent
20980659e2
commit
70571de7aa
5 changed files with 35 additions and 16 deletions
|
|
@ -65,6 +65,8 @@ env vars
|
||||||
* **POSTMOOGLE_TLS_KEY** - space separated list of paths to the SSL certificates' private keys of your domains, note that position on the key list must match the position of cert in the cert list
|
* **POSTMOOGLE_TLS_KEY** - space separated list of paths to the SSL certificates' private keys of your domains, note that position on the key list must match the position of cert in the cert list
|
||||||
* **POSTMOOGLE_TLS_REQUIRED** - require TLS connection, **even** on the non-TLS port (`POSTMOOGLE_PORT`). TLS connections are always required on the TLS port (`POSTMOOGLE_TLS_PORT`) regardless of this setting.
|
* **POSTMOOGLE_TLS_REQUIRED** - require TLS connection, **even** on the non-TLS port (`POSTMOOGLE_PORT`). TLS connections are always required on the TLS port (`POSTMOOGLE_TLS_PORT`) regardless of this setting.
|
||||||
* **POSTMOOGLE_DATA_SECRET** - secure key (password) to encrypt account data, must be 16, 24, or 32 bytes long
|
* **POSTMOOGLE_DATA_SECRET** - secure key (password) to encrypt account data, must be 16, 24, or 32 bytes long
|
||||||
|
* **POSTMOOGLE_DKIM_PRIVKEY** - DKIM private key, pre-generated before `!pm dkim` command
|
||||||
|
* **POSTMOOGLE_DKIM_SIGNATURE** - DKIM signature, pre-generated before `!pm dkim` command
|
||||||
* **POSTMOOGLE_STATUSMSG** - presence status message
|
* **POSTMOOGLE_STATUSMSG** - presence status message
|
||||||
* **POSTMOOGLE_MONITORING_SENTRY_DSN** - sentry DSN
|
* **POSTMOOGLE_MONITORING_SENTRY_DSN** - sentry DSN
|
||||||
* **POSTMOOGLE_MONITORING_SENTRY_RATE** - sentry sample rate, from 0 to 100 (default: 20)
|
* **POSTMOOGLE_MONITORING_SENTRY_RATE** - sentry sample rate, from 0 to 100 (default: 20)
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ func initMatrix(cfg *config.Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
psdc := psd.NewClient(cfg.PSD.URL, cfg.PSD.Login, cfg.PSD.Password)
|
psdc := psd.NewClient(cfg.PSD.URL, cfg.PSD.Login, cfg.PSD.Password)
|
||||||
mxc = mxconfig.New(lp, &log)
|
mxc = mxconfig.New(lp, &log, cfg.DKIM.PrivKey, cfg.DKIM.Signature)
|
||||||
q = queue.New(lp, mxc, &log)
|
q = queue.New(lp, mxc, &log)
|
||||||
mxb, err = bot.New(q, lp, &log, mxc, psdc, cfg.Proxies, cfg.Prefix, cfg.Domains, cfg.Admins, bot.MBXConfig(cfg.Mailboxes))
|
mxb, err = bot.New(q, lp, &log, mxc, psdc, cfg.Proxies, cfg.Prefix, cfg.Domains, cfg.Admins, bot.MBXConfig(cfg.Mailboxes))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -12,17 +12,21 @@ import (
|
||||||
|
|
||||||
// Manager of configs
|
// Manager of configs
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
mu utils.Mutex
|
mu utils.Mutex
|
||||||
log *zerolog.Logger
|
dkimPrivKey string
|
||||||
lp *linkpearl.Linkpearl
|
dkimSignature string
|
||||||
|
log *zerolog.Logger
|
||||||
|
lp *linkpearl.Linkpearl
|
||||||
}
|
}
|
||||||
|
|
||||||
// New config manager
|
// New config manager
|
||||||
func New(lp *linkpearl.Linkpearl, log *zerolog.Logger) *Manager {
|
func New(lp *linkpearl.Linkpearl, log *zerolog.Logger, dkimPrivKey, dkimSignature string) *Manager {
|
||||||
m := &Manager{
|
m := &Manager{
|
||||||
mu: utils.NewMutex(),
|
mu: utils.NewMutex(),
|
||||||
lp: lp,
|
lp: lp,
|
||||||
log: log,
|
log: log,
|
||||||
|
dkimPrivKey: dkimPrivKey,
|
||||||
|
dkimSignature: dkimSignature,
|
||||||
}
|
}
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
@ -38,7 +42,11 @@ func (m *Manager) GetBot(ctx context.Context) Bot {
|
||||||
}
|
}
|
||||||
if config == nil {
|
if config == nil {
|
||||||
config = make(Bot, 0)
|
config = make(Bot, 0)
|
||||||
return config
|
}
|
||||||
|
|
||||||
|
if config.DKIMPrivateKey() == "" {
|
||||||
|
config.Set(BotDKIMPrivateKey, m.dkimPrivKey)
|
||||||
|
config.Set(BotDKIMSignature, m.dkimSignature)
|
||||||
}
|
}
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,14 @@ func New() *Config {
|
||||||
Domains: migrateDomains("domain", "domains"),
|
Domains: migrateDomains("domain", "domains"),
|
||||||
Port: env.String("port", defaultConfig.Port),
|
Port: env.String("port", defaultConfig.Port),
|
||||||
Proxies: env.Slice("proxies"),
|
Proxies: env.Slice("proxies"),
|
||||||
NoEncryption: env.Bool("noencryption"),
|
DKIM: DKIM{
|
||||||
DataSecret: env.String("data.secret", defaultConfig.DataSecret),
|
PrivKey: env.String("dkim.privkey", defaultConfig.DKIM.PrivKey),
|
||||||
MaxSize: env.Int("maxsize", defaultConfig.MaxSize),
|
Signature: env.String("dkim.signature", defaultConfig.DKIM.Signature),
|
||||||
StatusMsg: env.String("statusmsg", defaultConfig.StatusMsg),
|
},
|
||||||
Admins: env.Slice("admins"),
|
DataSecret: env.String("data.secret", defaultConfig.DataSecret),
|
||||||
|
MaxSize: env.Int("maxsize", defaultConfig.MaxSize),
|
||||||
|
StatusMsg: env.String("statusmsg", defaultConfig.StatusMsg),
|
||||||
|
Admins: env.Slice("admins"),
|
||||||
Mailboxes: Mailboxes{
|
Mailboxes: Mailboxes{
|
||||||
Reserved: env.Slice("mailboxes.reserved"),
|
Reserved: env.Slice("mailboxes.reserved"),
|
||||||
Forwarded: env.Slice("mailboxes.forwarded"),
|
Forwarded: env.Slice("mailboxes.forwarded"),
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ type Config struct {
|
||||||
LogLevel string
|
LogLevel string
|
||||||
// DataSecret is account data secret key (password) to encrypt all account data values
|
// DataSecret is account data secret key (password) to encrypt all account data values
|
||||||
DataSecret string
|
DataSecret string
|
||||||
// NoEncryption disabled encryption support
|
// DKIM config
|
||||||
NoEncryption bool
|
DKIM DKIM
|
||||||
// Prefix for commands
|
// Prefix for commands
|
||||||
Prefix string
|
Prefix string
|
||||||
// MaxSize of an email (including attachments)
|
// MaxSize of an email (including attachments)
|
||||||
|
|
@ -50,6 +50,12 @@ type Config struct {
|
||||||
Relay Relay
|
Relay Relay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DKIM config
|
||||||
|
type DKIM struct {
|
||||||
|
PrivKey string
|
||||||
|
Signature string
|
||||||
|
}
|
||||||
|
|
||||||
// DB config
|
// DB config
|
||||||
type DB struct {
|
type DB struct {
|
||||||
// DSN is a database connection string
|
// DSN is a database connection string
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue