message

package
v4.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 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 CompressedService added in v4.7.1

type CompressedService struct {
	Identifier []byte
	Tags       []string
	Metadata   []byte // when hashed, included in CompressedSIH, when evaluated, recovered
	// contains filtered or unexported fields
}

func (CompressedService) ForMe added in v4.7.1

func (cs CompressedService) ForMe(pickup *id.ID, contents, hash []byte) (
	tags []string, found bool, metadata []byte)

func (CompressedService) Hash added in v4.7.1

func (cs CompressedService) Hash(pickup *id.ID, contents []byte) ([]byte, error)

func (CompressedService) String added in v4.7.1

func (cs CompressedService) String() string

type CompressedServiceList added in v4.7.1

type CompressedServiceList map[id.ID][]CompressedService

The CompressedServiceList holds all CompressedService keyed on their user ID.

func (CompressedServiceList) DeepCopy added in v4.7.1

DeepCopy creates a copy of all public fields of the CompressedServiceList.

type FallthroughManager added in v4.4.4

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

func (*FallthroughManager) AddFallthrough added in v4.4.4

func (f *FallthroughManager) AddFallthrough(c *id.ID, p Processor)

func (*FallthroughManager) RemoveFallthrough added in v4.4.4

func (f *FallthroughManager) RemoveFallthrough(c *id.ID)

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)

	// Services
	AddService(clientID *id.ID, newService Service, response Processor)
	DeleteService(clientID *id.ID, toDelete Service, response Processor)
	UpsertCompressedService(clientID *id.ID, newService CompressedService,
		response Processor)
	DeleteCompressedService(clientID *id.ID, toDelete CompressedService,
		processor Processor)
	DeleteClientService(clientID *id.ID)
	TrackServices(triggerTracker ServicesTracker)
	GetServices() (ServiceList, CompressedServiceList)

	//Fallthrough
	AddFallthrough(c *id.ID, p Processor)
	RemoveFallthrough(c *id.ID)
}

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, tags []string, metadata []byte,
		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(_ *id.ID, contents []byte) ([]byte, error)

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 Service keyed on their user ID.

func (ServiceList) DeepCopy added in v4.7.1

func (sl ServiceList) DeepCopy() ServiceList

DeepCopy creates a copy of all public fields of the ServiceList.

func (ServiceList) MarshalJSON

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

MarshalJSON marshals the ServiceList into valid JSON. This function adheres to the json.Marshaler interface.

func (ServiceList) UnmarshalJSON

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

UnmarshalJSON unmarshalls JSON into the ServiceList. This function adheres to the json.Unmarshaler interface.

Note that this function does not transfer the internal RNG. Use NewCipherFromJSON to properly reconstruct a cipher from JSON. UnmarshalJSON adheres to the json.Unmarshaler interface.

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. deletes both services and compressed services

func (*ServicesManager) DeleteCompressedService added in v4.7.1

func (sm *ServicesManager) DeleteCompressedService(clientID *id.ID, toDelete CompressedService,
	processor Processor)

DeleteCompressedService - 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) 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) GetServices added in v4.7.1

func (sm *ServicesManager) GetServices() (ServiceList, CompressedServiceList)

GetServices returns the current list of registered services and compressed services. This returns the same lists as the last lists provided to trackers registered with ServicesManager.TrackServices.

func (*ServicesManager) TrackServices

func (sm *ServicesManager) TrackServices(tracker ServicesTracker)

TrackServices registers a callback that is called every time a service is added or removed. It is also called once when registered. The callback receives the new service lists every time they are modified. Callbacks only occur when the network follower is running. Multiple message.ServicesTracker can be registered.

Generally, this is used by notification to identify a received message.

func (*ServicesManager) UpsertCompressedService added in v4.7.1

func (sm *ServicesManager) UpsertCompressedService(clientID *id.ID, newService CompressedService,
	response Processor)

UpsertCompressedService adds a compressed service which can call a message handing function or be used for notifications. Online a single compressed service can be registered to an identifier. If the same identifier is used, it will replace the old one.

type ServicesTracker

type ServicesTracker func(ServiceList, CompressedServiceList)

ServicesTracker returns the current ServiceList and CompressedServiceList stored in the ServicesManager.

Jump to

Keyboard shortcuts

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