parser

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: 6 Imported by: 0

README

Postfix Log Parser Go Library

This is an eternal work in progress Postfix Log Parser used by Lightmeter Control Center.

It's very imcomplete as it for now parses only the log types that we use on Lightmeter.

If you have interest on improving it, please send us a PR and check the Lightmeter Contributor agreement in the file CLA.

Building

You'll need ragel version 6.10 or newer to generate code from some state machines with go generate.

Then run:

$ go generate ./rawparser

License

For licencing information, please check the file LICENSE.

Lightmeter Team https://lightmeter.io

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidHeaderLine  = rawparser.ErrInvalidHeaderLine
	ErrUnsupportedLogLine = rawparser.ErrUnsupportedLogLine
)
View Source
var ErrInvalidStatus = errors.New(`Invalid Status`)

Functions

func Fuzz

func Fuzz(data []byte) int

func IsRecoverableError

func IsRecoverableError(err error) bool

func Parse

func Parse(line string) (Header, Payload, error)

func ParseWithCustomTimeFormat

func ParseWithCustomTimeFormat(line string, format rawparser.TimeFormat) (Header, Payload, error)

Types

type BounceCreated

type BounceCreated struct {
	Queue      string
	ChildQueue string
}

type CleanupMessageAccepted

type CleanupMessageAccepted struct {
	Queue     string
	Corrupted bool
	MessageId string
}

type CleanupMilterReject

type CleanupMilterReject struct {
	Queue        string
	ExtraMessage string
}

type Delays

type Delays struct {
	Smtpd   float32
	Cleanup float32
	Qmgr    float32
	Smtp    float32
}

type DovecotAuthFailed

type DovecotAuthFailed struct {
	DB                string
	Username          string
	IP                net.IP
	Reason            DovecotAuthFailedReason
	ReasonExplanation string
}

type DovecotAuthFailedReason

type DovecotAuthFailedReason int
const (
	// TODO: Should we use iota for those values?
	// If we do not store them in a database, iota works just well
	UnsupportedDovecotAuthFailedReason       DovecotAuthFailedReason = 0
	DovecotAuthFailedReasonPasswordMismatch  DovecotAuthFailedReason = 1
	DovecotAuthFailedReasonUnknownUser       DovecotAuthFailedReason = 2
	DovecotAuthFailedReasonAuthPolicyRefusal DovecotAuthFailedReason = 3
)

func (DovecotAuthFailedReason) String

func (r DovecotAuthFailedReason) String() string
type Header struct {
	Time      Time
	Host      string
	Process   string
	Daemon    string
	PID       int
	ProcessIP net.IP
}

func ParseHeader

func ParseHeader(line string) (h Header, payloadOffset int, err error)

func ParseHeaderWithCustomTimeFormat

func ParseHeaderWithCustomTimeFormat(line string, format rawparser.TimeFormat) (h Header, payloadOffset int, err error)

type LightmeterDumpedHeader

type LightmeterDumpedHeader rawparser.LightmeterDumpedHeader

type LightmeterRelayedBounce

type LightmeterRelayedBounce rawparser.LightmeterRelayedBounce

type Payload

type Payload interface {
	// contains filtered or unexported methods
}

func ParsePayload

func ParsePayload(h Header, payloadLine string) (Payload, error)

type Pickup

type Pickup struct {
	Queue  string
	Uid    int
	Sender string
}

type QmgrMailQueued

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

type QmgrMessageExpired

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

type QmgrRemoved

type QmgrRemoved struct {
	Queue string
}

type SmtpSentStatus

type SmtpSentStatus struct {
	Queue                   string
	RecipientLocalPart      string
	RecipientDomainPart     string
	OrigRecipientLocalPart  string
	OrigRecipientDomainPart string
	RelayName               string
	RelayPath               string
	RelayIP                 net.IP
	RelayPort               uint16
	Delay                   float32
	Delays                  Delays
	Dsn                     string
	Status                  SmtpStatus
	ExtraMessage            string
	ExtraMessagePayload     Payload
}

type SmtpSentStatusExtraMessageNewUUID

type SmtpSentStatusExtraMessageNewUUID struct {
	ID string
}

type SmtpSentStatusExtraMessageSentQueued

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

type SmtpStatus

type SmtpStatus int
const (
	SentStatus     SmtpStatus = 0
	BouncedStatus  SmtpStatus = 1
	DeferredStatus SmtpStatus = 2
	ExpiredStatus  SmtpStatus = 3
	ReturnedStatus SmtpStatus = 4

	ReceivedStatus SmtpStatus = 42 // not an actual status; used in Message Detective
	RepliedStatus  SmtpStatus = 43 // not an actual status; used in Message Detective
)

func ParseStatus

func ParseStatus(s string) (SmtpStatus, error)

func (SmtpStatus) String

func (s SmtpStatus) String() string

type SmtpdConnect

type SmtpdConnect struct {
	Host string
	IP   net.IP
}

type SmtpdDisconnect

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

type SmtpdDisconnectStat

type SmtpdDisconnectStat = rawparser.SmtpdDisconnectStat

type SmtpdMailAccepted

type SmtpdMailAccepted struct {
	Queue string
	Host  string
	IP    net.IP
}

type SmtpdReject

type SmtpdReject struct {
	Queue        string
	ExtraMessage string
}

type Time

type Time = timeutil.Time

type Version

type Version string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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