Documentation ¶
Index ¶
- type BroadcastStrategy
- type ContactID
- type ContactsContainer
- type Device
- type DeviceAddress
- type MemoryContactsContainer
- func (c *MemoryContactsContainer) AllGroups() []ContactID
- func (c *MemoryContactsContainer) AllLinks() []ContactID
- func (c *MemoryContactsContainer) ContactSecret(contact ContactID) (SharedSecret, error)
- func (c *MemoryContactsContainer) DebugLink(sharedSecret SharedSecret) ContactID
- func (c *MemoryContactsContainer) DeleteContact(contact ContactID)
- func (c *MemoryContactsContainer) JoinGroup(groupSecret SharedSecret) (ContactID, error)
- func (c *MemoryContactsContainer) NewGroup() (ContactID, error)
- func (c *MemoryContactsContainer) NewLink(linkSecret SharedSecret) (ContactID, error)
- type MessageID
- type ProtocolOptions
- type SessionID
- type SharedSecret
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BroadcastStrategy ¶
type BroadcastStrategy int
const ( // Forwards route requests to all connected peers. BroadcastAll BroadcastStrategy = iota // Forwards route requests to a random sample of the connected peers // with the number of forwards determined by a logarithmic function. BroadcastLogFunc // Forwards route requests to two randomly selected peers. BroadcastTwo )
type ContactsContainer ¶
type ContactsContainer interface { ContactSecret(contact ContactID) (SharedSecret, error) DeleteContact(contact ContactID) AllGroups() []ContactID AllLinks() []ContactID NewGroup() (ContactID, error) JoinGroup(groupSecret SharedSecret) (ContactID, error) NewLink(linkSecret SharedSecret) (ContactID, error) }
type Device ¶
type Device interface { // Log prints a message to the device log. Log(message string) // SendPacket sends a packet to the device with the provided address. SendPacket(address DeviceAddress, packet []byte) // MessageDelivered is called when a message has been confirmed to have been received. MessageDelivered(messageID MessageID) // MaxPacketSize returns the max packet size for some peer given by its address. MaxPacketSize(address DeviceAddress) (int, error) // ProcessMessage is called when packet(s) from a peer have been decoded to a message ProcessMessage(session SessionID, message []byte) // ReplyPayload is called when a matching route request is received. // It returns the payload that should be included with the route reply. ReplyPayload(session SessionID, contact ContactID) []byte // SessionEstablished is called when a new session with the given contact has been established SessionEstablished(session SessionID, contact ContactID, address DeviceAddress) // SessionBroken is called when a previously established session has been broken // and is no longer available SessionBroken(session SessionID) // SyncStateChanged is called whenever the synchronization state changes for a given contact. // The state is encoded as JSON. // This event is only called when the sync option is turned on. SyncStateChanged(contact ContactID, stateUpdate []byte) // Rand is used for generating all random values, a default is used when nil is returned Rand() *rand.Rand // CryptoRand should produce cryptographically secure random bytes in production CryptoRand() io.Reader // Delay performs the given action after the duration has passed Delay(action func(), duration time.Duration) // Now returns the current time of the device Now() time.Time ContactsContainer() ContactsContainer }
The device that the protocol uses to interact with the environment.
type DeviceAddress ¶
type DeviceAddress string
A DeviceAddress represents an address of a locally connected peer
type MemoryContactsContainer ¶
type MemoryContactsContainer struct {
// contains filtered or unexported fields
}
func NewMemoryContactsContainer ¶
func NewMemoryContactsContainer() *MemoryContactsContainer
func (*MemoryContactsContainer) AllGroups ¶
func (c *MemoryContactsContainer) AllGroups() []ContactID
func (*MemoryContactsContainer) AllLinks ¶
func (c *MemoryContactsContainer) AllLinks() []ContactID
func (*MemoryContactsContainer) ContactSecret ¶
func (c *MemoryContactsContainer) ContactSecret(contact ContactID) (SharedSecret, error)
func (*MemoryContactsContainer) DebugLink ¶
func (c *MemoryContactsContainer) DebugLink(sharedSecret SharedSecret) ContactID
func (*MemoryContactsContainer) DeleteContact ¶
func (c *MemoryContactsContainer) DeleteContact(contact ContactID)
func (*MemoryContactsContainer) JoinGroup ¶
func (c *MemoryContactsContainer) JoinGroup(groupSecret SharedSecret) (ContactID, error)
func (*MemoryContactsContainer) NewGroup ¶
func (c *MemoryContactsContainer) NewGroup() (ContactID, error)
func (*MemoryContactsContainer) NewLink ¶
func (c *MemoryContactsContainer) NewLink(linkSecret SharedSecret) (ContactID, error)
type MessageID ¶
type MessageID uint64
A MessageID is generated when sending a message in order to later get notified if it has been delivered
type ProtocolOptions ¶
type ProtocolOptions struct { // EnableSync determines whether the sync extension is enabled. EnableSync bool // When DisableAutoRREQOnConnection is activated, nodes will not automatically send route requests on connection. DisableAutoRREQOnConnection bool // The max time to live to give a packet when broadcasting or forwarding route requests. MaxRREQTTL int // RREQBroadcastStrategy determines what strategy to use when forwarding route requests. RREQBroadcastStrategy BroadcastStrategy // Whether or not to forward route requests, even when the node identifies that it is included in the bitmap. ForwardRREQsWhenMatching bool // ACKDelay ACKDelay time.Duration // ACKTimeout ACKTimeout time.Duration }
func DefaultProtocolOptions ¶
func DefaultProtocolOptions() *ProtocolOptions
func DefaultSyncProtocolOptions ¶
func DefaultSyncProtocolOptions() *ProtocolOptions
type SharedSecret ¶
type SharedSecret []byte
The SharedSecret is used to derive a device.ContactID and is used to encrypt messages
Click to show internal directories.
Click to hide internal directories.