mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 16:33:47 +03:00
e24e1bee19
for reporting addresses that cause DSNs to be returned. that just adds noise. the admin can add/remove/extend addresses through the webadmin. in the future, we could send reports with a smtp mail from of "postmaster+<signed-encoded-recipient>@...", and add the reporting recipient on the suppression list automatically when a DSN comes in on that address, but for now this will probably do.
50 lines
925 B
Go
50 lines
925 B
Go
package tlsrptdb
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/mjl-/bstore"
|
|
|
|
"github.com/mjl-/mox/mlog"
|
|
"github.com/mjl-/mox/mox-"
|
|
)
|
|
|
|
var (
|
|
xlog = mlog.New("tlsrptdb")
|
|
|
|
ReportDBTypes = []any{TLSReportRecord{}}
|
|
ReportDB *bstore.DB
|
|
mutex sync.Mutex
|
|
|
|
// Accessed directly by tlsrptsend.
|
|
ResultDBTypes = []any{TLSResult{}, TLSRPTSuppressAddress{}}
|
|
ResultDB *bstore.DB
|
|
)
|
|
|
|
// Init opens and possibly initializes the databases.
|
|
func Init() error {
|
|
if _, err := reportDB(mox.Shutdown); err != nil {
|
|
return err
|
|
}
|
|
if _, err := resultDB(mox.Shutdown); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Close closes the database connections.
|
|
func Close() {
|
|
if ResultDB != nil {
|
|
err := ResultDB.Close()
|
|
xlog.Check(err, "closing result database")
|
|
ResultDB = nil
|
|
}
|
|
|
|
mutex.Lock()
|
|
defer mutex.Unlock()
|
|
if ReportDB != nil {
|
|
err := ReportDB.Close()
|
|
xlog.Check(err, "closing report database")
|
|
ReportDB = nil
|
|
}
|
|
}
|