dap

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2015 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDataResponse

func CreateDataResponse(code int, msg string, from *identity.Address, to *identity.Address, data []byte) []message.Message

func CreateResponse

func CreateResponse(code int, msg string, from *identity.Address, to *identity.Address, data ...message.Message) []message.Message

Types

type Client

type Client struct {
	Key    *identity.Identity
	Server *identity.Address
}

func CreateClient

func CreateClient(key *identity.Identity, server *identity.Address) *Client

func (*Client) DownloadMessages

func (c *Client) DownloadMessages(since uint64, context bool) ([]*ResponseMessage, error)

func (*Client) DownloadSentMessages added in v0.1.2

func (c *Client) DownloadSentMessages(since uint64, context bool) ([]*ResponseMessage, error)

Download Messages from Server

func (c *Client) EnableLink() error

EnableLink tells the dispatcher that the account is ready to accept link requests.

func (*Client) GetData

func (c *Client) GetData(key string) ([]byte, error)

func (*Client) GetLinkRequest

func (c *Client) GetLinkRequest() (*PendingLinkRequest, error)

GetLinkRequest will check the dispatcher for a pending link request

func (*Client) LinkAcceptRequest

func (c *Client) LinkAcceptRequest(request *PendingLinkRequest) error

LinkAcceptRequest will upload the current identity to the dispatcher encrypted for `from`

func (*Client) PublishDataMessage

func (c *Client) PublishDataMessage(
	r io.ReadSeeker,
	to []*identity.Address,
	typ, prefix, file string) (string, error)

func (*Client) PublishEncryptedMessage added in v0.1.2

func (c *Client) PublishEncryptedMessage(
	enc *message.EncryptedMessage,
	to []*identity.Address,
	name string,
	alert bool,
) (string, error)

func (*Client) PublishMessage

func (c *Client) PublishMessage(
	enc *message.Mail,
	to []*identity.Address,
	name string,
	alert bool,
) (string, error)

Publish Message on Server

func (*Client) Register

func (c *Client) Register(keys map[string][]byte) error

Register with the Server

func (*Client) SetData

func (c *Client) SetData(key string, value []byte) error

Set Arbitrary Data on Server

func (*Client) Unregister

func (c *Client) Unregister(keys map[string][]byte) error

Unregister with the Server

func (*Client) UpdateMessage

func (c *Client) UpdateMessage(enc *message.Mail, to []*identity.Address, name string) error

Update Message on Server

func (*Client) WaitForLinkRequest

func (c *Client) WaitForLinkRequest() (*PendingLinkRequest, error)

WaitForLinkRequeset will loop, querying the dispatcher every 10 seconds for a LinkRequest. It will error out after 5 minutes.

type Delegate

type Delegate interface {
	// Account
	Register(addr string, keys map[string][]byte) error
	Unregister(addr string, keys map[string][]byte) error
	// Message
	GetMessages(since uint64, owner string, context bool) ([]*ResponseMessage, error)
	PublishMessage(name string, to []string, author string, message *message.EncryptedMessage, alerted bool) error
	UpdateMessage(name string, author string, message *message.EncryptedMessage) error
	// Sent Messages
	GetSentMessages(since uint64, owner string, context bool) ([]*ResponseMessage, error)
	// AD Data
	PublishDataMessage(name string, to []string, author string, message *message.EncryptedMessage, length uint64, r ReadVerifier) error
	// Data
	GetData(owner string, key string) ([]byte, error)
	SetData(owner string, key string, data []byte) error
}

type Handler

type Handler struct {
	Key      *identity.Identity
	Delegate Delegate
}

func (*Handler) Data

func (h *Handler) Data(r *wire.Data, head message.Header) ([]message.Message, error)

Set Data

func (*Handler) DownloadMessages

func (h *Handler) DownloadMessages(r *wire.DownloadMessages, head message.Header) ([]message.Message, error)

Return all Messages received after `since` in sequence.

func (h *Handler) EnableLink(head message.Header) ([]message.Message, error)

func (*Handler) GetData

func (h *Handler) GetData(r *wire.GetData, head message.Header) ([]message.Message, error)

Get Data

func (*Handler) HandleMessage

func (h *Handler) HandleMessage(typ string, data []byte, head message.Header, conn net.Conn) ([]message.Message, error)

