user

package
v0.0.0-...-dee8dd0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2017 License: ISC Imports: 34 Imported by: 0

Documentation

Overview

Package user provides functionality for implementing the IMAP and SMTP servers for bmagent. It allows Bitmessage to act like email. It provides for message folders that are compatible with IMAP and for coverting between the e-mail format and Bitmessage objects.

Index

Constants

View Source
const (
	// InboxFolderName is the default name for the inbox folder.
	// The IMAP protocol requires that a folder named Inbox, case insensitive,
	// exist. So this can't be changed.
	InboxFolderName = "Inbox"

	// OutboxFolderName is the default name for the out folder.
	// Messages in the out folder are waiting for pow to be completed or public
	// key of the recipient so that they can be sent.
	OutboxFolderName = "Outbox"

	// LimboFolderName is the default name for folder containing messages
	// that are out in the network, but have not been received yet (no ack).
	LimboFolderName = "Limbo"

	// SentFolderName is the default name for the sent folder.
	SentFolderName = "Sent"

	// TrashFolderName is the default name for the trash folder.
	TrashFolderName = "Trash"

	// DraftsFolderName is the default name for the drafts folder.
	DraftsFolderName = "Drafts"

	// CommandsFolderName is the default name for the folder containing
	// responses to sent commands.
	CommandsFolderName = "Commands"
)
View Source
const (
	// DefaultBehavior is the default behavior for a new address.
	DefaultBehavior = identity.BehaviorAck
)

Variables

View Source
var (
	// ErrUnrecognizedAck is returned if we have no record of having
	// sent such an ack.
	ErrUnrecognizedAck = errors.New("Unrecognized ack")

	// ErrNoAckExpected is returned if we somehow receive an ack for
	// a message for which none was expected.
	ErrNoAckExpected = errors.New("No ack expected")

	// ErrNoMessageFound is returned when no message is found.
	ErrNoMessageFound = errors.New("No message found")

	// ErrMissingPrivateID is returned when the private id could not be found.
	ErrMissingPrivateID = errors.New("Private id not found")
)
View Source
var Broadcast = identity.Public(&broadcastID{})

Broadcast represents a broadcast message, which doesn't require a public id.

Functions

func Initialize

func Initialize(u data.Folders, k keys.Manager, genkeys uint32) error

Initialize initializes the store by creating the default mailboxes and inserting the welcome message.

func PrivateIDToPublicID

func PrivateIDToPublicID(pi *keys.PrivateID) cmd.PublicID

PrivateIDToPublicID converts a PrivateID as returned from the key magager to a PublicID as expected by the command system.

func SMTPLogHandler

func SMTPLogHandler(message string, args ...interface{})

SMTPLogHandler handles logging for the SMTP protocol.

Types

type BitmessageStore

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

BitmessageStore implements mailstore.Mailstore.

func NewBitmessageStore

func NewBitmessageStore(user *User, cfg *email.IMAPConfig) *BitmessageStore

NewBitmessageStore creates a new bitmessage store.

func (*BitmessageStore) Authenticate

func (s *BitmessageStore) Authenticate(username string, password string) (mailstore.User, error)

Authenticate is part of the mailstore.Mailstore interface. It takes a username and password and returns a mailstore.User if the credentials are valid.

type MessageSequence

type MessageSequence []uint64

MessageSequence represents a sequence of uids contained in this mailbox. It implements sort.Interface.

func (MessageSequence) GetSequenceNumber

func (uids MessageSequence) GetSequenceNumber(uid uint64) uint32

GetSequenceNumber gets the lowest sequence number containing a value higher than or equal to the given uid.

func (MessageSequence) Len

func (uids MessageSequence) Len() int

func (MessageSequence) Less

func (uids MessageSequence) Less(i, j int) bool

func (MessageSequence) Swap

func (uids MessageSequence) Swap(i, j int)

type ObjectExpiration

type ObjectExpiration func(wire.ObjectType) time.Duration

ObjectExpiration returns the time duration after which an object of the given type will expire on the network. It's used for POW calculations.

type SMTPServer

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

SMTPServer provides an SMTP server for handling communications with SMTP clients.

func NewSMTPServer

func NewSMTPServer(cfg *email.SMTPConfig, user *User) *SMTPServer

NewSMTPServer returns a new smtp server.

func (*SMTPServer) Serve

func (serv *SMTPServer) Serve(l net.Listener) error

Serve serves SMTP requests on the given listener.

type ServerOps

type ServerOps interface {
	// GetOrRequestPublicID attempts to retreive a public identity for the given
	// address. If the function returns nil with no error, that means that a
	// pubkey request was successfully queued for proof-of-work.
	GetOrRequestPublicID(string) (identity.Public, error)

	// Send sends a message out into the network.
	Send(obj []byte)
}

ServerOps is used for doing operations best performed by the server and its components. This includes requesting public and private identities from the server and accessing some config options.

type User

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

User implements the mailstore.User interface and represents a collection of imap folders belonging to a single user.

func NewUser

func NewUser(username string, privateIds keys.Manager, expiration ObjectExpiration,
	folders data.Folders, pm *powmgr.Pow, server ServerOps) (*User, error)

NewUser creates a User object from the store.

func (*User) DeliverAckReply

func (u *User) DeliverAckReply(hash *hash.Sha) error

DeliverAckReply takes a message ack and marks a message as having been received by the recipient.

func (*User) DeliverFromBMNet

func (u *User) DeliverFromBMNet(bm *email.Bmail) error

DeliverFromBMNet adds a message received from bmd into the appropriate folder.

func (*User) DeliverFromSMTP

func (u *User) DeliverFromSMTP(smtp *smtp.Content) error

DeliverFromSMTP adds a message received via SMTP to the POW queue, if needed, and the outbox.

func (*User) DeliverPublic

func (u *User) DeliverPublic(bmaddr string, public identity.Public) error

DeliverPublic takes a public key and attempts to match it with a message. If a matching message is found, the message is encoded to the wire format and sent to the pow queue.

func (*User) ListAddresses

func (u *User) ListAddresses() []cmd.PublicID

ListAddresses lists all available addresses.

func (*User) MailboxByName

func (u *User) MailboxByName(name string) (mailstore.Mailbox, error)

MailboxByName returns a mailbox by its name. It is part of the IMAPMailbox interface.

func (*User) Mailboxes

func (u *User) Mailboxes() []mailstore.Mailbox

Mailboxes returns all the mailboxes. It is part of the IMAPMailbox interface.

func (*User) Move

func (u *User) Move(bmsg *email.Bmail, from, to string) error

Move finds a email.Bmail in one mailbox and moves it to another.

func (*User) NewAddress

func (u *User) NewAddress(tag string, sendAck bool) cmd.PublicID

NewAddress creates n new keys for the user.

func (*User) NewMailbox

func (u *User) NewMailbox(name string) (email.Mailbox, error)

NewMailbox adds a new mailbox.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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