Documentation
¶
Index ¶
- Constants
- type ConnectionStatusEvent
- type Event
- type MessageIDGarbageCollected
- type MessageReplyEvent
- type MessageSentEvent
- type NewDocumentEvent
- type NewPKIDocumentEvent
- type Request
- type Response
- type ShutdownEvent
- type ThinClient
- func (t *ThinClient) BlockingSendMessage(ctx context.Context, payload []byte, destNode *[32]byte, destQueue []byte) ([]byte, error)
- func (t *ThinClient) BlockingSendReliableMessage(ctx context.Context, messageID *[MessageIDLength]byte, payload []byte, ...) (reply []byte, err error)
- func (t *ThinClient) Close() error
- func (t *ThinClient) Dial() error
- func (t *ThinClient) EventSink() chan Event
- func (t *ThinClient) GetConfig() *config.Config
- func (t *ThinClient) GetLogger(prefix string) *logging.Logger
- func (t *ThinClient) GetService(serviceName string) (*common.ServiceDescriptor, error)
- func (t *ThinClient) GetServices(capability string) ([]*common.ServiceDescriptor, error)
- func (t *ThinClient) NewMessageID() *[MessageIDLength]byte
- func (t *ThinClient) NewSURBID() *[sConstants.SURBIDLength]byte
- func (t *ThinClient) PKIDocument() *cpki.Document
- func (t *ThinClient) SendMessage(surbID *[sConstants.SURBIDLength]byte, payload []byte, destNode *[32]byte, ...) error
- func (t *ThinClient) SendMessageWithoutReply(payload []byte, destNode *[32]byte, destQueue []byte) error
- func (t *ThinClient) SendReliableMessage(messageID *[MessageIDLength]byte, payload []byte, destNode *[32]byte, ...) error
- func (t *ThinClient) Shutdown()
- type ThinResponse
Constants ¶
const MessageIDLength = 16
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionStatusEvent ¶
type ConnectionStatusEvent struct {
// IsConnected is true iff the client is connected to the entry node.
IsConnected bool `cbor:"is_connected"`
// Err is the error encountered when connecting or by the connection if any.
Err error `cbor:"err"`
}
ConnectionStatusEvent is the event sent when an account's connection status changes.
func (*ConnectionStatusEvent) String ¶
func (e *ConnectionStatusEvent) String() string
String returns a string representation of the ConnectionStatusEvent.
type Event ¶
type Event interface {
// String returns a string representation of the Event.
String() string
}
Event is the generic event sent over the event listener channel.
type MessageIDGarbageCollected ¶
type MessageIDGarbageCollected struct {
// MessageID is the local unique identifier for the message.
MessageID *[MessageIDLength]byte `cbor:"message_id"`
}
MessageIDGarbageCollected is the event used to signal when a given message ID has been garbage collected.
func (*MessageIDGarbageCollected) String ¶
func (e *MessageIDGarbageCollected) String() string
String returns a string representation of a MessageIDGarbageCollected.
type MessageReplyEvent ¶
type MessageReplyEvent struct {
// MessageID is the unique identifier for the request associated with the
// reply.
MessageID *[MessageIDLength]byte `cbor:"message_id"`
// SURBID must be a unique identity for each request.
// This field should be nil if WithSURB is false.
SURBID *[sConstants.SURBIDLength]byte `cbor:"surbid"`
// Payload is the reply payload if any.
Payload []byte `cbor:"payload"`
// Err is the error encountered when servicing the request if any.
Err error `cbor:"err"`
}
MessageReplyEvent is the event sent when a new message is received.
func (*MessageReplyEvent) String ¶
func (e *MessageReplyEvent) String() string
String returns a string representation of the MessageReplyEvent.
type MessageSentEvent ¶
type MessageSentEvent struct {
// MessageID is the local unique identifier for the message, generated
// when the message was enqueued.
MessageID *[MessageIDLength]byte `cbor:"message_id"`
// SURBID must be a unique identity for each request.
// This field should be nil if WithSURB is false.
SURBID *[sConstants.SURBIDLength]byte `cbor:"surbid"`
// SentAt contains the time the message was sent.
SentAt time.Time `cbor:"sent_at"`
// ReplyETA is the expected round trip time to receive a response.
ReplyETA time.Duration `cbor:"reply_eta"`
// Err is the error encountered when sending the message if any.
Err error `cbor:"err"`
}
MessageSentEvent is the event sent when a message has been fully transmitted.
func (*MessageSentEvent) String ¶
func (e *MessageSentEvent) String() string
String returns a string representation of a MessageSentEvent.
type NewDocumentEvent ¶
NewDocumentEvent is the new document event, signaling that we have received a new document from the PKI.
func (*NewDocumentEvent) String ¶
func (e *NewDocumentEvent) String() string
String returns a string representation of a NewDocumentEvent.
type NewPKIDocumentEvent ¶
type NewPKIDocumentEvent struct {
Payload []byte `cbor:"payload"`
}
NewPKIDocumentEvent is the unix domain socket protocol message used by the daemon to tell the thin client about new PKI document events. The payload field contains a CBOR encoded PKI document, stripped of signatures.
func (*NewPKIDocumentEvent) String ¶
func (e *NewPKIDocumentEvent) String() string
String returns a string representation of a NewDocumentEvent.
type Request ¶
type Request struct {
// ID is the unique identifier with respect to the Payload.
// This is only used by the ARQ.
ID *[MessageIDLength]byte `cbor:"id"`
// WithSURB indicates if the message should be sent with a SURB
// in the Sphinx payload.
WithSURB bool `cbor:"with_surb"`
// SURBID must be a unique identity for each request.
// This field should be nil if WithSURB is false.
SURBID *[sConstants.SURBIDLength]byte `cbor:"surbid"`
// DestinationIdHash is 32 byte hash of the destination Provider's
// identity public key.
DestinationIdHash *[32]byte `cbor:"destination_id_hash"`
// RecipientQueueID is the queue identity which will receive the message.
RecipientQueueID []byte `cbor:"recipient_queue_id"`
// Payload is the actual Sphinx packet.
Payload []byte `cbor:"payload"`
// IsSendOp is set to true if the intent is to send a message through
// the mix network.
IsSendOp bool `cbor:"is_send_op"`
// IsARQSendOp is set to true if the intent is to send a message through
// the mix network using the naive ARQ error correction scheme.
IsARQSendOp bool `cbor:"is_arq_send_op"`
// IsLoopDecoy is set to true to indicate that this message shall
// be a loop decoy message.
IsLoopDecoy bool `cbor:"is_loop_decoy"`
// IsDropDecoy is set to true to indicate that this message shall
// be a drop decoy message.
IsDropDecoy bool `cbor:"is_drop_decoy"`
// IsThinClose is set to true to indicate that the thin client
// is disconnecting from the daemon.
IsThinClose bool `cbor:"is_thin_close"`
}
type Response ¶
type Response struct {
ShutdownEvent *ShutdownEvent `cbor:"shudown_event"`
ConnectionStatusEvent *ConnectionStatusEvent `cbor:"connection_status_event"`
NewPKIDocumentEvent *NewPKIDocumentEvent `cbor:"new_pki_document_event"`
MessageSentEvent *MessageSentEvent `cbor:"message_sent_event"`
MessageReplyEvent *MessageReplyEvent `cbor:"message_reply_event"`
MessageIDGarbageCollected *MessageIDGarbageCollected `cbor:"message_id_garbage_collected"`
}
type ShutdownEvent ¶
type ShutdownEvent struct{}
func (*ShutdownEvent) String ¶
func (e *ShutdownEvent) String() string
type ThinClient ¶
ThinClient is the client that handles communication between the mixnet application and the client daemon. It does not do any encryption or decryption or checking of cryptographic signatures; those responsibilities are left to the client daemon process.
func NewThinClient ¶
func NewThinClient(cfg *config.Config) *ThinClient
NewThinClient creates a new thing client.
func (*ThinClient) BlockingSendMessage ¶
func (t *ThinClient) BlockingSendMessage(ctx context.Context, payload []byte, destNode *[32]byte, destQueue []byte) ([]byte, error)
BlockingSendMessage blocks until a reply is received and returns it or an error.
func (*ThinClient) BlockingSendReliableMessage ¶
func (t *ThinClient) BlockingSendReliableMessage(ctx context.Context, messageID *[MessageIDLength]byte, payload []byte, destNode *[32]byte, destQueue []byte) (reply []byte, err error)
BlockingSendReliableMessage blocks until the message is reliably sent and the ARQ reply is received.
func (*ThinClient) Close ¶
func (t *ThinClient) Close() error
Close halts the thin client worker thread and closes the socket connection with the client daemon.
func (*ThinClient) EventSink ¶
func (t *ThinClient) EventSink() chan Event
func (*ThinClient) GetConfig ¶
func (t *ThinClient) GetConfig() *config.Config
GetConfig returns the config
func (*ThinClient) GetLogger ¶
func (t *ThinClient) GetLogger(prefix string) *logging.Logger
GetLogger(prefix) returns a logger with prefix
func (*ThinClient) GetService ¶
func (t *ThinClient) GetService(serviceName string) (*common.ServiceDescriptor, error)
GetService returns a randomly selected service matching the specified service name
func (*ThinClient) GetServices ¶
func (t *ThinClient) GetServices(capability string) ([]*common.ServiceDescriptor, error)
GetServices returns the services matching the specified service name
func (*ThinClient) NewMessageID ¶
func (t *ThinClient) NewMessageID() *[MessageIDLength]byte
NewMessageID returns a new message id.
func (*ThinClient) NewSURBID ¶
func (t *ThinClient) NewSURBID() *[sConstants.SURBIDLength]byte
NewSURBID returns a new surb id.
func (*ThinClient) PKIDocument ¶
func (t *ThinClient) PKIDocument() *cpki.Document
PKIDocument returns the thin client's current reference to the PKI doc
func (*ThinClient) SendMessage ¶
func (t *ThinClient) SendMessage(surbID *[sConstants.SURBIDLength]byte, payload []byte, destNode *[32]byte, destQueue []byte) error
SendMessage takes a message payload, a destination node, destination queue ID and a SURB ID and sends a message along with a SURB so that you can later receive the reply along with the SURBID you choose. This method of sending messages should be considered to be asynchronous because it does NOT actually wait until the client daemon sends the message. Nor does it wait for a reply. The only blocking aspect to it's behavior is merely blocking until the client daemon receives our request to send a message.
func (*ThinClient) SendMessageWithoutReply ¶
func (t *ThinClient) SendMessageWithoutReply(payload []byte, destNode *[32]byte, destQueue []byte) error
SendMessageWithoutReply sends a message encapsulated in a Sphinx packet, without any SURB. No reply will be possible.
func (*ThinClient) SendReliableMessage ¶
func (t *ThinClient) SendReliableMessage(messageID *[MessageIDLength]byte, payload []byte, destNode *[32]byte, destQueue []byte) error
func (*ThinClient) Shutdown ¶
func (t *ThinClient) Shutdown()
type ThinResponse ¶
type ThinResponse struct {
// SURBID, a unique indentifier for this response,
// which should precisely match the application's chosen
// SURBID of the sent message.
SURBID *[sConstants.SURBIDLength]byte
// ID is the unique ID for the corresponding sent message.
ID *[MessageIDLength]byte
// Payload is the decrypted payload plaintext.
Payload []byte
}
ThinResponse is used to encapsulate a message response that are passed to the client application.