This repository has been archived by the owner on Oct 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AbstractNetworkConnectionHandler.go
62 lines (52 loc) · 2.85 KB
/
AbstractNetworkConnectionHandler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package sshserver
import (
"context"
"fmt"
)
// AbstractNetworkConnectionHandler is an empty implementation for the NetworkConnectionHandler interface.
type AbstractNetworkConnectionHandler struct {
}
// OnAuthPassword is called when a user attempts a password authentication. The implementation must always supply
// AuthResponse and may supply error as a reason description.
func (a *AbstractNetworkConnectionHandler) OnAuthPassword(_ string, _ []byte, _ string) (response AuthResponse, metadata map[string]string, reason error) {
return AuthResponseUnavailable, nil, nil
}
// OnAuthPassword is called when a user attempts a pubkey authentication. The implementation must always supply
// AuthResponse and may supply error as a reason description. The pubKey parameter is an SSH key in
// the form of "ssh-rsa KEY HERE".
func (a *AbstractNetworkConnectionHandler) OnAuthPubKey(_ string, _ string, _ string) (response AuthResponse, metadata map[string]string, reason error) {
return AuthResponseUnavailable, nil, nil
}
// OnAuthKeyboardInteractive is a callback for interactive authentication. The implementer will be passed a callback
// function that can be used to issue challenges to the user. These challenges can, but do not have to contain
// questions.
func (a *AbstractNetworkConnectionHandler) OnAuthKeyboardInteractive(
_ string,
_ func(
instruction string,
questions KeyboardInteractiveQuestions,
) (answers KeyboardInteractiveAnswers, err error),
_ string,
) (response AuthResponse, metadata map[string]string, reason error) {
return AuthResponseUnavailable, nil, nil
}
// OnHandshakeFailed is called when the SSH handshake failed. This method is also called after an authentication
// failure. After this method is the connection will be closed and the OnDisconnect method will be
// called.
func (a *AbstractNetworkConnectionHandler) OnHandshakeFailed(_ error) {
}
// OnHandshakeSuccess is called when the SSH handshake was successful. It returns connection to process
// requests, or failureReason to indicate that a backend error has happened. In this case, the
// connection will be closed and OnDisconnect will be called.
func (a *AbstractNetworkConnectionHandler) OnHandshakeSuccess(_ string) (
connection SSHConnectionHandler, failureReason error,
) {
return nil, fmt.Errorf("not implemented")
}
// OnDisconnect is called when the network connection is closed.
func (a *AbstractNetworkConnectionHandler) OnDisconnect() {
}
// OnShutdown is called when a shutdown of the SSH server is desired. The shutdownContext is passed as a deadline
// for the shutdown, after which the server should abort all running connections and return as fast as
// possible.
func (a *AbstractNetworkConnectionHandler) OnShutdown(_ context.Context) {}