encoders

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// EncoderModulus - The modulus used to calculate the encoder ID from a C2 request nonce
	// *** IMPORTANT *** ENCODER IDs MUST BE LESS THAN THE MODULUS
	EncoderModulus = uint64(65537)
	MaxN           = uint64(9999999)
)

Variables

View Source
var (
	TrafficEncoderFS = PassthroughEncoderFS{}

	Base64  = util.Base64{}
	Base58  = util.Base58{}
	Base32  = util.Base32{}
	Hex     = util.Hex{}
	English = util.English{}
	Gzip    = util.Gzip{}
	PNG     = util.PNGEncoder{}
	Nop     = util.NoEncoder{}

	NoEncoderID      = uint64(0)
	Base64EncoderID  = SetupDefaultEncoders("base64")
	Base58EncoderID  = SetupDefaultEncoders("base58")
	Base32EncoderID  = SetupDefaultEncoders("base32")
	HexEncoderID     = SetupDefaultEncoders("hex")
	EnglishEncoderID = SetupDefaultEncoders("english")
	GzipEncoderID    = SetupDefaultEncoders("gzip")
	PNGEncoderID     = SetupDefaultEncoders("png")
	NopEncoderID     = SetupDefaultEncoders("nop")
	UnavailableID    = PopulateID()
)

EncoderMap - A map of all available encoders (native and traffic/wasm)

FastEncoderMap - Keeps track of fast native encoders that can be used for large messages

View Source
var TrafficEncoderMap = map[uint64]*traffic.TrafficEncoder{}

TrafficEncoderMap - Keeps track of the loaded traffic encoders (i.e., wasm-based encoder functions)

Functions

func EncoderFromNonce

func EncoderFromNonce(nonce uint64) (uint64, util.Encoder, error)

EncoderFromNonce - Convert a nonce into an encoder

func GetRandomID

func GetRandomID() uint64

generate a random id and ensure it is not in use

func PopulateID

func PopulateID() []uint64

generate unavailable id array on startup

func RandomEncoder

func RandomEncoder() (uint64, util.Encoder)

RandomEncoder - Get a random nonce identifier and a matching encoder

func RemoveTrafficEncoder

func RemoveTrafficEncoder(name string) error

RemoveTrafficEncoder - Save a traffic encoder to the filesystem

func SaveTrafficEncoder

func SaveTrafficEncoder(name string, wasmBin []byte) error

SaveTrafficEncoder - Save a traffic encoder to the filesystem

func SetupDefaultEncoders

func SetupDefaultEncoders(name string) uint64

Types

type PassthroughEncoderFS

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

PassthroughEncoderFS - Creates an encoder.EncoderFS object from a single local directory

func (PassthroughEncoderFS) Open

func (p PassthroughEncoderFS) Open(name string) (fs.File, error)

func (PassthroughEncoderFS) ReadDir

func (p PassthroughEncoderFS) ReadDir(_ string) ([]fs.DirEntry, error)

func (PassthroughEncoderFS) ReadFile

func (p PassthroughEncoderFS) ReadFile(name string) ([]byte, error)

Jump to

Keyboard shortcuts

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