1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-08-15 20:13:16 +02:00

Feature: Add option to only allow SMTP recipients matching a regular expression (disable open-relay behaviour #219)

This commit is contained in:
Ralph Slooten
2024-01-03 12:06:36 +13:00
parent aad15945b3
commit cdab59b295
6 changed files with 80 additions and 40 deletions

View File

@@ -21,9 +21,9 @@ var (
mu sync.RWMutex
smtpReceived int
smtpReceivedSize int
smtpErrors int
smtpAccepted int
smtpAcceptedSize int
smtpRejected int
smtpIgnored int
)
@@ -52,13 +52,13 @@ type AppInformation struct {
Memory uint64
// Messages deleted
MessagesDeleted int
// SMTP messages received via since run
SMTPReceived int
// Total size in bytes of received messages since run
SMTPReceivedSize int
// SMTP errors since run
SMTPErrors int
// SMTP messages ignored since run (duplicate IDs)
// SMTP accepted messages since run
SMTPAccepted int
// Total size in bytes of accepted messages since run
SMTPAcceptedSize int
// SMTP rejected messages since run
SMTPRejected int
// SMTP ignored messages since run (duplicate IDs)
SMTPIgnored int
}
}
@@ -75,9 +75,9 @@ func Load() AppInformation {
info.RuntimeStats.Uptime = int(time.Since(startedAt).Seconds())
info.RuntimeStats.MessagesDeleted = storage.StatsDeleted
info.RuntimeStats.SMTPReceived = smtpReceived
info.RuntimeStats.SMTPReceivedSize = smtpReceivedSize
info.RuntimeStats.SMTPErrors = smtpErrors
info.RuntimeStats.SMTPAccepted = smtpAccepted
info.RuntimeStats.SMTPAcceptedSize = smtpAcceptedSize
info.RuntimeStats.SMTPRejected = smtpRejected
info.RuntimeStats.SMTPIgnored = smtpIgnored
if latestVersionCache != "" {
@@ -116,18 +116,18 @@ func Track() {
startedAt = time.Now()
}
// LogSMTPReceived logs a successfully SMTP transaction
func LogSMTPReceived(size int) {
// LogSMTPAccepted logs a successful SMTP transaction
func LogSMTPAccepted(size int) {
mu.Lock()
smtpReceived = smtpReceived + 1
smtpReceivedSize = smtpReceivedSize + size
smtpAccepted = smtpAccepted + 1
smtpAcceptedSize = smtpAcceptedSize + size
mu.Unlock()
}
// LogSMTPError logs a failed SMTP transaction
func LogSMTPError() {
// LogSMTPRejected logs a rejected SMTP transaction
func LogSMTPRejected() {
mu.Lock()
smtpErrors = smtpErrors + 1
smtpRejected = smtpRejected + 1
mu.Unlock()
}