notifications

package
v0.0.0-...-0388672 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheLastPasswordSent

type CacheLastPasswordSent struct {
	// contains filtered or unexported fields
}

CacheLastPasswordSent stores information about when we last sent password cracked emails for a specific task

func NewCache

func NewCache(expireAfter time.Duration) *CacheLastPasswordSent

NewCache creates a password notification sent cache

func (*CacheLastPasswordSent) CanSendEmail

func (s *CacheLastPasswordSent) CanSendEmail(taskID string) bool

CanSendEmail returns a boolean indicating if we're able to send an email. If checks to see if the taskid exists in a lookup table which stores the last time an email was sent out for the taskid. If a value exists in the table and it's greater than the expiration, it will be reset to the current time and return true. If the lookup fails, it will set the current time for the task and return true.

func (*CacheLastPasswordSent) Stop

func (s *CacheLastPasswordSent) Stop()

Stop the password cache expiration goroutine

type Config

type Config struct {
	EmailServer struct {
		Address         string  `yaml:"address"`
		Port            int     `yaml:"port"`
		Username        string  `yaml:"username"`
		Password        string  `yaml:"password"`
		SkipInvalidCert bool    `yaml:"skip_invalid_cert"`
		Certifcate      *string `yaml:"certificate"`
		ServerName      *string `yaml:"server_name"`
	} `yaml:"email_server"`
	Enabled       bool   `yaml:"enabled"`
	FromAddress   string `yaml:"from_address"`
	PublicAddress string `yaml:"public_address"`
}

Config describes the available configuration options for the email notification engine

func (*Config) Validate

func (s *Config) Validate() error

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is a context that provides notification capabilities via email

func New

func New(cfg Config, stor storage.Backend) (*Engine, error)

New builds the notification engine

func (*Engine) CrackedPassword

func (s *Engine) CrackedPassword(taskID string) error

CrackedPassword is called whenever a password has been cracked and will send out a notification email if one can be sent.

func (*Engine) Stop

func (s *Engine) Stop()

Stop the notification engine

func (*Engine) TaskStatusChanged

func (s *Engine) TaskStatusChanged(taskID string, newStatus storage.TaskStatus) error

TaskStatusChanged is called whenever a task status has changed

Jump to

Keyboard shortcuts

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