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
- Variables
- func Initialize(u data.Folders, k keys.Manager, genkeys uint32) error
- func PrivateIDToPublicID(pi *keys.PrivateID) cmd.PublicID
- func SMTPLogHandler(message string, args ...interface{})
- type BitmessageStore
- type MessageSequence
- type ObjectExpiration
- type SMTPServer
- type ServerOps
- type User
- func (u *User) DeliverAckReply(hash *hash.Sha) error
- func (u *User) DeliverFromBMNet(bm *email.Bmail) error
- func (u *User) DeliverFromSMTP(smtp *smtp.Content) error
- func (u *User) DeliverPublic(bmaddr string, public identity.Public) error
- func (u *User) ListAddresses() []cmd.PublicID
- func (u *User) MailboxByName(name string) (mailstore.Mailbox, error)
- func (u *User) Mailboxes() []mailstore.Mailbox
- func (u *User) Move(bmsg *email.Bmail, from, to string) error
- func (u *User) NewAddress(tag string, sendAck bool) cmd.PublicID
- func (u *User) NewMailbox(name string) (email.Mailbox, error)
Constants ¶
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" )
const ( // DefaultBehavior is the default behavior for a new address. DefaultBehavior = identity.BehaviorAck )
Variables ¶
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") )
var Broadcast = identity.Public(&broadcastID{})
Broadcast represents a broadcast message, which doesn't require a public id.
Functions ¶
func Initialize ¶
Initialize initializes the store by creating the default mailboxes and inserting the welcome message.
func PrivateIDToPublicID ¶
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 ¶
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.
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 ¶
DeliverAckReply takes a message ack and marks a message as having been received by the recipient.
func (*User) DeliverFromBMNet ¶
DeliverFromBMNet adds a message received from bmd into the appropriate folder.
func (*User) DeliverFromSMTP ¶
DeliverFromSMTP adds a message received via SMTP to the POW queue, if needed, and the outbox.
func (*User) DeliverPublic ¶
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 ¶
ListAddresses lists all available addresses.
func (*User) MailboxByName ¶
MailboxByName returns a mailbox by its name. It is part of the IMAPMailbox interface.
func (*User) Mailboxes ¶
Mailboxes returns all the mailboxes. It is part of the IMAPMailbox interface.
func (*User) NewAddress ¶
NewAddress creates n new keys for the user.