-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Expand file tree
/
Copy pathbep.proto
More file actions
262 lines (214 loc) · 5.38 KB
/
Copy pathbep.proto
File metadata and controls
262 lines (214 loc) · 5.38 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
syntax = "proto3";
package bep;
// --- Pre-auth ---
message Hello {
string device_name = 1;
string client_name = 2;
string client_version = 3;
int32 num_connections = 4;
int64 timestamp = 5;
}
// --- Header ---
message Header {
MessageType type = 1;
MessageCompression compression = 2;
}
enum MessageType {
MESSAGE_TYPE_CLUSTER_CONFIG = 0;
MESSAGE_TYPE_INDEX = 1;
MESSAGE_TYPE_INDEX_UPDATE = 2;
MESSAGE_TYPE_REQUEST = 3;
MESSAGE_TYPE_RESPONSE = 4;
MESSAGE_TYPE_DOWNLOAD_PROGRESS = 5;
MESSAGE_TYPE_PING = 6;
MESSAGE_TYPE_CLOSE = 7;
}
enum MessageCompression {
MESSAGE_COMPRESSION_NONE = 0;
MESSAGE_COMPRESSION_LZ4 = 1;
}
// --- Actual messages ---
// Cluster Config
message ClusterConfig {
repeated Folder folders = 1;
bool secondary = 2;
}
message Folder {
string id = 1;
string label = 2;
FolderType type = 3;
FolderStopReason stop_reason = 7;
reserved 4 to 6;
repeated Device devices = 16;
}
message Device {
bytes id = 1;
string name = 2;
repeated string addresses = 3;
Compression compression = 4;
string cert_name = 5;
int64 max_sequence = 6;
bool introducer = 7;
uint64 index_id = 8;
bool skip_introduction_removals = 9;
bytes encryption_password_token = 10;
}
enum Compression {
COMPRESSION_METADATA = 0;
COMPRESSION_NEVER = 1;
COMPRESSION_ALWAYS = 2;
}
enum FolderType {
FOLDER_TYPE_SEND_RECEIVE = 0;
FOLDER_TYPE_SEND_ONLY = 1;
FOLDER_TYPE_RECEIVE_ONLY = 2;
FOLDER_TYPE_RECEIVE_ENCRYPTED = 3;
}
enum FolderStopReason {
FOLDER_STOP_REASON_RUNNING = 0; // i.e., not stopped
FOLDER_STOP_REASON_PAUSED = 1;
}
// Index and Index Update
message Index {
string folder = 1;
repeated FileInfo files = 2;
int64 last_sequence = 3; // the highest sequence in this batch
}
message IndexUpdate {
string folder = 1;
repeated FileInfo files = 2;
int64 last_sequence = 3; // the highest sequence in this batch
int64 prev_sequence = 4; // the highest sequence in the previous batch
}
message FileInfo {
// The field ordering here optimizes for struct size / alignment --
// large types come before smaller ones.
string name = 1;
int64 size = 3;
int64 modified_s = 5;
uint64 modified_by = 12;
Vector version = 9;
int64 sequence = 10;
repeated BlockInfo blocks = 16;
bytes symlink_target = 17;
bytes blocks_hash = 18;
bytes previous_blocks_hash = 20;
bytes encrypted = 19;
FileInfoType type = 2;
uint32 permissions = 4;
int32 modified_ns = 11;
int32 block_size = 13;
PlatformData platform = 14;
// The local_flags fields stores flags that are relevant to the local
// host only. It is not part of the protocol, doesn't get sent or
// received (we make sure to zero it), nonetheless we need it on our
// struct and to be able to serialize it to/from the database.
uint32 local_flags = 1000;
// The version_hash is an implementation detail and not part of the wire
// format. It is used in the old database format.
bytes version_hash = 1001;
// The size of the data appended to the encrypted file on disk. This is
// host-local, not sent over the wire.
int32 encryption_trailer_size = 1003;
bool deleted = 6;
bool invalid = 7;
bool no_permissions = 8;
reserved 1002; // previously inode change time
}
enum FileInfoType {
FILE_INFO_TYPE_FILE = 0;
FILE_INFO_TYPE_DIRECTORY = 1;
FILE_INFO_TYPE_SYMLINK_FILE = 2 [deprecated = true];
FILE_INFO_TYPE_SYMLINK_DIRECTORY = 3 [deprecated = true];
FILE_INFO_TYPE_SYMLINK = 4;
}
message BlockInfo {
bytes hash = 3;
int64 offset = 1;
int32 size = 2;
reserved 4;
}
message Vector {
repeated Counter counters = 1;
}
message Counter {
uint64 id = 1;
uint64 value = 2;
}
message PlatformData {
UnixData unix = 1;
WindowsData windows = 2;
XattrData linux = 3;
XattrData darwin = 4;
XattrData freebsd = 5;
XattrData netbsd = 6;
}
message UnixData {
// The owner name and group name are set when known (i.e., could be
// resolved on the source device), while the UID and GID are always set
// as they come directly from the stat() call.
string owner_name = 1;
string group_name = 2;
int32 uid = 3;
int32 gid = 4;
}
message WindowsData {
// Windows file objects have a single owner, which may be a user or a
// group. We keep the name of that account, and a flag to indicate what
// type it is.
string owner_name = 1;
bool owner_is_group = 2;
}
message XattrData {
repeated Xattr xattrs = 1;
}
message Xattr {
string name = 1;
bytes value = 2;
}
// Request
message Request {
int32 id = 1;
string folder = 2;
string name = 3;
int64 offset = 4;
int32 size = 5;
bytes hash = 6;
bool from_temporary = 7;
int32 block_no = 9;
reserved 8;
}
// Response
message Response {
int32 id = 1;
bytes data = 2;
ErrorCode code = 3;
}
enum ErrorCode {
ERROR_CODE_NO_ERROR = 0;
ERROR_CODE_GENERIC = 1;
ERROR_CODE_NO_SUCH_FILE = 2;
ERROR_CODE_INVALID_FILE = 3;
}
// DownloadProgress
message DownloadProgress {
string folder = 1;
repeated FileDownloadProgressUpdate updates = 2;
}
message FileDownloadProgressUpdate {
FileDownloadProgressUpdateType update_type = 1;
string name = 2;
Vector version = 3;
repeated int32 block_indexes = 4 [packed = false];
int32 block_size = 5;
}
enum FileDownloadProgressUpdateType {
FILE_DOWNLOAD_PROGRESS_UPDATE_TYPE_APPEND = 0;
FILE_DOWNLOAD_PROGRESS_UPDATE_TYPE_FORGET = 1;
}
// Ping
message Ping {}
// Close
message Close {
string reason = 1;
}