bep.proto 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. syntax = "proto3";
  2. package protocol;
  3. import "repos/protobuf/gogoproto/gogo.proto";
  4. option (gogoproto.goproto_getters_all) = false;
  5. option (gogoproto.sizer_all) = false;
  6. option (gogoproto.protosizer_all) = true;
  7. option (gogoproto.goproto_enum_stringer_all) = true;
  8. option (gogoproto.goproto_enum_prefix_all) = false;
  9. option (gogoproto.goproto_unkeyed_all) = false;
  10. option (gogoproto.goproto_unrecognized_all) = false;
  11. option (gogoproto.goproto_sizecache_all) = false;
  12. // --- Pre-auth ---
  13. message Hello {
  14. string device_name = 1;
  15. string client_name = 2;
  16. string client_version = 3;
  17. }
  18. // --- Header ---
  19. message Header {
  20. MessageType type = 1;
  21. MessageCompression compression = 2;
  22. }
  23. enum MessageType {
  24. CLUSTER_CONFIG = 0 [(gogoproto.enumvalue_customname) = "messageTypeClusterConfig"];
  25. INDEX = 1 [(gogoproto.enumvalue_customname) = "messageTypeIndex"];
  26. INDEX_UPDATE = 2 [(gogoproto.enumvalue_customname) = "messageTypeIndexUpdate"];
  27. REQUEST = 3 [(gogoproto.enumvalue_customname) = "messageTypeRequest"];
  28. RESPONSE = 4 [(gogoproto.enumvalue_customname) = "messageTypeResponse"];
  29. DOWNLOAD_PROGRESS = 5 [(gogoproto.enumvalue_customname) = "messageTypeDownloadProgress"];
  30. PING = 6 [(gogoproto.enumvalue_customname) = "messageTypePing"];
  31. CLOSE = 7 [(gogoproto.enumvalue_customname) = "messageTypeClose"];
  32. }
  33. enum MessageCompression {
  34. NONE = 0 [(gogoproto.enumvalue_customname) = "MessageCompressionNone"];
  35. LZ4 = 1 [(gogoproto.enumvalue_customname) = "MessageCompressionLZ4"];
  36. }
  37. // --- Actual messages ---
  38. // Cluster Config
  39. message ClusterConfig {
  40. repeated Folder folders = 1 [(gogoproto.nullable) = false];
  41. }
  42. message Folder {
  43. string id = 1 [(gogoproto.customname) = "ID"];
  44. string label = 2;
  45. bool read_only = 3;
  46. bool ignore_permissions = 4;
  47. bool ignore_delete = 5;
  48. bool disable_temp_indexes = 6;
  49. bool paused = 7;
  50. repeated Device devices = 16 [(gogoproto.nullable) = false];
  51. }
  52. message Device {
  53. bytes id = 1 [(gogoproto.customname) = "ID", (gogoproto.customtype) = "DeviceID", (gogoproto.nullable) = false];
  54. string name = 2;
  55. repeated string addresses = 3;
  56. Compression compression = 4;
  57. string cert_name = 5;
  58. int64 max_sequence = 6;
  59. bool introducer = 7;
  60. uint64 index_id = 8 [(gogoproto.customname) = "IndexID", (gogoproto.customtype) = "IndexID", (gogoproto.nullable) = false];
  61. bool skip_introduction_removals = 9;
  62. }
  63. enum Compression {
  64. METADATA = 0 [(gogoproto.enumvalue_customname) = "CompressMetadata"];
  65. NEVER = 1 [(gogoproto.enumvalue_customname) = "CompressNever"];
  66. ALWAYS = 2 [(gogoproto.enumvalue_customname) = "CompressAlways"];
  67. }
  68. // Index and Index Update
  69. message Index {
  70. string folder = 1;
  71. repeated FileInfo files = 2 [(gogoproto.nullable) = false];
  72. }
  73. message IndexUpdate {
  74. string folder = 1;
  75. repeated FileInfo files = 2 [(gogoproto.nullable) = false];
  76. }
  77. message FileInfo {
  78. option (gogoproto.goproto_stringer) = false;
  79. // The field ordering here optimizes for struct size / alignment --
  80. // large types come before smaller ones.
  81. string name = 1;
  82. int64 size = 3;
  83. int64 modified_s = 5;
  84. uint64 modified_by = 12 [(gogoproto.customtype) = "ShortID", (gogoproto.nullable) = false];
  85. Vector version = 9 [(gogoproto.nullable) = false];
  86. int64 sequence = 10;
  87. repeated BlockInfo Blocks = 16 [(gogoproto.nullable) = false];
  88. string symlink_target = 17;
  89. FileInfoType type = 2;
  90. uint32 permissions = 4;
  91. int32 modified_ns = 11;
  92. int32 block_size = 13 [(gogoproto.customname) = "RawBlockSize"];
  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. bool deleted = 6;
  99. bool invalid = 7 [(gogoproto.customname) = "RawInvalid"];
  100. bool no_permissions = 8;
  101. }
  102. enum FileInfoType {
  103. FILE = 0 [(gogoproto.enumvalue_customname) = "FileInfoTypeFile"];
  104. DIRECTORY = 1 [(gogoproto.enumvalue_customname) = "FileInfoTypeDirectory"];
  105. SYMLINK_FILE = 2 [(gogoproto.enumvalue_customname) = "FileInfoTypeDeprecatedSymlinkFile", deprecated = true];
  106. SYMLINK_DIRECTORY = 3 [(gogoproto.enumvalue_customname) = "FileInfoTypeDeprecatedSymlinkDirectory", deprecated = true];
  107. SYMLINK = 4 [(gogoproto.enumvalue_customname) = "FileInfoTypeSymlink"];
  108. }
  109. message BlockInfo {
  110. option (gogoproto.goproto_stringer) = false;
  111. bytes hash = 3;
  112. int64 offset = 1;
  113. int32 size = 2;
  114. uint32 weak_hash = 4;
  115. }
  116. message Vector {
  117. repeated Counter counters = 1 [(gogoproto.nullable) = false];
  118. }
  119. message Counter {
  120. uint64 id = 1 [(gogoproto.customname) = "ID", (gogoproto.customtype) = "ShortID", (gogoproto.nullable) = false];
  121. uint64 value = 2;
  122. }
  123. // Request
  124. message Request {
  125. int32 id = 1 [(gogoproto.customname) = "ID"];
  126. string folder = 2;
  127. string name = 3;
  128. int64 offset = 4;
  129. int32 size = 5;
  130. bytes hash = 6;
  131. bool from_temporary = 7;
  132. uint32 weak_hash = 8;
  133. }
  134. // Response
  135. message Response {
  136. int32 id = 1 [(gogoproto.customname) = "ID"];
  137. bytes data = 2;
  138. ErrorCode code = 3;
  139. }
  140. enum ErrorCode {
  141. NO_ERROR = 0 [(gogoproto.enumvalue_customname) = "ErrorCodeNoError"];
  142. GENERIC = 1 [(gogoproto.enumvalue_customname) = "ErrorCodeGeneric"];
  143. NO_SUCH_FILE = 2 [(gogoproto.enumvalue_customname) = "ErrorCodeNoSuchFile"];
  144. INVALID_FILE = 3 [(gogoproto.enumvalue_customname) = "ErrorCodeInvalidFile"];
  145. }
  146. // DownloadProgress
  147. message DownloadProgress {
  148. string folder = 1;
  149. repeated FileDownloadProgressUpdate updates = 2 [(gogoproto.nullable) = false];
  150. }
  151. message FileDownloadProgressUpdate {
  152. FileDownloadProgressUpdateType update_type = 1;
  153. string name = 2;
  154. Vector version = 3 [(gogoproto.nullable) = false];
  155. repeated int32 block_indexes = 4 [packed=false];
  156. }
  157. enum FileDownloadProgressUpdateType {
  158. APPEND = 0 [(gogoproto.enumvalue_customname) = "UpdateTypeAppend"];
  159. FORGET = 1 [(gogoproto.enumvalue_customname) = "UpdateTypeForget"];
  160. }
  161. // Ping
  162. message Ping {
  163. }
  164. // Close
  165. message Close {
  166. string reason = 1;
  167. }