forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats.go
45 lines (39 loc) · 1.31 KB
/
stats.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
package executor
import (
"context"
"errors"
config_proto "www.velocidex.com/golang/velociraptor/config/proto"
"www.velocidex.com/golang/velociraptor/constants"
crypto_proto "www.velocidex.com/golang/velociraptor/crypto/proto"
"www.velocidex.com/golang/velociraptor/utils"
)
// This request asks the client to report progress on all currently
// running flows. This is needed for the server to identify when a
// client has restarted or crashed and reap any flows that are still
// outstanding.
func (self *ClientExecutor) ProcessStatRequest(
ctx context.Context,
config_obj *config_proto.Config, req *crypto_proto.VeloMessage) {
for _, flow_id := range req.FlowStatsRequest.FlowId {
flow_context, err := self.flow_manager.Get(flow_id)
var stats *crypto_proto.VeloMessage
if errors.Is(err, utils.NotFoundError) {
stats = &crypto_proto.VeloMessage{
SessionId: flow_id,
RequestId: constants.STATS_SINK,
FlowStats: &crypto_proto.FlowStats{
FlowComplete: true,
QueryStatus: []*crypto_proto.VeloStatus{{
Status: crypto_proto.VeloStatus_GENERIC_ERROR,
ErrorMessage: "Flow not known - maybe the client crashed?",
}},
},
}
} else {
stats = flow_context.GetStats()
}
// Make sure responses get there immediately.
stats.Urgent = true
self.SendToServer(stats)
}
}