bep.proto 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. FolderType type = 3;
  40. FolderStopReason stop_reason = 7;
  41. reserved 4 to 6;
  42. repeated Device devices = 16;
  43. }
  44. message Device {
  45. bytes id = 1;
  46. string name = 2;
  47. repeated string addresses = 3;
  48. Compression compression = 4;
  49. string cert_name = 5;
  50. int64 max_sequence = 6;
  51. bool introducer = 7;
  52. uint64 index_id = 8;
  53. bool skip_introduction_removals = 9;
  54. bytes encryption_password_token = 10;
  55. }
  56. enum Compression {
  57. COMPRESSION_METADATA = 0;
  58. COMPRESSION_NEVER = 1;
  59. COMPRESSION_ALWAYS = 2;
  60. }
  61. enum FolderType {
  62. FOLDER_TYPE_SEND_RECEIVE = 0;
  63. FOLDER_TYPE_SEND_ONLY = 1;
  64. FOLDER_TYPE_RECEIVE_ONLY = 2;
  65. FOLDER_TYPE_RECEIVE_ENCRYPTED = 3;
  66. }
  67. enum FolderStopReason {
  68. FOLDER_STOP_REASON_RUNNING = 0; // i.e., not stopped
  69. FOLDER_STOP_REASON_PAUSED = 1;
  70. }
  71. // Index and Index Update
  72. message Index {
  73. string folder = 1;
  74. repeated FileInfo files = 2;
  75. int64 last_sequence = 3; // the highest sequence in this batch
  76. }
  77. message IndexUpdate {
  78. string folder = 1;
  79. repeated FileInfo files = 2;
  80. int64 last_sequence = 3; // the highest sequence in this batch
  81. int64 prev_sequence = 4; // the highest sequence in the previous batch
  82. }
  83. message FileInfo {
  84. // The field ordering here optimizes for struct size / alignment --
  85. // large types come before smaller ones.
  86. string name = 1;
  87. int64 size = 3;
  88. int64 modified_s = 5;
  89. uint64 modified_by = 12;
  90. Vector version = 9;
  91. int64 sequence = 10;
  92. repeated BlockInfo blocks = 16;
  93. bytes symlink_target = 17;
  94. bytes blocks_hash = 18;
  95. bytes previous_blocks_hash = 20;
  96. bytes encrypted = 19;
  97. FileInfoType type = 2;
  98. uint32 permissions = 4;
  99. int32 modified_ns = 11;
  100. int32 block_size = 13;
  101. PlatformData platform = 14;
  102. // The local_flags fields stores flags that are relevant to the local
  103. // host only. It is not part of the protocol, doesn't get sent or
  104. // received (we make sure to zero it), nonetheless we need it on our
  105. // struct and to be able to serialize it to/from the database.
  106. uint32 local_flags = 1000;
  107. // The version_hash is an implementation detail and not part of the wire
  108. // format. It is used in the old database format.
  109. bytes version_hash = 1001;
  110. // The time when the inode was last changed (i.e., permissions, xattrs
  111. // etc changed). This is host-local, not sent over the wire.
  112. int64 inode_change_ns = 1002;
  113. // The size of the data appended to the encrypted file on disk. This is
  114. // host-local, not sent over the wire.
  115. int32 encryption_trailer_size = 1003;
  116. bool deleted = 6;
  117. bool invalid = 7;
  118. bool no_permissions = 8;
  119. }
  120. enum FileInfoType {
  121. FILE_INFO_TYPE_FILE = 0;
  122. FILE_INFO_TYPE_DIRECTORY = 1;
  123. FILE_INFO_TYPE_SYMLINK_FILE = 2 [deprecated = true];
  124. FILE_INFO_TYPE_SYMLINK_DIRECTORY = 3 [deprecated = true];
  125. FILE_INFO_TYPE_SYMLINK = 4;
  126. }
  127. message BlockInfo {
  128. bytes hash = 3;
  129. int64 offset = 1;
  130. int32 size = 2;
  131. reserved 4;
  132. }
  133. message Vector {
  134. repeated Counter counters = 1;
  135. }
  136. message Counter {
  137. uint64 id = 1;
  138. uint64 value = 2;
  139. }
  140. message PlatformData {
  141. UnixData unix = 1;
  142. WindowsData windows = 2;
  143. XattrData linux = 3;
  144. XattrData darwin = 4;
  145. XattrData freebsd = 5;
  146. XattrData netbsd = 6;
  147. }
  148. message UnixData {
  149. // The owner name and group name are set when known (i.e., could be
  150. // resolved on the source device), while the UID and GID are always set
  151. // as they come directly from the stat() call.
  152. string owner_name = 1;
  153. string group_name = 2;
  154. int32 uid = 3;
  155. int32 gid = 4;
  156. }
  157. message WindowsData {
  158. // Windows file objects have a single owner, which may be a user or a
  159. // group. We keep the name of that account, and a flag to indicate what
  160. // type it is.
  161. string owner_name = 1;
  162. bool owner_is_group = 2;
  163. }
  164. message XattrData {
  165. repeated Xattr xattrs = 1;
  166. }
  167. message Xattr {
  168. string name = 1;
  169. bytes value = 2;
  170. }
  171. // Request
  172. message Request {
  173. int32 id = 1;
  174. string folder = 2;
  175. string name = 3;
  176. int64 offset = 4;
  177. int32 size = 5;
  178. bytes hash = 6;
  179. bool from_temporary = 7;
  180. int32 block_no = 9;
  181. reserved 8;
  182. }
  183. // Response
  184. message Response {
  185. int32 id = 1;
  186. bytes data = 2;
  187. ErrorCode code = 3;
  188. }
  189. enum ErrorCode {
  190. ERROR_CODE_NO_ERROR = 0;
  191. ERROR_CODE_GENERIC = 1;
  192. ERROR_CODE_NO_SUCH_FILE = 2;
  193. ERROR_CODE_INVALID_FILE = 3;
  194. }
  195. // DownloadProgress
  196. message DownloadProgress {
  197. string folder = 1;
  198. repeated FileDownloadProgressUpdate updates = 2;
  199. }
  200. message FileDownloadProgressUpdate {
  201. FileDownloadProgressUpdateType update_type = 1;
  202. string name = 2;
  203. Vector version = 3;
  204. repeated int32 block_indexes = 4 [packed = false];
  205. int32 block_size = 5;
  206. }
  207. enum FileDownloadProgressUpdateType {
  208. FILE_DOWNLOAD_PROGRESS_UPDATE_TYPE_APPEND = 0;
  209. FILE_DOWNLOAD_PROGRESS_UPDATE_TYPE_FORGET = 1;
  210. }
  211. // Ping
  212. message Ping {}
  213. // Close
  214. message Close {
  215. string reason = 1;
  216. }