MCPcopy
hub / github.com/wavetermdev/waveterm / createInteractiveKbdInteractiveChallenge

Function createInteractiveKbdInteractiveChallenge

pkg/remote/sshclient.go:422–443  ·  view source on GitHub ↗
(connCtx context.Context, remoteName string, debugInfo *ConnectionDebugInfo)

Source from the content-addressed store, hash-verified

420}
421
422func createInteractiveKbdInteractiveChallenge(connCtx context.Context, remoteName string, debugInfo *ConnectionDebugInfo) func(name, instruction string, questions []string, echos []bool) (answers []string, err error) {
423 return func(name, instruction string, questions []string, echos []bool) (answers []string, outErr error) {
424 defer func() {
425 panicErr := panichandler.PanicHandler("sshclient:kbdinteractive-callback", recover())
426 if panicErr != nil {
427 outErr = panicErr
428 }
429 }()
430 if len(questions) != len(echos) {
431 return nil, fmt.Errorf("bad response from server: questions has len %d, echos has len %d", len(questions), len(echos))
432 }
433 for i, question := range questions {
434 echo := echos[i]
435 answer, err := promptChallengeQuestion(connCtx, question, echo, remoteName)
436 if err != nil {
437 return nil, ConnectionError{ConnectionDebugInfo: debugInfo, Err: utilds.MakeCodedError(ConnErrCode_UserCancelled, err)}
438 }
439 answers = append(answers, answer)
440 }
441 return answers, nil
442 }
443}
444
445func promptChallengeQuestion(connCtx context.Context, question string, echo bool, remoteName string) (answer string, err error) {
446 // limited to 15 seconds for some reason. this should be investigated more

Callers 1

createClientConfigFunction · 0.85

Calls 3

PanicHandlerFunction · 0.92
MakeCodedErrorFunction · 0.92
promptChallengeQuestionFunction · 0.85

Tested by

no test coverage detected