forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
86 lines (69 loc) · 2.01 KB
/
client.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
package paths
import (
"context"
"fmt"
"path"
"www.velocidex.com/golang/velociraptor/file_store/api"
"www.velocidex.com/golang/velociraptor/utils"
)
type ClientPathManager struct {
path string
client_id string
}
func (self ClientPathManager) Path() string {
return self.path
}
func (self ClientPathManager) GetPathForWriting() (string, error) {
return self.path, nil
}
func (self ClientPathManager) GetQueueName() string {
return self.client_id
}
func (self ClientPathManager) GeneratePaths(ctx context.Context) <-chan *api.ResultSetFileProperties {
output := make(chan *api.ResultSetFileProperties)
go func() {
defer close(output)
output <- &api.ResultSetFileProperties{
Path: self.path,
EndTime: int64(1) << 62,
}
}()
return output
}
func NewClientPathManager(client_id string) *ClientPathManager {
return &ClientPathManager{
path: path.Join("/clients", client_id),
client_id: client_id,
}
}
// Gets the flow's log file.
func (self ClientPathManager) Ping() *ClientPathManager {
self.path = path.Join(self.path, "ping")
return &self
}
// Keep a record of all the client's labels.
func (self ClientPathManager) Labels() string {
return path.Join(self.path, "labels.json")
}
func (self ClientPathManager) Metadata() string {
return path.Join(self.path, "metadata.json")
}
func (self ClientPathManager) Key() *ClientPathManager {
self.path = path.Join(self.path, "key")
return &self
}
func (self ClientPathManager) TasksDirectory() *ClientPathManager {
self.path = path.Join(self.path, "tasks")
return &self
}
func (self ClientPathManager) Task(task_id uint64) *ClientPathManager {
self.path = path.Join(self.path, "tasks", fmt.Sprintf("%d", task_id))
return &self
}
func (self ClientPathManager) VFSPath(vfs_components []string) string {
return utils.JoinComponents(append([]string{
"clients", self.client_id, "vfs"}, vfs_components...), "/")
}
func (self ClientPathManager) VFSDownloadInfoPath(vfs string) string {
return path.Join("clients", self.client_id, "vfs_files", vfs)
}