broadcast

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: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assembler

type Assembler func(rid id.Round) (payload []byte, err error)

Assembler assembles the message to send using the provided round ID.

type Channel

type Channel interface {
	// MaxPayloadSize returns the maximum size for a symmetric broadcast
	// payload.
	MaxPayloadSize() int

	// MaxRSAToPublicPayloadSize returns the maximum size for an asymmetric
	// broadcast payload.
	MaxRSAToPublicPayloadSize() int

	// Get returns the underlying broadcast.Channel object.
	Get() *crypto.Channel

	// Broadcast broadcasts a payload to the channel. The payload must be of the
	// size Channel.MaxPayloadSize or smaller.
	//
	// The network must be healthy to send.
	Broadcast(payload []byte, tags []string, metadata [2]byte,
		cMixParams cmix.CMIXParams) (rounds.Round, ephemeral.Id, error)

	// BroadcastWithAssembler broadcasts a payload over a channel with a payload
	// assembled after the round is selected, allowing the round info to be
	// included in the payload.
	//
	// The payload must be of the size Channel.MaxPayloadSize or smaller.
	//
	// The network must be healthy to send.
	BroadcastWithAssembler(assembler Assembler, tags []string, metadata [2]byte,
		cMixParams cmix.CMIXParams) (rounds.Round, ephemeral.Id, error)

	// BroadcastRSAtoPublic broadcasts the payload to the channel.
	//
	// The payload must be of the size Channel.MaxRSAToPublicPayloadSize or
	// smaller and the channel rsa.PrivateKey must be passed in.
	//
	// The network must be healthy to send.
	BroadcastRSAtoPublic(pk rsa.PrivateKey, payload []byte, tags []string,
		metadata [2]byte, cMixParams cmix.CMIXParams) (
		[]byte, rounds.Round, ephemeral.Id, error)

	// BroadcastRSAToPublicWithAssembler broadcasts the payload to the channel
	// with a function that builds the payload based upon the ID of the selected
	// round.
	//
	// The payload must be of the size Channel.MaxRSAToPublicPayloadSize or
	// smaller and the channel rsa.PrivateKey must be passed in.
	//
	// The network must be healthy to send.
	BroadcastRSAToPublicWithAssembler(pk rsa.PrivateKey, assembler Assembler,
		tags []string, metadata [2]byte, cMixParams cmix.CMIXParams) (
		[]byte, rounds.Round, ephemeral.Id, error)

	// RegisterRSAtoPublicListener registers a listener for asymmetric broadcast messages.
	// Note: only one Asymmetric Listener can be registered at a time.
	// Registering a new one will overwrite the old one
	RegisterRSAtoPublicListener(listenerCb ListenerFunc, tags []string) (
		Processor, error)

	// RegisterSymmetricListener registers a listener for asymmetric broadcast messages.
	// Note: only one Asymmetric Listener can be registered at a time.
	// Registering a new one will overwrite the old one
	RegisterSymmetricListener(listenerCb ListenerFunc, tags []string) (
		Processor, error)

	// Stop unregisters the listener callback and stops the channel's identity
	// from being tracked.
	Stop()

	// AsymmetricIdentifier returns a copy of the asymmetric identifier.
	AsymmetricIdentifier() []byte

	// SymmetricIdentifier returns a copy of the symmetric identifier.
	SymmetricIdentifier() []byte
}

Channel is the public-facing interface to interact with broadcast channels.

func NewBroadcastChannel

func NewBroadcastChannel(channel *crypto.Channel, net Client,
	rng *fastRNG.StreamGenerator) (Channel, error)

NewBroadcastChannel creates a channel interface based on broadcast.Channel. It accepts a Cmix client connection.

type Client

type Client interface {
	SendWithAssembler(recipient *id.ID, assembler cmix.MessageAssembler,
		cmixParams cmix.CMIXParams) (rounds.Round, ephemeral.Id, error)
	IsHealthy() bool
	AddIdentityWithHistory(
		id *id.ID, validUntil, beginning time.Time, persistent bool,
		fallthroughProcessor message.Processor)
	UpsertCompressedService(clientID *id.ID, newService message.CompressedService,
		response message.Processor)
	DeleteClientService(clientID *id.ID)
	RemoveIdentity(id *id.ID)
	GetMaxMessageLength() int
}

Client contains the methods from cmix.Client that are required by the broadcastClient.

type ListenerFunc

type ListenerFunc func(payload, encryptedPayload []byte, tags []string,
	metadata [2]byte, receptionID receptionID.EphemeralIdentity,
	round rounds.Round)

ListenerFunc is registered when creating a new broadcasting channel and receives all new broadcast messages for the channel.

type Method

type Method uint8

Method enum for broadcast type.

const (
	// Symmetric messages can be sent by anyone in the channel to everyone else
	// in the channel.
	//
	//  all -> all
	Symmetric Method = iota

	// RSAToPublic messages can be sent from the channel admin to everyone else
	// in the channel.
	//
	//  admin -> all
	RSAToPublic

	// RSAToPrivate messages can be sent from anyone in the channel to the
	// channel admin.
	//
	//  all -> admin
	RSAToPrivate
)

func (Method) String

func (m Method) String() string

String prints a human-readable string representation of the Method used for logging and debugging. This function adheres to the fmt.Stringer interface.

type NewBroadcastChannelFunc

type NewBroadcastChannelFunc func(channel *crypto.Channel, net Client,
	rng *fastRNG.StreamGenerator) (Channel, error)

NewBroadcastChannelFunc creates a broadcast Channel. Used so that it can be replaced in tests.

type Processor added in v4.4.4

type Processor interface {
	message.Processor

	// ProcessAdminMessage decrypts an admin message and sends the results on
	// the callback.
	ProcessAdminMessage(innerCiphertext []byte, tags []string, metadata [2]byte,
		receptionID receptionID.EphemeralIdentity, round rounds.Round)
}

Processor handles channel message decryption and handling.

Jump to

Keyboard shortcuts

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