db

package
v0.0.0-...-6b39e2e Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSender is the sender part of the email address used to send messages
	DefaultSender = "no-reply"

	// DefaultSenderName is the name part of the email address used to send
	// messages
	DefaultSenderName = "Gophish Healthcheck"

	// DefaultSubject is the default subject used when sending messages
	DefaultSubject = "Gophish Healthcheck - Test Email"

	// DefaultSMTPPort is the default SMTP port used when making outbound SMTP
	// connections
	DefaultSMTPPort = 25

	// MessageIDLength is the number of bytes to use when generated message IDs
	MessageIDLength = 16

	// HardFail is the constant value used to indicate the specific configuration
	// should fail
	HardFail = "hardfail"
	// None is the constant value used to indicate the specific configuration
	// should not be present (e.g. no DKIM signing at all)
	None = "none"
	// SoftFail is the constant value that indicates the certain configuration
	// option (if supported) should softfail (e.g. spf softfail).
	SoftFail = "softfail"
	// Pass is the constant value used to indicate the specific configuration
	// value should be valid
	Pass = "pass"
	// Reject indicates that the DMARC response should have the policy set to
	// reject
	Reject = "reject"
	// Quarantine indicates that the DMARC response should have the policy set
	// to quarantine
	Quarantine = "quarantine"
	// Neutral indicates that the SPF response should have a neutral enforcement
	Neutral = "neutral"
)

Variables

View Source
var ErrMissingMailServer = errors.New("no mail server specified")

ErrMissingMailServer occurs when a message is received without specifying a valid mail server.

View Source
var ErrMissingRecipient = errors.New("no recipient specified")

ErrMissingRecipient occurs when a message is received without specifying a valid recipient

Functions

func PostMessage

func PostMessage(m *Message) error

PostMessage saves a message instance into the database

func Setup

func Setup() error

Types

type Dialer

type Dialer struct {
	*gomail.Dialer
}

Dialer is a wrapper around a standard gomail.Dialer in order to implement the mailer.Dialer interface. This allows us to better separate the mailer package as opposed to forcing a connection between mailer and gomail.

func (*Dialer) Dial

func (d *Dialer) Dial() (mailer.Sender, error)

Dial wraps the gomail dialer's Dial command

type Message

type Message struct {
	ID           uint         `gorm:"primary_key" json:"id"`
	CreatedAt    time.Time    `json:"created_at"`
	UpdatedAt    time.Time    `json:"updated_at"`
	DeletedAt    *time.Time   `json:"deleted_at,omitempty"`
	Recipient    string       `gorm:"-" json:"recipient"`
	MailServer   string       `json:"mail_server"`
	MessageID    string       `json:"message_id"`
	DomainHash   string       `json:"domain_hash"`
	Successful   bool         `json:"successful"`
	ErrorMessage string       `json:"error_message"`
	ErrorChan    chan (error) `gorm:"-" json:"-"`

	MessageConfiguration `gorm:"embedded" json:"configuration"`
}

Message is the base struct for handling per-message information.

func GetMessage

func GetMessage(id string) (*Message, error)

GetMessage retrieves a message by ID from the database

func (*Message) Backoff

func (m *Message) Backoff(reason error) error

Backoff simply errors out the message, since we don't handle exponential backoffs yet.

func (*Message) Error

func (m *Message) Error(err error) error

Error errors out the message.

func (*Message) Generate

func (m *Message) Generate(msg *gomail.Message) error

Generate creates a gomail.Message instance from the provided message.

func (*Message) GetDialer

func (m *Message) GetDialer() (mailer.Dialer, error)

GetDialer creates a mailer.Dialer from the message configuration.

func (*Message) Success

func (m *Message) Success() error

Success saves the message as having been sent successfully.

func (*Message) Validate

func (m *Message) Validate() error

Validate ensures the message is correctly formatted with all the necessary fields.

type MessageConfiguration

type MessageConfiguration struct {
	SPF   string `json:"spf"`
	DKIM  string `json:"dkim"`
	DMARC string `json:"dmarc"`
	MX    string `json:"mx"`
}

MessageConfiguration is the configuration for the outbound message.

Jump to

Keyboard shortcuts

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