Documentation ¶
Index ¶
- Constants
- Variables
- func LoadStateWriter(log *logging.Logger, stateFile string, passphrase []byte) (*StateWriter, *State, error)
- func NewContactExchangeBytes(spoolWriteDescriptor *memspoolClient.SpoolWriteDescriptor, keyExchange []byte) ([]byte, error)
- type Client
- func (c *Client) AddBlob(id string, blob []byte) error
- func (c *Client) CreateRemoteSpool() error
- func (c *Client) DeleteBlob(id string) error
- func (c *Client) GetBlob(id string) ([]byte, error)
- func (c *Client) GetContacts() map[string]*Contact
- func (c *Client) GetSortedConversation(nickname string) Messages
- func (c *Client) NewContact(nickname string, sharedSecret []byte)
- func (c *Client) RemoveContact(nickname string) error
- func (c *Client) RenameContact(oldname, newname string) error
- func (c *Client) SendMessage(nickname string, message []byte) MessageID
- func (c *Client) Shutdown()
- func (c *Client) Start()
- func (c *Client) WipeConversation(nickname string) error
- type Contact
- type KeyExchangeCompletedEvent
- type Message
- type MessageDeliveredEvent
- type MessageID
- type MessageNotSentEvent
- type MessageReceivedEvent
- type MessageSentEvent
- type Messages
- type Queue
- type SentMessageDescriptor
- type State
- type StateWriter
Constants ¶
const ( // MessageExpirationDuration is the duration of time after which messages will be removed. MessageExpirationDuration = 168 * time.Hour // MessageIDLen is the length of our message IDs which are used the keys in a map // to reference individual messages of a conversation. MessageIDLen = 4 // GarbageCollectionInterval is the time interval between garbage collecting // old messages. GarbageCollectionInterval = 120 * time.Minute )
const MaxQueueSize = 20
const ReadInboxLambdaPDivisor = 8
ReadInboxLambdaPDivisor is used to divide our LambdaP parameter to determine our new lambda parameter for our poisson process which is used in selecting time intervals between attempting to retreive messages from our remote Provider.
Variables ¶
var DoubleRatchetPayloadLength = common.SpoolPayloadLength - ratchet.DoubleRatchetOverhead
DoubleRatchetPayloadLength is the length of the payload encrypted by the ratchet.
var ErrQueueEmpty = errors.New("queue is empty")
ErrQueueEmpty is the error issued when the queue is empty.
var ErrQueueFull = errors.New("queue is full")
ErrQueueFull is the error issued when the queue is full.
Functions ¶
func LoadStateWriter ¶
func LoadStateWriter(log *logging.Logger, stateFile string, passphrase []byte) (*StateWriter, *State, error)
LoadStateWriter decrypts the given stateFile and returns the State as well as a new StateWriter.
func NewContactExchangeBytes ¶
func NewContactExchangeBytes(spoolWriteDescriptor *memspoolClient.SpoolWriteDescriptor, keyExchange []byte) ([]byte, error)
NewContactExchangeBytes returns serialized contact exchange information.
Types ¶
type Client ¶
type Client struct { worker.Worker EventSink chan interface{} // contains filtered or unexported fields }
Client is the mixnet client which interacts with other clients and services on the network.
func New ¶
func New(logBackend *log.Backend, mixnetClient *client.Client, stateWorker *StateWriter, state *State) (*Client, error)
New creates a new Client instance given a mixnetClient, stateWorker and state. This constructor is used to load the previously saved state of a Client.
func NewClientAndRemoteSpool ¶
func NewClientAndRemoteSpool(logBackend *log.Backend, mixnetClient *client.Client, stateWorker *StateWriter, user string, linkKey *ecdh.PrivateKey) (*Client, error)
NewClientAndRemoteSpool creates a new Client and creates a new remote spool for collecting messages destined to this Client. The Client is associated with this remote spool and this state is preserved in the encrypted statefile, of course. This constructor of Client is used when creating a new Client as opposed to loading the previously saved state for an existing Client.
func (*Client) AddBlob ¶ added in v0.0.39
AddBlob adds a []byte blob identified by id string to the clients storage
func (*Client) CreateRemoteSpool ¶
CreateRemoteSpool creates a remote spool for collecting messages destined to this Client. This method blocks until the reply from the remote spool service is received or the round trip timeout is reached.
func (*Client) DeleteBlob ¶ added in v0.0.39
DeleteBlob removes the blob identified by id string or error
func (*Client) GetContacts ¶ added in v0.0.3
GetContacts returns the contacts map.
func (*Client) GetSortedConversation ¶ added in v0.0.37
GetSortedConversation returns Messages (a slice of *Message, sorted by Timestamp)
func (*Client) NewContact ¶
NewContact adds a new contact to the Client's state. This starts the PANDA protocol instance for this contact where intermediate states will be preserved in the encrypted statefile such that progress on the PANDA key exchange can be continued at a later time after program shutdown or restart.
func (*Client) RemoveContact ¶
RemoveContact removes a contact from the Client's state.
func (*Client) RenameContact ¶ added in v0.0.39
RenameContact changes the name of a contact.
func (*Client) SendMessage ¶
SendMessage sends a message to the Client contact with the given nickname.
func (*Client) Start ¶
func (c *Client) Start()
Start starts the client worker goroutine and the read-inbox worker goroutine.
func (*Client) WipeConversation ¶ added in v0.0.42
WipeConversation removes all messages between a contact
type Contact ¶
type Contact struct { // Nickname is also unique locally. Nickname string // IsPending is true if the key exchange has not been completed. IsPending bool LastMessage *Message // contains filtered or unexported fields }
Contact is a communications contact that we have bidirectional communication with.
func NewContact ¶
func NewContact(nickname string, id uint64, spoolReadDescriptor *memspoolClient.SpoolReadDescriptor, session *client.Session) (*Contact, error)
NewContact creates a new Contact or returns an error.
func (*Contact) MarshalBinary ¶
MarshalBinary does what you expect and returns a serialized Contact.
func (*Contact) UnmarshalBinary ¶
UnmarshalBinary does what you expect and initializes the given Contact with deserialized Contact fields from the given binary blob.
type KeyExchangeCompletedEvent ¶ added in v0.0.3
type KeyExchangeCompletedEvent struct { // Nickname is the nickname of the contact with whom our key // exchange has been completed. Nickname string // Err is a key exchange error or is set to nil on success. Err error }
KeyExchangeCompletedEvent is an event signaling the completion of a key exchange or failure if Err is non-nil.
type MessageDeliveredEvent ¶ added in v0.0.3
type MessageDeliveredEvent struct { // Nickname is the nickname of the recipient of our delivered message. Nickname string // MessageID is the key in the conversation map referencing a specific message. MessageID MessageID }
MessageDeliveredEvent is an event signaling that the message has been delivered to the remote spool.
type MessageID ¶ added in v0.0.3
type MessageID [MessageIDLen]byte
type MessageNotSentEvent ¶ added in v0.0.18
type MessageNotSentEvent struct { // Nickname is the nickname of the recipient of our delivered message. Nickname string // MessageID is the key in the conversation map referencing a specific message. MessageID MessageID // Err is an error with reason for failure Err error }
MessageNotSentEvent is an event signalling that the message was not sent.
type MessageReceivedEvent ¶ added in v0.0.3
type MessageReceivedEvent struct { // Nickname is the nickname from whom we received a message. Nickname string // Message is the message content which was received. Message []byte // Timestamp is the time the message was received. Timestamp time.Time }
MessageReceivedEvent is the event signaling that a message was received.
type MessageSentEvent ¶ added in v0.0.3
type MessageSentEvent struct { // Nickname is the nickname of the recipient of our delivered message. Nickname string // MessageID is the key in the conversation map referencing a specific message. MessageID MessageID }
MessageSentEvent is an event signaling that the message was sent.
type Messages ¶ added in v0.0.37
type Messages []*Message
type Queue ¶ added in v0.0.18
Queue is our in-memory queue implementation used as our egress FIFO queue for messages sent by the client.
func (*Queue) MarshalBinary ¶ added in v0.0.18
func (*Queue) Peek ¶ added in v0.0.18
Peek returns the next message ref from the queue without modifying the queue.
func (*Queue) Pop ¶ added in v0.0.18
Pop pops the next message ref off the queue and returns nil upon success, otherwise an error is returned.
func (*Queue) Push ¶ added in v0.0.18
Push pushes the given message ref onto the queue and returns nil on success, otherwise an error is returned.
func (*Queue) UnmarshalBinary ¶ added in v0.0.18
type SentMessageDescriptor ¶ added in v0.0.3
type State ¶
type State struct { SpoolReadDescriptor *client.SpoolReadDescriptor Contacts []*Contact User string Provider string LinkKey *ecdh.PrivateKey Conversations map[string]map[MessageID]*Message Blob map[string][]byte }
State is the struct type representing the Client's state which is encrypted and persisted to disk.
type StateWriter ¶
StateWriter takes ownership of the Client's encrypted statefile and has a worker goroutine which writes updates to disk.
func NewStateWriter ¶
func NewStateWriter(log *logging.Logger, stateFile string, passphrase []byte) (*StateWriter, error)
NewStateWriter is a constructor for StateWriter which is to be used when creating the statefile for the first time.
func (*StateWriter) Start ¶
func (w *StateWriter) Start()
Start starts the StateWriter's worker goroutine.