messaging

package
v0.0.0-...-8fcfbba Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: LGPL-3.0 Imports: 31 Imported by: 1

Documentation

Overview

Package implements reliable messaging layer for parties identified by a URL.

Index

Constants

View Source
const (
	// group states
	GroupStateNew         = 0
	GroupStateBackfilling = 1
	GroupStateSynced      = 2
	GroupStateProposed    = 3

	// group membership connection states
	GroupMembershipConnectionStateNew          = 0
	GroupMembershipConnectionStateInitiating   = 1
	GroupMembershipConnectionStateConnected    = 2
	GroupMembershipConnectionStateDeactivating = 3
	GroupMembershipConnectionStateDeactivated  = 4

	// group membership backfill states
	GroupMembershipBackfillStateNew         = 0
	GroupMembershipBackfillStateBackfilling = 1
	GroupMembershipBackfillStateSynced      = 2

	// bundle member states
	MessageStateUndelivered = 0
	MessageStateDelivered   = 1

	// endpoint states
	EndpointStateReady           = 0
	EndpointStateDelivering      = 1
	EndpointStateNotReady        = 2
	EndpointStateDelivered       = 3
	EndpointStateFailed          = 4
	EndpointStatePreflightFailed = 5

	IntroTypeJpake  = 0
	IntroTypePrekey = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Ack

type Ack struct {
	LastSeqAck    uint64 `bencode:"s"`
	LastSparseAck []byte `bencode:"sp"`
}

type AddressedMessage

type AddressedMessage struct {
	From string
	URLs []string
	Body []byte
}

type Backfill

type Backfill struct {
	ID    ids.ID `bencode:"i"`
	Total uint64 `bencode:"t"`
	Body  []byte `bencode:"b"`
}

type BackfillAbort

type BackfillAbort struct {
	ID ids.ID `bencode:"i"`
}

type BackfillComplete

type BackfillComplete struct {
	ID    ids.ID `bencode:"i"`
	Total uint64 `bencode:"t"`
}

type BackfillRequest

type BackfillRequest struct {
	ID   ids.ID `bencode:"i"`
	Type uint8  `bencode:"t"`
}

type BackfillStart

type BackfillStart struct {
	ID   ids.ID    `bencode:"i"`
	Acks GroupAcks `bencode:"a"`
}

type DeviceInvite

type DeviceInvite struct {
	ID      ids.ID
	CtimeMs uint64
}

type EncryptedBody

type EncryptedBody struct {
	PublicKey [32]byte `bencode:"k"`
	Body      []byte   `bencode:"b"`
}

type EndpointInfo

type EndpointInfo struct {
	Priority uint8 `bencode:"p"`
}

type Group

type Group struct {
	ID               ids.ID
	Name             string
	AuthorTag        [7]byte
	SelfIdentityID   [16]byte
	SelfMembershipID [16]byte
	State            int
	// contains filtered or unexported fields
}

type GroupAcks

type GroupAcks struct {
	Acks map[ids.ID]map[ids.ID]*Ack `bencode:"a"`
}

type GroupDescription

type GroupDescription struct {
	Name        *LWWString  `bencode:"n"`
	Description *LWWString  `bencode:"d"`
	Icon        *LWWBlob    `bencode:"ic"`
	IconType    *LWWString  `bencode:"it"`
	Identities  IdentityMap `bencode:"i"`
}

type GroupMembership

type GroupMembership []*Member

type GroupMessage

type GroupMessage struct {
	GroupMessages    []*GroupMessageBody `bencode:"b"`
	GroupAckSeq      uint64              `bencode:"gs"`
	GroupAckSparse   []byte              `bencode:"gss"`
	PrivateAckSeq    uint64              `bencode:"ps"`
	PrivateAckSparse []byte              `bencode:"pss"`
	BaseDigest       []byte              `bencode:"bd"`
	GroupChanges     []byte              `bencode:"gc"`
	NewDigest        []byte              `bencode:"nd"`
	PrivateMessages  []*PrivateMessage   `bencode:"m"`
	Lost             []*LostBody         `bencode:"l"`
}

type GroupMessageBody

type GroupMessageBody struct {
	Body                []byte              `bencode:"b"`
	Seq                 uint64              `bencode:"s"`
	UnhandledRecipients map[ids.ID][]ids.ID `bencode:"u"`
}

type GroupUpdate

type GroupUpdate struct {
	GroupID              ids.ID
	GroupState           int
	MemberCount          uint
	ConnectedMemberCount uint
	Seq                  uint64
	PendingMessageCount  uint
	AckedMemberCount     uint
}

type IdentityMap

type IdentityMap map[ids.ID]MembershipMap

type IncomingGroupMessage

type IncomingGroupMessage struct {
	GroupID      ids.ID
	IdentityID   ids.ID
	MembershipID ids.ID
	Seq          uint64
	Body         []byte
}

type IntroFailed

type IntroFailed struct {
	IntroID ids.ID
	GroupID ids.ID
}

type IntroSucceeded

type IntroSucceeded struct {
	IntroID ids.ID
	GroupID ids.ID
}

type IntroUpdate

type IntroUpdate struct {
	GroupID   ids.ID
	Initiator bool
	Stage     uint32
	Type      uint32
}

type Jpake1

type Jpake1 struct {
	ID        [16]byte                 `bencode:"id"`
	UserID    [16]byte                 `bencode:"u"`
	PublicKey [32]byte                 `bencode:"k"`
	X1G       []byte                   `bencode:"x1g"`
	X2G       []byte                   `bencode:"x2g"`
	X1ZKP     *ZKPBody                 `bencode:"x1zkp"`
	X2ZKP     *ZKPBody                 `bencode:"x2zkp"`
	ReplyTo   map[string]*EndpointInfo `bencode:"r"`
}

type LWWBlob

type LWWBlob struct {
	Value []byte `bencode:"v"`
	Type  string `bencode:"y"`
	Time  uint64 `bencode:"t"`
}

type LWWString

type LWWString struct {
	Value string `bencode:"v"`
	Time  uint64 `bencode:"t"`
}

type LostBody

type LostBody struct {
	Type uint8  `bencode:"t"`
	Body []byte `bencode:"b"`
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(config *config.Config, db *db.Database, t Transports, s sender, p processor, c clock.Clock, mu MembershipUpdater) (*Manager, error)

func (*Manager) AddMembership

func (m *Manager) AddMembership(groupID, identityID, membershipID ids.ID, membership *Membership) error

func (*Manager) AddressedMessageFromDirectMessage

func (m *Manager) AddressedMessageFromDirectMessage(message *directMessage, dme []*directMessageEndpoint) (*AddressedMessage, error)

func (*Manager) ApplyProposal

func (m *Manager) ApplyProposal(groupID, applierIdentityID, applierMembershipID, proposedMembershipID ids.ID, proposedMembership *Membership) error

func (*Manager) ApproveJpakeInvite

func (m *Manager) ApproveJpakeInvite(jpake1 *Jpake1, password string) (ids.ID, error)

func (*Manager) ApproveJpakeInviteWithID

func (m *Manager) ApproveJpakeInviteWithID(jpake1 *Jpake1, password string, existingGroupID *ids.ID) (ids.ID, error)

func (*Manager) CancelInvites

func (m *Manager) CancelInvites(groupID ids.ID) error

func (*Manager) CreateGroup

func (m *Manager) CreateGroup(name string) (ids.ID, error)

func (*Manager) CreateGroupWithID

func (m *Manager) CreateGroupWithID(name string, id ids.ID) error

func (*Manager) DeviceGroupID

func (m *Manager) DeviceGroupID() ids.ID

func (*Manager) EndpointInfoForURL

func (m *Manager) EndpointInfoForURL(u string) (*EndpointInfo, error)

func (*Manager) Group

func (m *Manager) Group(id ids.ID) (*Group, error)

func (*Manager) GroupMembers

func (m *Manager) GroupMembers(groupID ids.ID) (GroupMembership, error)

func (*Manager) GroupState

func (m *Manager) GroupState(id ids.ID) (*GroupUpdate, error)

func (*Manager) Groups

func (m *Manager) Groups() ([]*Group, error)

func (*Manager) InitiatePrekeySessions

func (m *Manager) InitiatePrekeySessions() error

func (*Manager) InviteMember

func (m *Manager) InviteMember(groupID ids.ID, password string) (*Jpake1, error)

func (*Manager) ProcessIncomingMessage

func (m *Manager) ProcessIncomingMessage(from string, body []byte) error

func (*Manager) ProposeMembership

func (m *Manager) ProposeMembership(groupID, identityID, otherMembershipID ids.ID, otherMembership *Membership) (ids.ID, *Membership, error)

func (*Manager) ReportChange

func (m *Manager) ReportChange(groupID ids.ID, url string, active bool) error

func (*Manager) SendGroupMessage

func (m *Manager) SendGroupMessage(groupID ids.ID, body []byte) error

func (*Manager) Shutdown

func (m *Manager) Shutdown() (err error)

func (*Manager) Start

func (m *Manager) Start() error

func (*Manager) Updates

func (m *Manager) Updates() UpdateChannel

func (*Manager) WaitForDelivery

func (m *Manager) WaitForDelivery() error

type Member

type Member struct {
	ID      ids.ID
	Members []ids.ID
}

type Membership

type Membership struct {
	Description *MembershipDescription `bencode:"d"`
	Signature   []byte                 `bencode:"s"`
}

type MembershipDescription

type MembershipDescription struct {
	IntroKey  [32]byte                 `bencode:"k"`
	Version   uint32                   `bencode:"v"`
	Protocol  uint32                   `bencode:"p"`
	Endpoints map[string]*EndpointInfo `bencode:"es"`
}

type MembershipMap

type MembershipMap map[ids.ID]*Membership

type MembershipUpdater

type MembershipUpdater func(ids.ID, ids.ID, ids.ID, *Membership) error

type PrivateMessage

type PrivateMessage struct {
	Type uint8  `bencode:"t"`
	Body []byte `bencode:"b"`
	Seq  uint64 `bencode:"s"`
}

type RepairBody

type RepairBody struct {
	IdentityID   ids.ID `bencode:"i"`
	MembershipID ids.ID `bencode:"m"`
	Seq          uint64 `bencode:"s"`
	Body         []byte `bencode:"b"`
}

type Transports

type Transports interface {
	URLsForGroup(id ids.ID) ([]string, error)
	ReportGroup(id ids.ID) error
	Preflight([]string) []bool
	StatusChanged(func(string, bool))
}

type UpdateChannel

type UpdateChannel chan interface{}

type ZKPBody

type ZKPBody struct {
	T []byte `bencode:"t"`
	R []byte `bencode:"r"`
}

Jump to

Keyboard shortcuts

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