Handle the DAP Request

func (*Handler) HandlesType

func (h *Handler) HandlesType(typ string) bool

Handle Type

func (*Handler) LinkKey

func (h *Handler) LinkKey(msg *wire.LinkData, head message.Header) ([]message.Message, error)

func (*Handler) LinkRequest

func (h *Handler) LinkRequest(msg *wire.LinkData, head message.Header) ([]message.Message, error)

func (*Handler) LinkTransfer

func (h *Handler) LinkTransfer(msg *wire.LinkTransfer, head message.Header) ([]message.Message, error)

func (*Handler) PublishDataMessage

func (h *Handler) PublishDataMessage(r *wire.PublishDataMessage, head message.Header, conn net.Conn) ([]message.Message, error)

Publish a message on Delegate.

func (*Handler) PublishMessage

func (h *Handler) PublishMessage(r *wire.PublishMessage, head message.Header) ([]message.Message, error)

Publish a message on Delegate.

func (*Handler) Register

func (h *Handler) Register(r *wire.Register, head message.Header) ([]message.Message, error)

Register a User on the Delegate

func (*Handler) Unregister

func (h *Handler) Unregister(r *wire.Unregister, head message.Header) ([]message.Message, error)

Unregister a User on the Delegate

func (*Handler) UpdateMessage

func (h *Handler) UpdateMessage(r *wire.UpdateMessage, head message.Header) ([]message.Message, error)

Update a message on Delegate.

type LinkClient

type LinkClient struct {
	*Client

	User *identity.Address
}

func CreateLinkClient

func CreateLinkClient(linkFrom *identity.Address, server *identity.Address) (*LinkClient, error)

func (*LinkClient) GetVerificationCode

func (c *LinkClient) GetVerificationCode() (VerificationCode, error)

func (*LinkClient) LinkGetIdentity

func (l *LinkClient) LinkGetIdentity() (*identity.Identity, error)

LinkGetIdentity will download the identity from the dispatcher and decrypt it

func (*LinkClient) LinkRequest

func (l *LinkClient) LinkRequest(verification VerificationCode) error

LinkRequest sends a LinkRequest to the dispatcher for a specific account `to`

type LinkManager

type LinkManager struct {
	// Track which accounts are accepting link
	// requests at the current moment.
	// map: requestee -> time enabled
	EnabledAccounts map[string]time.Time
	EnabledLock     *sync.RWMutex

	// Track the link requests
	// map: requestee -> request payload
	Requests     map[string][]byte
	RequestsLock *sync.RWMutex

	// Track the Transfers
	// map: requester -> key payload
	KeyTransfers  map[string][]byte
	TransfersLock *sync.RWMutex
}

type PendingLinkRequest

type PendingLinkRequest struct {
	From         *identity.Address
	Verification string
}

type RawMessage

type RawMessage struct {
	proto.Message
	Code string
	Head message.Header
}

func (*RawMessage) Header

func (r *RawMessage) Header() message.Header

func (*RawMessage) ToBytes

func (r *RawMessage) ToBytes() []byte

func (*RawMessage) Type

func (r *RawMessage) Type() string

type ReadVerifier

type ReadVerifier interface {
	io.Reader
	Verify() bool
}

type Response

type Response struct {
	Code    uint32
	Message string
	Length  uint64
	Data    []byte
	// contains filtered or unexported fields
}

func CreateResponseFromBytes

func CreateResponseFromBytes(data []byte, head message.Header) (*Response, error)

func (*Response) Header

func (r *Response) Header() message.Header

func (*Response) ToBytes

func (r *Response) ToBytes() []byte

func (*Response) Type

func (r *Response) Type() string

type ResponseMessage

type ResponseMessage struct {
	Message *message.EncryptedMessage
	Context map[string][]byte
	// contains filtered or unexported fields
}

func CreateResponseMessageFromBytes

func CreateResponseMessageFromBytes(data []byte, head message.Header) (*ResponseMessage, error)

func (*ResponseMessage) Header

func (r *ResponseMessage) Header() message.Header

func (*ResponseMessage) ToBytes

func (r *ResponseMessage) ToBytes() []byte

func (*ResponseMessage) Type

func (r *ResponseMessage) Type() string

type VerificationCode

type VerificationCode string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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