This repository has been archived by the owner on Oct 2, 2022. It is now read-only.
generated from ContainerSSH/library-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
handler_network.go
67 lines (57 loc) · 1.56 KB
/
handler_network.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
63
64
65
66
67
package security
import (
"context"
"sync"
"github.com/containerssh/log"
"github.com/containerssh/sshserver"
)
type networkHandler struct {
config Config
backend sshserver.NetworkConnectionHandler
logger log.Logger
}
func (n *networkHandler) OnAuthKeyboardInteractive(
user string,
challenge func(
instruction string,
questions sshserver.KeyboardInteractiveQuestions,
) (answers sshserver.KeyboardInteractiveAnswers, err error),
) (response sshserver.AuthResponse, reason error) {
return n.backend.OnAuthKeyboardInteractive(
user,
challenge,
)
}
func (n *networkHandler) OnShutdown(shutdownContext context.Context) {
n.backend.OnShutdown(shutdownContext)
}
func (n *networkHandler) OnAuthPassword(username string, password []byte) (
response sshserver.AuthResponse,
reason error,
) {
return n.backend.OnAuthPassword(username, password)
}
func (n *networkHandler) OnAuthPubKey(username string, pubKey string) (response sshserver.AuthResponse, reason error) {
return n.backend.OnAuthPubKey(username, pubKey)
}
func (n *networkHandler) OnHandshakeFailed(reason error) {
n.backend.OnHandshakeFailed(reason)
}
func (n *networkHandler) OnHandshakeSuccess(username string) (
connection sshserver.SSHConnectionHandler,
failureReason error,
) {
backend, failureReason := n.backend.OnHandshakeSuccess(username)
if failureReason != nil {
return nil, failureReason
}
return &sshConnectionHandler{
config: n.config,
backend: backend,
lock: &sync.Mutex{},
logger: n.logger,
}, nil
}
func (n *networkHandler) OnDisconnect() {
n.backend.OnDisconnect()
}