common

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientID

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

ClientID identifies a client using 8 arbitrary bytes and can be used as a map key.

func BytesToClientID

func BytesToClientID(b []byte) (ClientID, error)

BytesToClientID creates a ClientID based on the provided bytes.

func MakeClientID

func MakeClientID(pk crypto.PublicKey) (ClientID, error)

MakeClientID generates a ClientID from the provided public key.

func StringToClientID

func StringToClientID(s string) (ClientID, error)

StringToClientID creates a ClientID based on the provided hex string.

func (ClientID) Bytes

func (i ClientID) Bytes() []byte

Bytes returns bytes stored by ClientID

func (ClientID) IsNil

func (i ClientID) IsNil() bool

IsNil returns a client id represents the nil/empty id.

func (ClientID) String

func (i ClientID) String() string

String implements fmt.Stringer.

type MessageID

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

MessageID identifies a message using 32 arbitrary bytes and can be used as a map key.

func BytesToMessageID

func BytesToMessageID(b []byte) (MessageID, error)

BytesToMessageID converts a slice of 32 bytes to a message id.

func MakeMessageID

func MakeMessageID(origin *fspb.Address, originID []byte) MessageID

MakeMessageID generates a MessageID from the provided Origin and OriginMessageID. It is deterministic, so that if a client needs to send a message twice, we can deduplicate the message by ID. It is a good hash so that we can be sure that IDs are uniformly distributed, even if the clients are miscoded or hostile.

func RandomMessageID

func RandomMessageID() (MessageID, error)

RandomMessageID generates a MessageID from random bytes. This is appropriate for messages created on the server, client messages should use MakeMessageID.

func StringToMessageID

func StringToMessageID(s string) (MessageID, error)

StringToMessageID creates a MessageID based on the provided hex string.

func (MessageID) Bytes

func (i MessageID) Bytes() []byte

Bytes returns bytes stored by MessageID

func (MessageID) IsNil

func (i MessageID) IsNil() bool

IsNil return whether MessageID represents the nil/empty id.

func (MessageID) String

func (i MessageID) String() string

String implements fmt.Stringer.

Directories

Path Synopsis
Package anypbtest offers test helpers for working with AnyPb protos.
Package anypbtest offers test helpers for working with AnyPb protos.
Package fscontext contains helpers for migrating Fleetspeak to context.Context.
Package fscontext contains helpers for migrating Fleetspeak to context.Context.
proto
Package should lets callers indicate impossible conditions from the code.
Package should lets callers indicate impossible conditions from the code.

Jump to

Keyboard shortcuts

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