forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.go
62 lines (53 loc) · 1.48 KB
/
api.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
// Uploaders deliver files from accessors to the server (or another target).
package uploads
import (
"context"
"io"
"os"
"time"
"www.velocidex.com/golang/velociraptor/accessors"
"www.velocidex.com/golang/vfilter"
)
// Returned as the result of the query.
type UploadResponse struct {
Path string `json:"Path"`
Size uint64 `json:"Size"`
StoredSize uint64 `json:"StoredSize,omitempty"`
Error string `json:"Error,omitempty"`
Sha256 string `json:"sha256,omitempty"`
Md5 string `json:"md5,omitempty"`
StoredName string `json:"StoredName,omitempty"`
Reference string `json:"Reference,omitempty"`
Components []string `json:"Components,omitempty"`
Accessor string `json:"Accessor,omitempty"`
// The type of upload this is (Currently "idx" is an index file)
Type string `json:"Type,omitempty"`
}
// Provide an uploader capable of uploading any reader object.
type Uploader interface {
Upload(ctx context.Context,
scope vfilter.Scope,
filename *accessors.OSPath,
accessor string,
store_as_name *accessors.OSPath,
expected_size int64,
mtime time.Time,
atime time.Time,
ctime time.Time,
btime time.Time,
mode os.FileMode,
reader io.Reader) (*UploadResponse, error)
}
// A generic interface for reporting file ranges. Implementations will
// convert to this common form.
type Range struct {
// In bytes
Offset int64
Length int64
IsSparse bool
}
type RangeReader interface {
io.Reader
io.Seeker
Ranges() []Range
}