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 0
/
Copy pathhandler_sessionchannel.go
126 lines (111 loc) · 3.06 KB
/
handler_sessionchannel.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package auditlogintegration
import (
"context"
"github.com/containerssh/auditlog"
"github.com/containerssh/sshserver"
)
type sessionChannelHandler struct {
backend sshserver.SessionChannelHandler
audit auditlog.Channel
session sshserver.SessionChannel
}
func (s *sessionChannelHandler) OnClose() {
s.audit.OnClose()
s.backend.OnClose()
}
func (s *sessionChannelHandler) OnShutdown(shutdownContext context.Context) {
s.backend.OnShutdown(shutdownContext)
}
func (s *sessionChannelHandler) OnUnsupportedChannelRequest(requestID uint64, requestType string, payload []byte) {
s.backend.OnUnsupportedChannelRequest(requestID, requestType, payload)
s.audit.OnRequestUnknown(requestID, requestType, payload)
}
func (s *sessionChannelHandler) OnFailedDecodeChannelRequest(requestID uint64, requestType string, payload []byte, reason error) {
s.backend.OnFailedDecodeChannelRequest(requestID, requestType, payload, reason)
s.audit.OnRequestDecodeFailed(requestID, requestType, payload, reason.Error())
}
func (s *sessionChannelHandler) OnEnvRequest(requestID uint64, name string, value string) error {
s.audit.OnRequestSetEnv(requestID, name, value)
if err := s.backend.OnEnvRequest(requestID, name, value); err != nil {
s.audit.OnRequestFailed(requestID, err)
return err
}
return nil
}
func (s *sessionChannelHandler) OnExecRequest(
requestID uint64,
program string,
) error {
s.audit.OnRequestExec(requestID, program)
if err := s.backend.OnExecRequest(
requestID,
program,
); err != nil {
return err
}
return nil
}
func (s *sessionChannelHandler) OnPtyRequest(
requestID uint64,
term string,
columns uint32,
rows uint32,
width uint32,
height uint32,
modeList []byte,
) error {
s.audit.OnRequestPty(requestID, term, columns, rows, width, height, modeList)
if err := s.backend.OnPtyRequest(requestID, term, columns, rows, width, height, modeList); err != nil {
s.audit.OnRequestFailed(requestID, err)
return err
}
return nil
}
func (s *sessionChannelHandler) OnShell(
requestID uint64,
) error {
s.audit.OnRequestShell(requestID)
if err := s.backend.OnShell(
requestID,
); err != nil {
s.audit.OnRequestFailed(requestID, err)
return err
}
return nil
}
func (s *sessionChannelHandler) OnSignal(requestID uint64, signal string) error {
s.audit.OnRequestSignal(requestID, signal)
if err := s.backend.OnSignal(requestID, signal); err != nil {
s.audit.OnRequestFailed(requestID, err)
return err
}
return nil
}
func (s *sessionChannelHandler) OnSubsystem(
requestID uint64,
subsystem string,
) error {
s.audit.OnRequestSubsystem(requestID, subsystem)
if err := s.backend.OnSubsystem(
requestID,
subsystem,
); err != nil {
s.audit.OnRequestFailed(requestID, err)
return err
}
return nil
}
func (s *sessionChannelHandler) OnWindow(
requestID uint64,
columns uint32,
rows uint32,
width uint32,
height uint32,
) error {
s.audit.OnRequestWindow(requestID, columns, rows, width, height)
if err := s.backend.OnWindow(requestID, columns, rows, width, height); err != nil {
s.audit.OnRequestFailed(requestID, err)
return err
}
return nil
}