Documentation
¶
Index ¶
- Constants
- Variables
- func AddIACHandler(h IACHandler)
- func AlwaysRun(_ map[string]string) bool
- func AnsiHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
- func CleanserInputHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
- func CreatePromptHandler(steps []*PromptStep, onComplete CompletionFunc) connections.InputHandler
- func DefaultValidator(input string, _ map[string]string) (string, error)
- func EchoInputHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
- func FinalizeLoginOrCreate(results map[string]string, sharedState map[string]any, ...) bool
- func GetLoginPromptHandler() connections.InputHandler
- func HistoryInputHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
- func SignalHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
- func SystemCommandInputHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
- func TelnetIACHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
- func ValidateEmail(input string, results map[string]string) (string, error)
- func ValidateNewEntry(input string, _ map[string]string) (string, error)
- func ValidatePassword(input string, _ map[string]string) (string, error)
- func ValidatePassword2(input string, results map[string]string) (string, error)
- func ValidateUsername(input string, _ map[string]string) (string, error)
- func ValidateYesNo(input string, _ map[string]string) (string, error)
- type CompletionFunc
- type ConditionFunc
- type DataFunc
- type IACHandler
- type PromptHandlerState
- type PromptStep
- type SystemCommandHelp
- type ValidationFunc
Constants ¶
const ( CtrlA = 0x01 CtrlB = 0x02 CtrlC = 0x03 CtrlD = 0x04 CtrlE = 0x05 CtrlF = 0x06 CtrlN = 0x0E CtrlP = 0x10 // paste whatever is in the clipboard - This is kinda special and the clipboard should usually be empty unless you're CtrlQ = 0x11 // shortcut for /quit CtrlR = 0x12 CtrlS = 0x13 CtrlT = 0x14 CtrlU = 0x15 CtrlV = 0x16 CtrlW = 0x17 CtrlX = 0x18 CtrlY = 0x19 CtrlZ = 0x1A CtrlBkSlash = 0x1C )
const SystemCommandPrefix = "/"
Variables ¶
Functions ¶
func AddIACHandler ¶
func AddIACHandler(h IACHandler)
func AnsiHandler ¶
func AnsiHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
func CleanserInputHandler ¶
func CleanserInputHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
CleanserInputHandler's job is to remove any bad characters from the input stream before passing it down the chain. For this reason, it's important it happen before other text processing handlers
func CreatePromptHandler ¶
func CreatePromptHandler(steps []*PromptStep, onComplete CompletionFunc) connections.InputHandler
CreatePromptHandler creates a generic input handler for multi-step prompts.
func DefaultValidator ¶
DefaultValidator is a basic validator that accepts any non-empty input.
func EchoInputHandler ¶
func EchoInputHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
func FinalizeLoginOrCreate ¶
func FinalizeLoginOrCreate(results map[string]string, sharedState map[string]any, clientInput *connections.ClientInput) bool
FinalizeLoginOrCreate is called after all prompts are successfully answered.
func GetLoginPromptHandler ¶
func GetLoginPromptHandler() connections.InputHandler
func HistoryInputHandler ¶
func HistoryInputHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
All this does is manage the input history stack
func SignalHandler ¶
func SignalHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
This should be the first handler in the chain It will convert any special signals like CTRL-C into a /quit command
func SystemCommandInputHandler ¶
func SystemCommandInputHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
func TelnetIACHandler ¶
func TelnetIACHandler(clientInput *connections.ClientInput, sharedState map[string]any) (nextHandler bool)
func ValidatePassword2 ¶
func ValidateUsername ¶
Specific Validators
Types ¶
type CompletionFunc ¶
type CompletionFunc func(results map[string]string, sharedState map[string]any, clientInput *connections.ClientInput) bool
CompletionFunc is called when all steps are successfully completed. It receives the accumulated results and the shared state. It should return true if the overall process succeeded and the handler can be removed, false otherwise (e.g., login failed, disconnect).
type ConditionFunc ¶
ConditionFunc defines a function type to determine if a step should be executed. It takes the accumulated results so far.
type IACHandler ¶
type PromptHandlerState ¶
type PromptHandlerState struct {
Steps []*PromptStep
CurrentStepIndex int
Results map[string]string
OnComplete CompletionFunc
// contains filtered or unexported fields
}
PromptHandlerState holds the current state of the multi-step prompt process for a connection.
type PromptStep ¶
type PromptStep struct {
ID string // Unique identifier for this step's result
PromptTemplate string // Template name for the prompt message
GetDataFunc DataFunc // Function to generate template data dynamically (optional)
MaskInput bool // Should the input be masked?
MaskTemplate string // Template for the mask character (optional)
Validator ValidationFunc // Function to validate the input, if returns false, repeat prompt
Condition ConditionFunc // Do this step unless Condition Function returns false
FailureCount int // Can be added if needed, managed within PromptHandlerState
}
PromptStep defines a single step in a multi-step prompt process.
type SystemCommandHelp ¶
type ValidationFunc ¶
ValidationFunc defines a function type for validating user input for a step. It takes the raw input and the accumulated results so far. It returns the cleaned/validated value (or an empty string) and an error if validation fails.