rawparser

package
Version: v0.0.0-...-dcd00bf Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: AGPL-3.0, AGPL-3.0 Imports: 3 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      []byte
	ChildQueue []byte
}

type CleanupMessageAccepted

type CleanupMessageAccepted struct {
	Queue     []byte
	MessageId []byte
	Corrupted bool
}

type CleanupMilterReject

type CleanupMilterReject struct {
	Queue        []byte
	ExtraMessage []byte
}

type PayloadType

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

	// types for SmtpMessageStatus extra message
	PayloadTypeSmtpMessageStatusSentQueued
)

type Pickup

type Pickup struct {
	Queue  []byte
	Uid    []byte
	Sender []byte
}

type QmgrMailQueued

type QmgrMailQueued struct {
	Queue            []byte
	SenderLocalPart  []byte
	SenderDomainPart []byte
	Size             []byte
	Nrcpt            []byte
}

type QmgrMessageExpired

type QmgrMessageExpired struct {
	Queue            []byte
	SenderLocalPart  []byte
	SenderDomainPart []byte
	Message          []byte
}

type QmgrRemoved

type QmgrRemoved struct {
	Queue []byte
}

type RawHeader

type RawHeader struct {
	Time      timeutil.RawTime
	Host      []byte
	Process   []byte
	Daemon    []byte
	ProcessIP []byte
	ProcessID []byte
}

func ParseHeader

func ParseHeader(logLine []byte) (RawHeader, []byte, error)

func ParseHeaderWithCustomTimeFormat

func ParseHeaderWithCustomTimeFormat(logLine []byte, format TimeFormat) (RawHeader, []byte, 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
}

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 []byte, daemon, process string) (RawPayload, error)

type RawSmtpSentStatus

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

	// parsed extra message
	ExtraMessagePayloadType              PayloadType
	ExtraMessageSmtpSentStatusSentQueued SmtpSentStatusExtraMessageSentQueued
}

type SmtpSentStatusExtraMessageSentQueued

type SmtpSentStatusExtraMessageSentQueued struct {
	SmtpCode []byte
	Dsn      []byte
	IP       []byte
	Port     []byte
	Queue    []byte
}

type SmtpdConnect

type SmtpdConnect struct {
	Host []byte
	IP   []byte
}

type SmtpdDisconnect

type SmtpdDisconnect struct {
	Host []byte
	IP   []byte
}

type SmtpdMailAccepted

type SmtpdMailAccepted struct {
	Host  []byte
	IP    []byte
	Queue []byte
}

type SmtpdReject

type SmtpdReject struct {
	Queue        []byte
	ExtraMessage []byte
}

type TimeFormat

type TimeFormat = timeutil.TimeFormat

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL