forked from gaulliath/operative-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
session_stream.go
69 lines (57 loc) · 1.71 KB
/
session_stream.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
package session_stream
import (
"github.com/Oni-kuki/operative-framework/session"
)
type SessionStreamModule struct {
session.SessionModule
sess *session.Session `json:"-"`
Stream *session.Stream `json:"-"`
}
func PushSessionStreamModule(s *session.Session) *SessionStreamModule {
mod := SessionStreamModule{
sess: s,
Stream: &s.Stream,
}
mod.CreateNewParam("VERBOSE", "Change Verbosity (true/false)", mod.sess.BooleanToString(mod.Stream.Verbose), false, session.BOOL)
mod.CreateNewParam("CSV", "Print a response with CSV format", mod.sess.BooleanToString(mod.Stream.CSV), false, session.BOOL)
return &mod
}
func (module *SessionStreamModule) Name() string {
return "session_stream"
}
func (module *SessionStreamModule) Description() string {
return "Set a session event stream settings"
}
func (module *SessionStreamModule) Author() string {
return "Tristan Granier"
}
func (module *SessionStreamModule) GetType() []string {
return []string{
session.T_TARGET_SESSION,
}
}
func (module *SessionStreamModule) GetInformation() session.ModuleInformation {
information := session.ModuleInformation{
Name: module.Name(),
Description: module.Description(),
Author: module.Author(),
Type: module.GetType(),
Parameters: module.Parameters,
}
return information
}
func (module *SessionStreamModule) Start() {
paramVerbosity, err := module.GetParameter("VERBOSE")
if err != nil {
module.Stream.Error(err.Error())
return
}
paramCSV, err := module.GetParameter("CSV")
if err != nil {
module.Stream.Error(err.Error())
return
}
module.Stream.Verbose = module.sess.StringToBoolean(paramVerbosity.Value)
module.Stream.CSV = module.sess.StringToBoolean(paramCSV.Value)
return
}