common

package
v0.0.75 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package common provides shared utilities for katzenpost CLI tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandlerWithUsage

func ErrorHandlerWithUsage(cmd *cobra.Command) fang.ErrorHandler

ErrorHandlerWithUsage creates a custom error handler that displays error messages followed by usage help for CLI argument errors. This provides better user experience by showing both the error and how to use the command correctly.

func ExecuteWithFang

func ExecuteWithFang(cmd *cobra.Command)

ExecuteWithFang executes a cobra command using fang with standard katzenpost options. This reduces boilerplate across all CLI tools by providing a common execution pattern.

func LambdaRateToMs added in v0.0.73

func LambdaRateToMs(lambda float64) (uint64, error)

LambdaRateToMs converts a PKI lambda parameter (the rate of an Exp distribution, in events per millisecond) into the mean delay in milliseconds that ExpDist.UpdateRate expects. math.Ceil avoids the truncation-to-zero hazard of uint64(1.0 / lambda) when lambda > 1.

func TruncatePEMForLogging added in v0.0.58

func TruncatePEMForLogging(pemStr string) string

TruncatePEMForLogging truncates a PEM string to first two lines only This is useful for logging PEM keys in a more concise format while preserving the header and first line of data for debugging purposes.

Types

type ExpDist added in v0.0.72

type ExpDist struct {
	worker.Worker
	// contains filtered or unexported fields
}

ExpDist provides a pseudorandom ticker with an average and maximum delay The channel returned by OutCh() is written at an average rate specified with UpdateRate(average, max uint64), in units of milliseconds.

func NewExpDist added in v0.0.72

func NewExpDist() *ExpDist

NewExpDist returns an ExpDist with running worker routine.

func (*ExpDist) OutCh added in v0.0.72

func (e *ExpDist) OutCh() <-chan struct{}

OutCh returns channel that receives at the rate specified by UpdateRate

func (*ExpDist) UpdateConnectionStatus added in v0.0.72

func (e *ExpDist) UpdateConnectionStatus(isConnected bool)

UpdateConnectionStatus(true) starts sending to OutCh and UpdateConnectionStatus(false) stops sending to OutCh

func (*ExpDist) UpdateRate added in v0.0.72

func (e *ExpDist) UpdateRate(averageRate uint64, maxDelay uint64)

UpdateRate is a value in milliseconds and specifies the average and maximum delay between writes to the channel returned by OutCh.

Directories

Path Synopsis
Package config provides common configuration structures and utilities shared between courier and replica services.
Package config provides common configuration structures and utilities shared between courier and replica services.

Jump to

Keyboard shortcuts

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