bep.proto 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. syntax = "proto3";
  2. package bep;
  3. // --- Pre-auth ---
  4. message Hello {
  5. string device_name = 1;
  6. string client_name = 2;
  7. string client_version = 3;
  8. int32 num_connections = 4;
  9. int64 timestamp = 5;
  10. }
  11. // --- Header ---
  12. message Header {
  13. MessageType type = 1;
  14. MessageCompression compression = 2;
  15. }
  16. enum MessageType {
  17. MESSAGE_TYPE_CLUSTER_CONFIG = 0;
  18. MESSAGE_TYPE_INDEX = 1;
  19. MESSAGE_TYPE_INDEX_UPDATE = 2;
  20. MESSAGE_TYPE_REQUEST = 3;
  21. MESSAGE_TYPE_RESPONSE = 4;
  22. MESSAGE_TYPE_DOWNLOAD_PROGRESS = 5;
  23. MESSAGE_TYPE_PING = 6;
  24. MESSAGE_TYPE_CLOSE = 7;
  25. }
  26. enum MessageCompression {
  27. MESSAGE_COMPRESSION_NONE = 0;
  28. MESSAGE_COMPRESSION_LZ4 = 1;
  29. }
  30. // --- Actual messages ---
  31. // Cluster Config
  32. message ClusterConfig {
  33. repeated Folder folders = 1;
  34. bool secondary = 2;
  35. }
  36. message Folder {
  37. string id = 1;
  38. string label = 2;
  39. bool read_only = 3;
  40. bool ignore_permissions = 4;
  41. bool ignore_delete = 5;
  42. bool disable_temp_indexes = 6;
  43. bool paused = 7;
  44. repeated Device devices = 16;
  45. }
  46. message Device {
  47. bytes id = 1;
  48. string name = 2;
  49. repeated string addresses = 3;
  50. Compression compression = 4;
  51. string cert_name = 5;
  52. int64 max_sequence = 6;
  53. bool introducer = 7;
  54. uint64 index_id = 8;
  55. bool skip_introduction_removals = 9;
  56. bytes encryption_password_token = 10;
  57. }
  58. enum Compression {
  59. COMPRESSION_METADATA = 0;
  60. COMPRESSION_NEVER = 1;
  61. COMPRESSION_ALWAYS = 2;
  62. }
  63. // Index and Index Update
  64. message Index {
  65. string folder = 1;
  66. repeated FileInfo files = 2;
  67. int64 last_sequence = 3; // the highest sequence in this batch
  68. }
  69. message IndexUpdate {
  70. string folder = 1;
  71. repeated FileInfo files = 2;
  72. int64 last_sequence = 3; // the highest sequence in this batch
  73. int64 prev_sequence = 4; // the highest sequence in the previous batch
  74. }
  75. message FileInfo {
  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;
  82. Vector version = 9;
  83. int64 sequence = 10;
  84. repeated BlockInfo blocks = 16;
  85. bytes 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;
  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;
  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. bytes hash = 3;
  120. int64 offset = 1;
  121. int32 size = 2;
  122. uint32 weak_hash = 4;
  123. }
  124. message Vector {
  125. repeated Counter counters = 1;
  126. }
  127. message Counter {
  128. uint64 id = 1;
  129. uint64 value = 2;
  130. }
  131. message PlatformData {
  132. UnixData unix = 1;
  133. WindowsData windows = 2;
  134. XattrData linux = 3;
  135. XattrData darwin = 4;
  136. XattrData freebsd = 5;
  137. XattrData netbsd = 6;
  138. }
  139. message UnixData {
  140. // The owner name and group name are set when known (i.e., could be
  141. // resolved on the source device), while the UID and GID are always set
  142. // as they come directly from the stat() call.
  143. string owner_name = 1;
  144. string group_name = 2;
  145. int32 uid = 3;
  146. int32 gid = 4;
  147. }
  148. message WindowsData {
  149. // Windows file objects have a single owner, which may be a user or a
  150. // group. We keep the name of that account, and a flag to indicate what
  151. // type it is.
  152. string owner_name = 1;
  153. bool owner_is_group = 2;
  154. }
  155. message XattrData {
  156. repeated Xattr xattrs = 1;
  157. }
  158. message Xattr {
  159. string name = 1;
  160. bytes value = 2;
  161. }
  162. // Request
  163. message Request {
  164. int32 id = 1;
  165. string folder = 2;
  166. string name = 3;
  167. int64 offset = 4;
  168. int32 size = 5;
  169. bytes hash = 6;
  170. bool from_temporary = 7;
  171. uint32 weak_hash = 8;
  172. int32 block_no = 9;
  173. }
  174. // Response
  175. message Response {
  176. int32 id = 1;
  177. bytes data = 2;
  178. ErrorCode code = 3;
  179. }
  180. enum ErrorCode {
  181. ERROR_CODE_NO_ERROR = 0;
  182. ERROR_CODE_GENERIC = 1;
  183. ERROR_CODE_NO_SUCH_FILE = 2;
  184. ERROR_CODE_INVALID_FILE = 3;
  185. }
  186. // DownloadProgress
  187. message DownloadProgress {
  188. string folder = 1;
  189. repeated FileDownloadProgressUpdate updates = 2;
  190. }
  191. message FileDownloadProgressUpdate {
  192. FileDownloadProgressUpdateType update_type = 1;
  193. string name = 2;
  194. Vector version = 3;
  195. repeated int32 block_indexes = 4 [packed = false];
  196. int32 block_size = 5;
  197. }
  198. enum FileDownloadProgressUpdateType {
  199. FILE_DOWNLOAD_PROGRESS_UPDATE_TYPE_APPEND = 0;
  200. FILE_DOWNLOAD_PROGRESS_UPDATE_TYPE_FORGET = 1;
  201. }
  202. // Ping
  203. message Ping {}
  204. // Close
  205. message Close {
  206. string reason = 1;
  207. }