message

package
v4.3.11 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: BSD-2-Clause, BSD-2-Clause Imports: 24 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomFingerprint

func RandomFingerprint(rng csprng.Source) format.Fingerprint

Types

type Bundle

type Bundle struct {
	Round     id.Round
	RoundInfo rounds.Round
	Messages  []format.Message
	Finish    func()
	Identity  receptionID.EphemeralIdentity
}

type FingerprintsManager

type FingerprintsManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

FingerprintsManager is a thread-safe map, mapping format.Fingerprint's to a Handler object.

func (*FingerprintsManager) AddFingerprint

func (f *FingerprintsManager) AddFingerprint(clientID *id.ID,
	fingerprint format.Fingerprint, mp Processor) error

AddFingerprint is a thread-safe setter for the FingerprintsManager map. AddFingerprint maps the given fingerprint key to the handler value. If there is already an entry for this fingerprint, the method returns with no write operation. If a nil identity is passed, it will automatically use the default identity in the session

func (*FingerprintsManager) DeleteClientFingerprints

func (f *FingerprintsManager) DeleteClientFingerprints(clientID *id.ID)

DeleteClientFingerprints is a thread-safe deletion operation on the fingerprints map. It will remove all entries for the given clientID from the map.

func (*FingerprintsManager) DeleteFingerprint

func (f *FingerprintsManager) DeleteFingerprint(clientID *id.ID,
	fingerprint format.Fingerprint)

DeleteFingerprint is a thread-safe deletion operation on the Fingerprints map. It will remove the entry for the given fingerprint from the map.

type Handler

type Handler interface {
	GetMessageReceptionChannel() chan<- Bundle
	StartProcesses() stoppable.Stoppable
	CheckInProgressMessages()

	// Fingerprints
	AddFingerprint(clientID *id.ID, fingerprint format.Fingerprint, mp Processor) error
	DeleteFingerprint(clientID *id.ID, fingerprint format.Fingerprint)
	DeleteClientFingerprints(clientID *id.ID)

	// Triggers
	AddService(clientID *id.ID, newService Service, response Processor)
	DeleteService(clientID *id.ID, toDelete Service, response Processor)
	DeleteClientService(clientID *id.ID)
	TrackServices(triggerTracker ServicesTracker)
}

func NewHandler

func NewHandler(param Params, kv *versioned.KV, events event.Reporter,
	standardID *id.ID) Handler

type MeteredCmixMessageBuffer

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

MeteredCmixMessageBuffer wraps the message buffer to store and load raw cMix messages.

func LoadMeteredCmixMessageBuffer

func LoadMeteredCmixMessageBuffer(kv *versioned.KV, key string) (
	*MeteredCmixMessageBuffer, error)

func NewMeteredCmixMessageBuffer

func NewMeteredCmixMessageBuffer(kv *versioned.KV, key string) (
	*MeteredCmixMessageBuffer, error)

func NewOrLoadMeteredCmixMessageBuffer

func NewOrLoadMeteredCmixMessageBuffer(kv *versioned.KV, key string) (
	*MeteredCmixMessageBuffer, error)

func (*MeteredCmixMessageBuffer) Add

func (*MeteredCmixMessageBuffer) AddProcessing

func (mcmb *MeteredCmixMessageBuffer) AddProcessing(m format.Message,
	ri *pb.RoundInfo, identity receptionID.EphemeralIdentity) (uint, time.Time)

func (*MeteredCmixMessageBuffer) Failed

func (*MeteredCmixMessageBuffer) Next

func (*MeteredCmixMessageBuffer) Remove

type Params

type Params struct {
	MessageReceptionBuffLen        uint
	MessageReceptionWorkerPoolSize uint
	MaxChecksInProcessMessage      uint
	InProcessMessageWait           time.Duration
	RealtimeOnly                   bool
}

Params contains the parameters for the message package.

func GetDefaultParams

func GetDefaultParams() Params

