data

package
v0.0.0-...-65e9c33 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2018 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encrypt_Password

func Encrypt_Password(password string, salt []byte) string

func MimeBodyDecode

func MimeBodyDecode(str string, charset string, encoding string) string

func MimeHeaderDecode

func MimeHeaderDecode(str string) string

Decode strings in Mime header format eg. =?ISO-2022-JP?B?GyRCIVo9dztSOWJAOCVBJWMbKEI=?=

func ParseMIME

func ParseMIME(MIMEBody *MIMEBody, reader io.Reader, boundary string, message *Message) error

func Partbuf

func Partbuf(reader io.Reader) (int64, []byte, error)

func Validate_Password

func Validate_Password(hashed string, input_password string) bool

Types

type Attachment

type Attachment struct {
	Id               string
	Body             string
	FileName         string
	ContentType      string
	Charset          string
	MIMEVersion      string
	TransferEncoding string
	Size             int
}

type Content

type Content struct {
	Headers  map[string][]string
	TextBody string
	HtmlBody string
	Size     int
	Body     string
}

func ContentFromString

func ContentFromString(data string) *Content

type DataStore

type DataStore struct {
	Config         config.DataStoreConfig
	Storage        interface{}
	SaveMailChan   chan *config.SMTPMessage
	NotifyMailChan chan interface{}
}

func NewDataStore

func NewDataStore() *DataStore

DefaultDataStore creates a new DataStore object.

func (*DataStore) CheckGreyHost

func (ds *DataStore) CheckGreyHost(h string) bool

Check if host address is in greylist h -> hostname client ip

func (*DataStore) CheckGreyMail

func (ds *DataStore) CheckGreyMail(t, m, d, h string) bool

Check if email address is in greylist t -> type (from/to) m -> local mailbox d -> domain h -> client IP

func (*DataStore) SaveMail

func (ds *DataStore) SaveMail()

func (*DataStore) SaveSpamIP

func (ds *DataStore) SaveSpamIP(ip string, email string)

func (*DataStore) StorageConnect

func (ds *DataStore) StorageConnect()

func (*DataStore) StorageDisconnect

func (ds *DataStore) StorageDisconnect()

type GreyHost

type GreyHost struct {
	Id        bson.ObjectId `bson:"_id"`
	CreatedBy string
	Hostname  string
	CreatedAt time.Time
	IsActive  bool
}

type GreyMail

type GreyMail struct {
	Id        bson.ObjectId `bson:"_id"`
	CreatedBy string
	Type      string
	Email     string
	Local     string
	Domain    string
	CreatedAt time.Time
	IsActive  bool
}

type LoginForm

type LoginForm struct {
	Username string
	Password string
	Token    string

	Errors map[string]string
}

func (*LoginForm) Validate

func (f *LoginForm) Validate() bool

type MIMEBody

type MIMEBody struct {
	Parts []*MIMEPart
}

type MIMEPart

type MIMEPart struct {
	Headers          map[string][]string
	Body             string
	FileName         string
	ContentType      string
	Charset          string
	MIMEVersion      string
	TransferEncoding string
	Disposition      string
	Size             int
}

type Message

type Message struct {
	Id          string
	Subject     string
	From        *Path
	To          []*Path
	Created     time.Time
	Attachments []*Attachment
	Ip          string
	Content     *Content
	MIME        *MIMEBody
	Starred     bool
	Unread      bool
}

func ParseSMTPMessage

func ParseSMTPMessage(m *config.SMTPMessage, hostname string, mimeParser bool) *Message

TODO support nested MIME content

type Messages

type Messages []Message

type MongoDB

type MongoDB struct {
	Config   config.DataStoreConfig
	Session  *mgo.Session
	Messages *mgo.Collection
	Users    *mgo.Collection
	Hosts    *mgo.Collection
	Emails   *mgo.Collection
	Spamdb   *mgo.Collection
}

func CreateMongoDB

func CreateMongoDB(c config.DataStoreConfig) *MongoDB

func (*MongoDB) Close

func (mongo *MongoDB) Close()

func (*MongoDB) DeleteAll

func (mongo *MongoDB) DeleteAll() error

func (*MongoDB) DeleteOne

func (mongo *MongoDB) DeleteOne(id string) error

func (*MongoDB) IsGreyHost

func (mongo *MongoDB) IsGreyHost(hostname string) (int, error)

func (*MongoDB) IsGreyMail

func (mongo *MongoDB) IsGreyMail(email, t string) (int, error)

func (*MongoDB) List

func (mongo *MongoDB) List(start int, limit int) (*Messages, error)

func (*MongoDB) Load

func (mongo *MongoDB) Load(id string) (*Message, error)

func (*MongoDB) LoadAttachment

func (mongo *MongoDB) LoadAttachment(id string) (*Message, error)

func (*MongoDB) Login

func (mongo *MongoDB) Login(username, password string) (*User, error)

Login validates and returns a user object if they exist in the database.

func (*MongoDB) Store

func (mongo *MongoDB) Store(m *Message) (string, error)

func (*MongoDB) StoreGreyHost

func (mongo *MongoDB) StoreGreyHost(h *GreyHost) (string, error)

func (*MongoDB) StoreGreyMail

func (mongo *MongoDB) StoreGreyMail(m *GreyMail) (string, error)

func (*MongoDB) StoreSpamIp

func (mongo *MongoDB) StoreSpamIp(s SpamIP) (string, error)

func (*MongoDB) Total

func (mongo *MongoDB) Total() (int, error)

type Path

type Path struct {
	Relays  []string
	Mailbox string
	Domain  string
	Params  string
}

func PathFromString

func PathFromString(path string) *Path

db.messages.find({ to:{ $elemMatch: { mailbox:"bob" } } }) db.messages.find( { 'from.mailbox': "alex" } )

type SpamIP

type SpamIP struct {
	Id        bson.ObjectId `bson:"_id"`
	Hostname  string
	IPAddress string
	Type      string
	Email     string
	CreatedAt time.Time
	IsActive  bool
}

type User

type User struct {
	Id            bson.ObjectId `bson:"_id"`
	Firstname     string
	Lastname      string
	Email         string
	Username      string
	Password      string
	Avatar        string
	Website       string
	Location      string
	Tagline       string
	Bio           string
	JoinedAt      time.Time
	IsSuperuser   bool
	IsActive      bool
	ValidateCode  string
	ResetCode     string
	LastLoginTime time.Time
	LastLoginIp   string
	LoginCount    int64
}

func (*User) SetPassword

func (u *User) SetPassword(password string)

SetPassword takes a plaintext password and hashes it with bcrypt and sets the password field to the hash.

Jump to

Keyboard shortcuts

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