bep.proto 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. syntax = "proto3";
  2. package protocol;
  3. import "ext.proto";
  4. import "repos/protobuf/gogoproto/gogo.proto";
  5. // --- Pre-auth ---
  6. message Hello {
  7. string device_name = 1;
  8. string client_name = 2;
  9. string client_version = 3;
  10. int32 num_connections = 4;
  11. int64 timestamp = 5;
  12. }
  13. // --- Header ---
  14. message Header {
  15. MessageType type = 1;
  16. MessageCompression compression = 2;
  17. }
  18. enum MessageType {
  19. MESSAGE_TYPE_CLUSTER_CONFIG = 0;
  20. MESSAGE_TYPE_INDEX = 1;
  21. MESSAGE_TYPE_INDEX_UPDATE = 2;
  22. MESSAGE_TYPE_REQUEST = 3;
  23. MESSAGE_TYPE_RESPONSE = 4;
  24. MESSAGE_TYPE_DOWNLOAD_PROGRESS = 5;
  25. MESSAGE_TYPE_PING = 6;
  26. MESSAGE_TYPE_CLOSE = 7;
  27. }
  28. enum MessageCompression {
  29. MESSAGE_COMPRESSION_NONE = 0;
  30. MESSAGE_COMPRESSION_LZ4 = 1 [(ext.enumgoname) = "MessageCompressionLZ4"];
  31. }
  32. // --- Actual messages ---
  33. // Cluster Config
  34. message ClusterConfig {
  35. repeated Folder folders = 1;
  36. bool secondary = 2;
  37. }
  38. message Folder {
  39. string id = 1 [(ext.goname) = "ID"];
  40. string label = 2;
  41. bool read_only = 3;
  42. bool ignore_permissions = 4;
  43. bool ignore_delete = 5;
  44. bool disable_temp_indexes = 6;
  45. bool paused = 7;
  46. repeated Device devices = 16;
  47. }
  48. message Device {
  49. bytes id = 1 [(ext.goname) = "ID", (ext.device_id) = true];
  50. string name = 2;
  51. repeated string addresses = 3;
  52. Compression compression = 4;
  53. string cert_name = 5;
  54. int64 max_sequence = 6;
  55. bool introducer = 7;
  56. uint64 index_id = 8 [(ext.goname) = "IndexID", (ext.gotype) = "IndexID"];
  57. bool skip_introduction_removals = 9;
  58. bytes encryption_password_token = 10;
  59. }
  60. enum Compression {
  61. COMPRESSION_METADATA = 0;
  62. COMPRESSION_NEVER = 1;
  63. COMPRESSION_ALWAYS = 2;
  64. }
  65. // Index and Index Update
  66. message Index {
  67. string folder = 1;
  68. repeated FileInfo files = 2;
  69. }
  70. message IndexUpdate {
  71. string folder = 1;
  72. repeated FileInfo files = 2;
  73. }
  74. message FileInfo {
  75. option (gogoproto.goproto_stringer) = false;
  76. // The field ordering here optimizes for struct size / alignment --
  77. // large types come before smaller ones.
  78. string name = 1;
  79. int64 size = 3;
  80. int64 modified_s = 5;
  81. uint64 modified_by = 12 [(ext.gotype) = "ShortID"];
  82. Vector version = 9;
  83. int64 sequence = 10;
  84. repeated BlockInfo blocks = 16;
  85. string symlink_target = 17;
  86. bytes blocks_hash = 18;
  87. bytes encrypted = 19;
  88. FileInfoType type = 2;
  89. uint32 permissions = 4;
  90. int32 modified_ns = 11;
  91. int32 block_size = 13 [(ext.goname) = "RawBlockSize"];
  92. PlatformData platform = 14;
  93. // The local_flags fields stores flags that are relevant to the local
  94. // host only. It is not part of the protocol, doesn't get sent or
  95. // received (we make sure to zero it), nonetheless we need it on our
  96. // struct and to be able to serialize it to/from the database.
  97. uint32 local_flags = 1000;
  98. // The version_hash is an implementation detail and not part of the wire
  99. // format.
  100. bytes version_hash = 1001;
  101. // The time when the inode was last changed (i.e., permissions, xattrs
  102. // etc changed). This is host-local, not sent over the wire.
  103. int64 inode_change_ns = 1002;
  104. // The size of the data appended to the encrypted file on disk. This is
  105. // host-local, not sent over the wire.
  106. int32 encryption_trailer_size = 1003;
  107. bool deleted = 6;
  108. bool invalid = 7 [(ext.goname) = "RawInvalid"];
  109. bool no_permissions = 8;
  110. }
  111. enum FileInfoType {
  112. FILE_INFO_TYPE_FILE = 0;
  113. FILE_INFO_TYPE_DIRECTORY = 1;
  114. FILE_INFO_TYPE_SYMLINK_FILE = 2 [deprecated = true];
  115. FILE_INFO_TYPE_SYMLINK_DIRECTORY = 3 [deprecated = true];
  116. FILE_INFO_TYPE_SYMLINK = 4;
  117. }
  118. message BlockInfo {
  119. option (gogoproto.goproto_stringer) = false;
  120. bytes hash = 3;
  121. int64 offset = 1;
  122. int32 size = 2;
  123. uint32 weak_hash = 4;
  124. }
  125. message Vector {
  126. repeated Counter counters = 1;
  127. }
  128. message Counter {
  129. uint64 id = 1 [(ext.goname) = "ID", (ext.gotype) = "ShortID"];
  130. uint64 value = 2;
  131. }
  132. message PlatformData {
  133. UnixData unix = 1 [(gogoproto.nullable) = true];
  134. WindowsData windows = 2 [(gogoproto.nullable) = true];
  135. XattrData linux = 3 [(gogoproto.nullable) = true];
  136. XattrData darwin = 4 [(gogoproto.nullable) = true];
  137. XattrData freebsd = 5 [(gogoproto.nullable) = true, (ext.goname) = "FreeBSD"];
  138. XattrData netbsd = 6 [(gogoproto.nullable) = true, (ext.goname) = "NetBSD"];
  139. }
  140. message UnixData {
  141. // The owner name and group name are set when known (i.e., could be
  142. // resolved on the source device), while the UID and GID are always set
  143. // as they come directly from the stat() call.
  144. string owner_name = 1;
  145. string group_name = 2;
  146. int32 uid = 3 [(ext.goname) = "UID"];
  147. int32 gid = 4 [(ext.goname) = "GID"];
  148. }
  149. message WindowsData {
  150. // Windows file objects have a single owner, which may be a user or a
  151. // group. We keep the name of that account, and a flag to indicate what
  152. // type it is.
  153. string owner_name = 1;
  154. bool owner_is_group = 2;
  155. }
  156. message XattrData {
  157. repeated Xattr xattrs = 1;
  158. }
  159. message Xattr {
  160. string name = 1;
  161. bytes value = 2;
  162. }
  163. // Request
  164. message Request {
  165. int32 id = 1 [(ext.goname) = "ID"];
  166. string folder = 2;
  167. string name = 3;
  168. int64 offset = 4;
  169. int32 size = 5;
  170. bytes hash = 6;
  171. bool from_temporary = 7;
  172. uint32 weak_hash = 8;
  173. int32 block_no = 9;
  174. }
  175. // Response
  176. message Response {
  177. int32 id = 1 [(ext.goname) = "ID"];
  178. bytes data = 2;
  179. ErrorCode code = 3;
  180. }
  181. enum ErrorCode {
  182. ERROR_CODE_NO_ERROR = 0;
  183. ERROR_CODE_GENERIC = 1;
  184. ERROR_CODE_NO_SUCH_FILE = 2;
  185. ERROR_CODE_INVALID_FILE = 3;
  186. }
  187. // DownloadProgress
  188. message DownloadProgress {
  189. string folder = 1;
  190. repeated FileDownloadProgressUpdate updates = 2;
  191. }
  192. message FileDownloadProgressUpdate {
  193. FileDownloadProgressUpdateType update_type = 1;
  194. string name = 2;
  195. Vector version = 3;
  196. repeated int32 block_indexes = 4 [packed=false];
  197. int32 block_size = 5;
  198. }
  199. enum FileDownloadProgressUpdateType {
  200. FILE_DOWNLOAD_PROGRESS_UPDATE_TYPE_APPEND = 0;
  201. FILE_DOWNLOAD_PROGRESS_UPDATE_TYPE_FORGET = 1;
  202. }
  203. // Ping
  204. message Ping {
  205. }
  206. // Close
  207. message Close {
  208. string reason = 1;
  209. }