mirror of
https://github.com/mjl-/mox.git
synced 2024-12-27 00:43:48 +03:00
893a6f8911
we were already accepting, processing and displaying incoming tls reports. now we start tracking TLS connection and security-policy-related errors for outgoing message deliveries as well. we send reports once a day, to the reporting addresses specified in TLSRPT records (rua) of a policy domain. these reports are about MTA-STS policies and/or DANE policies, and about STARTTLS-related failures. sending reports is enabled by default, but can be disabled through setting NoOutgoingTLSReports in mox.conf. only at the end of the implementation process came the realization that the TLSRPT policy domain for DANE (MX) hosts are separate from the TLSRPT policy for the recipient domain, and that MTA-STS and DANE TLS/policy results are typically delivered in separate reports. so MX hosts need their own TLSRPT policies. config for the per-host TLSRPT policy should be added to mox.conf for existing installs, in field HostTLSRPT. it is automatically configured by quickstart for new installs. with a HostTLSRPT config, the "dns records" and "dns check" admin pages now suggest the per-host TLSRPT record. by creating that record, you're requesting TLS reports about your MX host. gathering all the TLS/policy results is somewhat tricky. the tentacles go throughout the code. the positive result is that the TLS/policy-related code had to be cleaned up a bit. for example, the smtpclient TLS modes now reflect reality better, with independent settings about whether PKIX and/or DANE verification has to be done, and/or whether verification errors have to be ignored (e.g. for tls-required: no header). also, cached mtasts policies of mode "none" are now cleaned up once the MTA-STS DNS record goes away.
75 lines
1.7 KiB
Go
75 lines
1.7 KiB
Go
package metrics
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
)
|
|
|
|
var metricPanic = promauto.NewCounterVec(
|
|
prometheus.CounterOpts{
|
|
Name: "mox_panic_total",
|
|
Help: "Number of unhandled panics, by package.",
|
|
},
|
|
[]string{
|
|
"pkg",
|
|
},
|
|
)
|
|
|
|
type Panic string
|
|
|
|
const (
|
|
Ctl Panic = "ctl"
|
|
Import Panic = "import"
|
|
Serve Panic = "serve"
|
|
Imapserver Panic = "imapserver"
|
|
Dmarcdb Panic = "dmarcdb"
|
|
Mtastsdb Panic = "mtastsdb"
|
|
Queue Panic = "queue"
|
|
Smtpclient Panic = "smtpclient"
|
|
Smtpserver Panic = "smtpserver"
|
|
Tlsrptdb Panic = "tlsrptdb"
|
|
Dkimverify Panic = "dkimverify"
|
|
Spfverify Panic = "spfverify"
|
|
Upgradethreads Panic = "upgradethreads"
|
|
Importmanage Panic = "importmanage"
|
|
Importmessages Panic = "importmessages"
|
|
Webadmin Panic = "webadmin"
|
|
Webmailsendevent Panic = "webmailsendevent"
|
|
Webmail Panic = "webmail"
|
|
Webmailrequest Panic = "webmailrequest"
|
|
Webmailquery Panic = "webmailquery"
|
|
Webmailhandle Panic = "webmailhandle"
|
|
)
|
|
|
|
func init() {
|
|
// Ensure the panic counts are initialized to 0, so the query for change also picks
|
|
// up the first panic.
|
|
names := []Panic{
|
|
Ctl,
|
|
Import,
|
|
Serve,
|
|
Imapserver,
|
|
Mtastsdb,
|
|
Queue,
|
|
Smtpclient,
|
|
Smtpserver,
|
|
Dkimverify,
|
|
Spfverify,
|
|
Upgradethreads,
|
|
Importmanage,
|
|
Importmessages,
|
|
Webadmin,
|
|
Webmailsendevent,
|
|
Webmail,
|
|
Webmailrequest,
|
|
Webmailquery,
|
|
Webmailhandle,
|
|
}
|
|
for _, name := range names {
|
|
metricPanic.WithLabelValues(string(name)).Add(0)
|
|
}
|
|
}
|
|
|
|
func PanicInc(name Panic) {
|
|
metricPanic.WithLabelValues(string(name)).Inc()
|
|
}
|