rawparser

package
v0.0.0-...-4be01c1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: AGPL-3.0, AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHeaderLine  = errors.New("Could not parse header")
	ErrUnsupportedLogLine = errors.New("Unsupported payload")
)

Functions

This section is empty.

Types

type BounceCreated

type BounceCreated struct {
	Queue      string
	ChildQueue string
}

type CleanupMessageAccepted

type CleanupMessageAccepted struct {
	Queue     string
	MessageId string
	Corrupted bool
}

type CleanupMilterReject

type CleanupMilterReject struct {
	Queue        string
	ExtraMessage string
}

type DovecotAuthFailedWithReason

type DovecotAuthFailedWithReason struct {
	DB       string
	Username string
	IP       string

	// Different reasons
	DovecotAuthFailedReasonPasswordMismatch  string
	DovecotAuthFailedReasonUnknownUser       string
	DovecotAuthFailedReasonAuthPolicyRefusal string

	ReasonExplanation string
}

type LightmeterDumpedHeader

type LightmeterDumpedHeader struct {
	Key    string
	Value  string
	Queue  string
	Values []string
}

type LightmeterRelayedBounce

type LightmeterRelayedBounce struct {
	Queue           string `json:"queue"`
	Sender          string `json:"sender"`
	Recipient       string `json:"recipient"`
	DeliveryCode    string `json:"delivery_code"`
	DeliveryMessage string `json:"delivery_message"`
	ReportingMTA    string `json:"reporting_mta"`
}

type PayloadType

type PayloadType int
const (
	PayloadTypeUnsupported PayloadType = iota
	PayloadTypeQmgrMessageExpired
	PayloadTypeQmgrMailQueued
	PayloadTypeQmgrRemoved
	PayloadTypeSmtpMessageStatus
	PayloadTypeSmtpdConnect
	PayloadTypeSmtpdDisconnect
	PayloadTypeSmtpdMailAccepted
	PayloadTypeSmtpdReject
	PayloadTypeCleanupMessageAccepted
	PayloadTypeBounceCreated
	PayloadTypePickup
	PayloadTypeCleanupMilterReject
	PayloadTypeVersion
	PayloadTypeDovecotAuthFailedWithReason
	PayloadTypeLightmeterDumpedHeader
	PayloadTypeLightmeterRelayedBounce

	// types for SmtpMessageStatus extra message
	PayloadTypeSmtpMessageStatusSentQueued
	PayloadSmtpSentStatusExtraMessageNewUUID
)

type Pickup

type Pickup struct {
	Queue  string
	Uid    string
	Sender string
}

type QmgrMailQueued

type QmgrMailQueued struct {
	Queue            string
	SenderLocalPart  string
	SenderDomainPart string
	Size             string
	Nrcpt            string
}

type QmgrMessageExpired

type QmgrMessageExpired struct {
	Queue            string
	SenderLocalPart  string
	SenderDomainPart string
	Message          string
}

type QmgrRemoved

type QmgrRemoved struct {
	Queue string
}

type RawHeader

type RawHeader struct {
	Time      timeutil.RawTime
	Host      string
	Process   string
	Daemon    string
	ProcessIP string
	ProcessID string
}

func ParseHeader

func ParseHeader(logLine string) (RawHeader, int, error)

func ParseHeaderWithCustomTimeFormat

func ParseHeaderWithCustomTimeFormat(logLine string, format TimeFormat) (RawHeader, int, error)

type RawPayload

type RawPayload struct {
	PayloadType                 PayloadType
	RawSmtpSentStatus           RawSmtpSentStatus
	QmgrMessageExpired          QmgrMessageExpired
	QmgrMailQueued              QmgrMailQueued
	QmgrRemoved                 QmgrRemoved
	SmtpdConnect                SmtpdConnect
	SmtpdDisconnect             SmtpdDisconnect
	SmtpdMailAccepted           SmtpdMailAccepted
	SmtpdReject                 SmtpdReject
	CleanupMesageAccepted       CleanupMessageAccepted
	CleanupMilterReject         CleanupMilterReject
	BounceCreated               BounceCreated
	Pickup                      Pickup
	Version                     Version
	DovecotAuthFailedWithReason DovecotAuthFailedWithReason
	LightmeterDumpedHeader      LightmeterDumpedHeader
	LightmeterRelayedBounce     LightmeterRelayedBounce
}

NOTE: Go does not have unions, and using interfaces implies on virtual calls (which are being done in the higher level parsing interface, anyways), so we add all the possible payloads inlined in the struct, with a field describing which payload the whole record refers to. This is ok as all payloads here store basically byte slices only, which are trivially constructible and copyable so, although this struct will grow as newer payloads are supported, copying will perform better than using virtual calls

func ParsePayload

func ParsePayload(payloadLine string, daemon, process string) (RawPayload, error)

type RawSmtpSentStatus

type RawSmtpSentStatus struct {
	Queue                   string
	RecipientLocalPart      string
	RecipientDomainPart     string
	OrigRecipientLocalPart  string
	OrigRecipientDomainPart string
	RelayName               string
	RelayIpOrPath           string
	RelayPort               string
	Delay                   string
	Delays                  [5]string
	Dsn                     string
	Status                  string
	ExtraMessage            string

	// parsed extra message
	ExtraMessagePayloadType                       PayloadType
	ExtraMessageSmtpSentStatusSentQueued          SmtpSentStatusExtraMessageSentQueued
	ExtraMessageSmtpSentStatusExtraMessageNewUUID SmtpSentStatusExtraMessageNewUUID
}

type SmtpSentStatusExtraMessageNewUUID

type SmtpSentStatusExtraMessageNewUUID struct {
	ID string
}

type SmtpSentStatusExtraMessageSentQueued

type SmtpSentStatusExtraMessageSentQueued struct {
	SmtpCode    string
	Dsn         string
	IP          string
	Port        string
	Queue       string
	InternalMTA bool
}

type SmtpdConnect

type SmtpdConnect struct {
	Host string
	IP   string
}

type SmtpdDisconnect

type SmtpdDisconnect struct {
	Host  string
	IP    string
	Stats map[string]SmtpdDisconnectStat
}

type SmtpdDisconnectStat

type SmtpdDisconnectStat struct {
	Success int
	Total   int
}

type SmtpdMailAccepted

type SmtpdMailAccepted struct {
	Host  string
	IP    string
	Queue string
}

type SmtpdReject

type SmtpdReject struct {
	Queue        string
	ExtraMessage string
}

type TimeFormat

type TimeFormat = timeutil.TimeFormat

type Version

type Version string

Jump to

Keyboard shortcuts

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