netboundfileenc

package
v0.0.0-...-f37ca10 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxRandomChallengeLen is the maximum length accepted for a client-generated random challenge string.
	MaxRandomChallengeLen = 64
)

Variables

This section is empty.

Functions

func GetRandomChallenge

func GetRandomChallenge() string

GetRandomChallenge returns a randomly generated string that an RPC client may use as challenge string to identify its intent. The function uses the default PRNG source internally.

Types

type PasswordRegister

type PasswordRegister struct {
	unlocksvc.UnimplementedPasswordUnlockServiceServer
	// IntentsChallenge record the random string challenge generated by the client. They reside in an in-memory buffer, hence the capacity is
	// sufficient for a limited number of entries.
	// The identification of these challenge strings are stored in IntentIdentifications and kept in-sync.
	IntentsChallenge *datastruct.LeastRecentlyUsedBuffer
	// IntentIdentifications is a mapping between client's random string challenge and the identification information. The map is kept in-sync
	// with the elements stored in IntentsChallenge.
	IntentIdentifications map[string]*UnlockAttemptRPCClientInfo
	// FulfilledIntents is a mapping between client's random string challenge and the corresponding unlocking password in plain text.
	FulfilledIntents map[string]string
	// contains filtered or unexported fields
}

PasswordRegister provides facilities for an instance of laitos program to register an intent of obtaining unlocking password for its config/data files, and then obtain the password after a user has honoured the intent.

func NewPasswordRegister

func NewPasswordRegister(maxIntents, maxCallsPerSec int, logger *lalog.Logger) *PasswordRegister

NewPasswordRegister returns an initialised PasswordRegister.

func (*PasswordRegister) FulfilIntent

func (reg *PasswordRegister) FulfilIntent(challenge, password string) bool

FulfilIntent memorises an unlocking password corresponding to a client generated challenge. The function returns true if an outstanding intent corresponds to the challenge, otherwise, it returns false and the password will be not be memorised.

func (*PasswordRegister) GetOutstandingIntents

func (reg *PasswordRegister) GetOutstandingIntents() map[string]*UnlockAttemptRPCClientInfo

GetOutstandingIntents returns the identification records of outstanding unlocking intents that are yet to be fulfilled.

func (*PasswordRegister) GetUnlockPassword

GetUnlockPassword retrieves an unlocking password a user has offered.

func (*PasswordRegister) PostUnlockIntent

PostUnlockIntent registers an intent of obtaining unlocking password from a user.

type UnlockAttemptRPCClientInfo

type UnlockAttemptRPCClientInfo struct {
	*unlocksvc.UnlockAttemptIdentification
	ClientIP string
	Time     time.Time
}

UnlockAttemptRPCClientInfo contains the identification information from an unlocking request along with network transport information about the client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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