-
Notifications
You must be signed in to change notification settings - Fork 0
/
pattern_initandlisten.go
96 lines (88 loc) · 2.47 KB
/
pattern_initandlisten.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
package main
import (
"fmt"
"sync"
)
type Res_InitAndListen struct {
host string
port string
db_version string
storage_engine string
auth string
auth_type string
keyfile string
audit string
enterprise string
encrypted string
}
func (r *Res_InitAndListen) Init() {
r.host = "-"
r.port = "-"
r.db_version = "-"
r.storage_engine = "-"
r.auth = "-"
r.auth_type = "-"
r.keyfile = "-"
r.audit = "-"
r.enterprise = "-"
r.encrypted = "-"
}
func (r *Res_InitAndListen) String() string {
return fmt.Sprintf(`
host: %v
port: %v
db_version: %v
storage_engine: %v
auth: %v
auth_type: %v
keyfile: %v
encrypted: %v
enterprise: %v
audit: %v`,
r.host,
r.port,
r.db_version,
r.storage_engine,
r.auth,
r.auth_type,
r.keyfile,
r.encrypted,
r.enterprise,
r.audit,
)
}
var Matcher_host = RegexMatcher_string(`pid=.*port=\d+.*host=([^\s]+)`)
var Matcher_port = RegexMatcher_string(`pid=.*port=(\d+).*host=[^\s]+`)
var Matcher_storage_engine_1 = RegexMatcher_string(`options:.*storage:.*(wiredTiger|mmapv1)`)
var Matcher_storage_engine_2 = RegexMatcher_string(`(wiredtiger)_open config:`)
var Matcher_db_version = RegexMatcher_string(`db version v(\d{0,2}\.\d{0,2}\.\d{0,2})`)
var Matcher_keyfile = RegexMatcher_string(`options:.*keyFile:\ *"([^"]+)"`)
var Matcher_audit = RegexMatcher_string(`options:.*auditLog:\ *{\ *destination:\ *"([^"]+)"`)
var Matcher_enterprise = RegexMatcher_bool(`modules:\ *enterprise`)
var Matcher_encryption = RegexMatcher_bool(`options:.*enableEncryption:\ *true`)
func MatcherGroup_initandlisten(line <-chan string, result chan<- *Res_InitAndListen, wg_main *sync.WaitGroup) {
var res = new(Res_InitAndListen)
res.Init()
var Matchers_initandlisten = []MatcherType{
MatcherType{Matcher_host, &res.host},
MatcherType{Matcher_port, &res.port},
MatcherType{Matcher_storage_engine_1, &res.storage_engine},
MatcherType{Matcher_storage_engine_2, &res.storage_engine},
MatcherType{Matcher_db_version, &res.db_version},
MatcherType{Matcher_keyfile, &res.keyfile},
MatcherType{Matcher_audit, &res.audit},
MatcherType{Matcher_enterprise, &res.enterprise},
MatcherType{Matcher_encryption, &res.encrypted},
}
var wg sync.WaitGroup
wg.Add(1)
go RegexMatchers(Matchers_initandlisten, line, &wg)
wg.Wait()
result <- res
close(result)
if res.keyfile != "" {
res.auth = "true"
res.auth_type = "keyfile"
}
wg_main.Done()
}