GetDefaultParams returns a Params object containing the default parameters.

func GetParameters

func GetParameters(params string) (Params, error)

GetParameters returns the default Params, or override with given parameters, if set.

func (Params) MarshalJSON

func (p Params) MarshalJSON() ([]byte, error)

MarshalJSON adheres to the json.Marshaler interface.

func (*Params) UnmarshalJSON

func (p *Params) UnmarshalJSON(data []byte) error

UnmarshalJSON adheres to the json.Unmarshaler interface.

type Processor

type Processor interface {
	// Process decrypts and hands off the message to its internal down stream
	// message processing system.
	// CRITICAL: Fingerprints should never be used twice. Process must denote,
	// in long term storage, usage of a fingerprint and that fingerprint must
	// not be added again during application load.
	// It is a security vulnerability to reuse a fingerprint. It leaks privacy
	// and can lead to compromise of message contents and integrity.
	Process(message format.Message, receptionID receptionID.EphemeralIdentity,
		round rounds.Round)

	// Stringer interface for debugging
	fmt.Stringer
}

type Service

type Service struct {
	Identifier []byte
	Tag        string
	Metadata   []byte // Optional metadata field, only used on reception
	// contains filtered or unexported fields
}

func GetDefaultService

func GetDefaultService(recipient *id.ID) Service

GetDefaultService is used to generate a default service. All identities will respond to their default service, but it lacks privacy because it uses the public ID as the key. Used for initial reach out in some protocols, otherwise should not be used.

func GetRandomService

func GetRandomService(rng csprng.Source) Service

GetRandomService is used to make a service for cMix sending when no service is needed. It fills the Identifier with random, bits in order to preserve privacy.

func (Service) ForMe

func (si Service) ForMe(contents, hash []byte) bool

func (Service) ForMeFromMessageHash

func (si Service) ForMeFromMessageHash(messageHash, hash []byte) bool

func (Service) Hash

func (si Service) Hash(contents []byte) []byte

func (Service) HashFromMessageHash

func (si Service) HashFromMessageHash(messageHash []byte) []byte

func (Service) String

func (si Service) String() string

type ServiceList

type ServiceList map[id.ID][]Service

The ServiceList holds all services.

func (ServiceList) MarshalJSON

func (sl ServiceList) MarshalJSON() ([]byte, error)

func (ServiceList) UnmarshalJSON

func (sl ServiceList) UnmarshalJSON(b []byte) error

type ServicesManager

type ServicesManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewServices

func NewServices() *ServicesManager

func (*ServicesManager) AddService

func (sm *ServicesManager) AddService(clientID *id.ID, newService Service, response Processor)

AddService adds a service which can call a message handing function or be used for notifications. In general a single service can only be registered for the same identifier/tag pair.

preimage - the preimage which is triggered on
type - a descriptive string of the service. Generally used in notifications
source - a byte buffer of related data. Mostly used in notifications.
  Example: Sender ID

There can be multiple "default" services, they must use the "default" tag and the identifier must be the client reception ID. A service may have a nil response unless it is default.

func (*ServicesManager) DeleteClientService

func (sm *ServicesManager) DeleteClientService(clientID *id.ID)

DeleteClientService deletes the mapping associated with an ID.

func (*ServicesManager) DeleteService

func (sm *ServicesManager) DeleteService(clientID *id.ID, toDelete Service,
	processor Processor)

DeleteService - If only a single response is associated with the preimage, the entire preimage is removed. If there is more than one response, only the given response is removed. If nil is passed in for response, all triggers for the preimage will be removed.

func (*ServicesManager) TrackServices

func (sm *ServicesManager) TrackServices(tracker ServicesTracker)

TrackServices adds a service tracker to be triggered when a new service is added. Generally used for notification to use this system to identify a received message.

type ServicesTracker

type ServicesTracker func(ServiceList)

Jump to

Keyboard shortcuts

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