Documentation
¶
Overview ¶
Package msgdb defines an encrypted database used to store messages.
Index ¶
- Constants
- Variables
- func Create(dbname string, passphrase []byte, iter int) error
- func Rekey(dbname string, oldPassphrase, newPassphrase []byte, newIter int) error
- type ContactType
- type MsgDB
- func (msgDB *MsgDB) AddAccount(myID, contactID string, privkey *[ed25519.PrivateKeySize]byte, server string, ...) error
- func (msgDB *MsgDB) AddContact(myID, mappedID, unmappedID, fullName string, contactType ContactType) error
- func (msgDB *MsgDB) AddInQueue(myID, contactID string, date int64, msg string) error
- func (msgDB *MsgDB) AddMessage(selfID, peerID string, date int64, sent bool, message string, sign bool, ...) error
- func (msgDB *MsgDB) AddMessageIDCache(myID, contactID, messageID string) error
- func (msgDB *MsgDB) AddNym(mappedID, unmappedID, fullName string) error
- func (msgDB *MsgDB) AddOutQueue(myID string, msgID int64, encMsg, nymaddress string, minDelay, maxDelay int32) error
- func (msgDB *MsgDB) AddValue(key, value string) error
- func (msgDB *MsgDB) ClearResendOutQueue(myID string) error
- func (msgDB *MsgDB) Close() error
- func (msgDB *MsgDB) DB() *sql.DB
- func (msgDB *MsgDB) DelInQueue(iqIdx int64) error
- func (msgDB *MsgDB) DelMessage(myID string, msgNum int64) error
- func (msgDB *MsgDB) DelNym(mappedID string) error
- func (msgDB *MsgDB) GetAccount(myID, contactID string) (privkey *[ed25519.PrivateKeySize]byte, server string, secret *[64]byte, ...)
- func (msgDB *MsgDB) GetAccountTime(myID, contactID string) (int64, error)
- func (msgDB *MsgDB) GetAccounts(myID string) ([]string, error)
- func (msgDB *MsgDB) GetContact(myID, contactID string) (unmappedID, fullName string, contactType ContactType, err error)
- func (msgDB *MsgDB) GetContacts(myID string, blocked bool) ([]string, error)
- func (msgDB *MsgDB) GetInQueue() (iqIdx int64, myID, contactID, msg string, envelope bool, err error)
- func (msgDB *MsgDB) GetMessage(myID string, msgNum int64) (from, to, msg string, date int64, err error)
- func (msgDB *MsgDB) GetMessageIDCache(myID, contactID string) (map[string]bool, error)
- func (msgDB *MsgDB) GetMsgIDs(myID string) ([]*MsgID, error)
- func (msgDB *MsgDB) GetNym(mappedID string) (unmappedID, fullName string, err error)
- func (msgDB *MsgDB) GetNyms(mapped bool) ([]string, error)
- func (msgDB *MsgDB) GetOutQueue(myID string) (oqIdx int64, msg, nymaddress string, minDelay, maxDelay int32, envelope bool, ...)
- func (msgDB *MsgDB) GetUndeliveredMessage(myID string) (msgNum int64, contactID string, msg []byte, sign bool, ...)
- func (msgDB *MsgDB) GetUpkeepAccounts(myID string) (int64, error)
- func (msgDB *MsgDB) GetUpkeepAll(myID string) (int64, error)
- func (msgDB *MsgDB) GetValue(key string) (string, error)
- func (msgDB *MsgDB) Incremental(pages int64) error
- func (msgDB *MsgDB) ReadMessage(msgNum int64) error
- func (msgDB *MsgDB) RemoveContact(myID, contactID string) error
- func (msgDB *MsgDB) RemoveInQueue(iqIdx int64, plainMsg, fromID string, drop bool) error
- func (msgDB *MsgDB) RemoveMessageIDCache(myID, contactID, messageID string) error
- func (msgDB *MsgDB) RemoveOutQueue(oqIdx, date int64) error
- func (msgDB *MsgDB) RetractOutQueue(oqIdx int64) error
- func (msgDB *MsgDB) SetAccountLastMsg(myID, contactID string, lastMessageTime int64) error
- func (msgDB *MsgDB) SetAccountTime(myID, contactID string, loadTime int64) error
- func (msgDB *MsgDB) SetInQueue(iqIdx int64, msg string) error
- func (msgDB *MsgDB) SetOutQueue(oqIdx int64, envMsg string) error
- func (msgDB *MsgDB) SetResendOutQueue(oqIdx int64) error
- func (msgDB *MsgDB) SetUpkeepAccounts(myID string, t int64) error
- func (msgDB *MsgDB) SetUpkeepAll(myID string, t int64) error
- func (msgDB *MsgDB) Status() (autoVacuum string, freelistCount int64, err error)
- func (msgDB *MsgDB) Vacuum(autoVacuumMode string) error
- func (msgDB *MsgDB) Version() (string, error)
- type MsgID
Constants ¶
const ( DBVersion = "Version" // version string of msgdb WalletKey = "WalletKey" // 64-byte private Ed25519 wallet key, base64 encoded ActiveUID = "ActiveUID" // the active UID )
Entries in KeyValueTable.
const Version = "1"
Version is the current msgdb version.
Variables ¶
var ErrNilMessageID = errors.New("msgdb: messageID nil")
ErrNilMessageID is returned if the messageID argument is nil.
Functions ¶
Types ¶
type ContactType ¶
type ContactType int64
ContactType represents the different types of contacts (white list, gray list, and black list).
const ( // WhiteList represents a white listed contact. WhiteList ContactType = iota // GrayList represents a gray listed contact. GrayList // BlackList represents a black listed contact. BlackList )
type MsgDB ¶
type MsgDB struct {
// contains filtered or unexported fields
}
MsgDB is a handle for an encrypted database to store messsages and tokens.
func (*MsgDB) AddAccount ¶
func (msgDB *MsgDB) AddAccount( myID, contactID string, privkey *[ed25519.PrivateKeySize]byte, server string, secret *[64]byte, minDelay, maxDelay int32, ) error
AddAccount adds an account for myID and contactID (which can be nil) with given privkey on server.
func (*MsgDB) AddContact ¶
func (msgDB *MsgDB) AddContact( myID, mappedID, unmappedID, fullName string, contactType ContactType, ) error
AddContact adds or updates a contact in msgDB.
func (*MsgDB) AddInQueue ¶
AddInQueue adds the given message corressponding to myID and contactID (can be nil) to the inqueue.
func (*MsgDB) AddMessage ¶
func (msgDB *MsgDB) AddMessage( selfID, peerID string, date int64, sent bool, message string, sign bool, minDelay, maxDelay int32, ) error
AddMessage adds message between selfID and peerID to msgDB. If sent is true, it is a sent message. Otherwise a received message.
func (*MsgDB) AddMessageIDCache ¶
AddMessageIDCache adds messageID to the message ID cache for the myID and contactID pair.
func (*MsgDB) AddNym ¶
AddNym adds or updates a mapping from a mapped ID to an unmapped ID and full name.
func (*MsgDB) AddOutQueue ¶
func (msgDB *MsgDB) AddOutQueue( myID string, msgID int64, encMsg, nymaddress string, minDelay, maxDelay int32, ) error
AddOutQueue adds the encrypted message encMsg corresponding to the the plain text message with msgID to the outqueue.
func (*MsgDB) ClearResendOutQueue ¶
ClearResendOutQueue clears the resend status in the outqueue for myID.
func (*MsgDB) DB ¶
DB returns the internal database handle for message database. Usually this method should not be used!
func (*MsgDB) DelInQueue ¶
DelInQueue deletes the entry with index iqIdx from inqueue.
func (*MsgDB) DelMessage ¶
DelMessage deletes the message from user myID with the given msgNum.
func (*MsgDB) GetAccount ¶
func (msgDB *MsgDB) GetAccount( myID, contactID string, ) ( privkey *[ed25519.PrivateKeySize]byte, server string, secret *[64]byte, minDelay, maxDelay int32, lastMessageTime int64, err error, )
GetAccount returns the privkey and server of the account for myID.
func (*MsgDB) GetAccountTime ¶
GetAccountTime returns the account time for the given myID and contactID combination.
func (*MsgDB) GetAccounts ¶
GetAccounts returns a list of contactIDs (including nil) of all accounts that exist for myID.
func (*MsgDB) GetContact ¶
func (msgDB *MsgDB) GetContact(myID, contactID string) ( unmappedID, fullName string, contactType ContactType, err error, )
GetContact retrieves the (possibly blocked) contact contactID for myID.
func (*MsgDB) GetContacts ¶
GetContacts retrieves all the contacts list (or blacklist, if blocked equals true) for the given ownID user ID.
func (*MsgDB) GetInQueue ¶
func (msgDB *MsgDB) GetInQueue() ( iqIdx int64, myID, contactID, msg string, envelope bool, err error, )
GetInQueue returns the first entry in the inqueue.
func (*MsgDB) GetMessage ¶
func (msgDB *MsgDB) GetMessage( myID string, msgNum int64, ) (from, to, msg string, date int64, err error)
GetMessage returns the message from user myID with the given msgNum.
func (*MsgDB) GetMessageIDCache ¶
GetMessageIDCache retursn the message ID cache for the myID and contactID pair.
func (*MsgDB) GetOutQueue ¶
func (msgDB *MsgDB) GetOutQueue(myID string) ( oqIdx int64, msg, nymaddress string, minDelay, maxDelay int32, envelope bool, err error, )
GetOutQueue returns the first entry in the outqueue for myID. Entries which need to be resend are ignored.
func (*MsgDB) GetUndeliveredMessage ¶
func (msgDB *MsgDB) GetUndeliveredMessage(myID string) ( msgNum int64, contactID string, msg []byte, sign bool, minDelay, maxDelay int32, err error, )
GetUndeliveredMessage returns the oldest undelivered message for myID from msgDB.
func (*MsgDB) GetUpkeepAccounts ¶
GetUpkeepAccounts retrieves the last execution time of 'upkeep accounts'.
func (*MsgDB) GetUpkeepAll ¶
GetUpkeepAll retrieves the last execution time of 'upkeep all'.
func (*MsgDB) Incremental ¶
Incremental executes incremental_vacuum to free up to pages many pages. If pages is 0, all pages are freed. If the current auto_vacuum mode is not INCREMENTAL, an error is returned.
func (*MsgDB) ReadMessage ¶
ReadMessage sets the message with the given msgNum as read.
func (*MsgDB) RemoveContact ¶
RemoveContact removes a contact between myID and contactID (normal or blocked) from the msgDB.
func (*MsgDB) RemoveInQueue ¶
RemoveInQueue remove the entry with index iqIdx from inqueue and adds the descrypted message plainMsg to msgDB (if drop is not true).
func (*MsgDB) RemoveMessageIDCache ¶
RemoveMessageIDCache removes all entries from the message ID cache for the myID and contactID pair which are older than messageID.
func (*MsgDB) RemoveOutQueue ¶
RemoveOutQueue remove the message corresponding to oqIdx from the outqueue and sets the send time of the corresponding message to date.
func (*MsgDB) RetractOutQueue ¶
RetractOutQueue retract the message corresponding to oqIdx from the outqueue and sets the corresponding message to 'ToSend' again.
func (*MsgDB) SetAccountLastMsg ¶
SetAccountLastMsg sets the last message time and ID for the given myID and contactID combination (contactID can be nil).
func (*MsgDB) SetAccountTime ¶
SetAccountTime sets the account time for the given myID and contactID combination (contactID can be nil).
func (*MsgDB) SetInQueue ¶
SetInQueue replaces the encrypted message corresponding to iqIdx with the encrypted message msg.
func (*MsgDB) SetOutQueue ¶
SetOutQueue replaces the encrypted message corresponding to oqIdx with the envelope message envMsg.
func (*MsgDB) SetResendOutQueue ¶
SetResendOutQueue sets the message in outqueue with index oqIdx to resend.
func (*MsgDB) SetUpkeepAccounts ¶
SetUpkeepAccounts sets the last execution time of 'upkeep accounts' to t.
func (*MsgDB) SetUpkeepAll ¶
SetUpkeepAll sets the last execution time of 'upkeep all' to t.
type MsgID ¶
type MsgID struct { MsgID int64 // the message ID From string // sender To string // recipient Incoming bool // an incoming message, outgoing otherwise Sent bool // outgoing message has been sent Date int64 Subject string Read bool }
MsgID is the info type that is returned by GetMsgIDs.