-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery_engine.go
52 lines (43 loc) · 929 Bytes
/
query_engine.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
package savdi
import (
"bufio"
"fmt"
"strconv"
"strings"
)
// EngineInfo contains data from QUERY ENGINE
type EngineInfo struct {
EngineVersion string
SAVVersion string
VirusCount int
VirusDataChecksum string
}
// QueryEngine queries the SAVI engine for configuration
func (c *Client) QueryEngine() (info EngineInfo, err error) {
_, err = fmt.Fprintln(c.Socket, fmt.Sprintf("%s QUERY ENGINE", c.Version))
if err != nil {
return info, err
}
scanner := bufio.NewScanner(c.Socket)
for scanner.Scan() {
line := scanner.Text()
kv := strings.Split(line, ": ")
if len(kv) != 2 {
break
}
k, v := kv[0], kv[1]
switch k {
case "engineversion":
info.EngineVersion = v
case "savversion":
info.SAVVersion = v
case "viruscount":
info.VirusCount, _ = strconv.Atoi(v)
case "virusdatachecksum":
info.VirusDataChecksum = v
case "":
break
}
}
return info, nil
}