bep.proto 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. string name = 1;
  80. FileInfoType type = 2;
  81. int64 size = 3;
  82. uint32 permissions = 4;
  83. int64 modified_s = 5;
  84. int32 modified_ns = 11;
  85. uint64 modified_by = 12 [(gogoproto.customtype) = "ShortID", (gogoproto.nullable) = false];
  86. bool deleted = 6;
  87. bool invalid = 7 [(gogoproto.customname) = "RawInvalid"];
  88. bool no_permissions = 8;
  89. Vector version = 9 [(gogoproto.nullable) = false];
  90. int64 sequence = 10;
  91. int32 block_size = 13 [(gogoproto.customname) = "RawBlockSize"];
  92. repeated BlockInfo Blocks = 16 [(gogoproto.nullable) = false];
  93. string symlink_target = 17;
  94. // The local_flags fields stores flags that are relevant to the local
  95. // host only. It is not part of the protocol, doesn't get sent or
  96. // received (we make sure to zero it), nonetheless we need it on our
  97. // struct and to be able to serialize it to/from the database.
  98. uint32 local_flags = 1000;
  99. }
  100. enum FileInfoType {
  101. FILE = 0 [(gogoproto.enumvalue_customname) = "FileInfoTypeFile"];
  102. DIRECTORY = 1 [(gogoproto.enumvalue_customname) = "FileInfoTypeDirectory"];
  103. SYMLINK_FILE = 2 [(gogoproto.enumvalue_customname) = "FileInfoTypeDeprecatedSymlinkFile", deprecated = true];
  104. SYMLINK_DIRECTORY = 3 [(gogoproto.enumvalue_customname) = "FileInfoTypeDeprecatedSymlinkDirectory", deprecated = true];
  105. SYMLINK = 4 [(gogoproto.enumvalue_customname) = "FileInfoTypeSymlink"];
  106. }
  107. message BlockInfo {
  108. option (gogoproto.goproto_stringer) = false;
  109. int64 offset = 1;
  110. int32 size = 2;
  111. bytes hash = 3;
  112. uint32 weak_hash = 4;
  113. }
  114. message Vector {
  115. repeated Counter counters = 1 [(gogoproto.nullable) = false];
  116. }
  117. message Counter {
  118. uint64 id = 1 [(gogoproto.customname) = "ID", (gogoproto.customtype) = "ShortID", (gogoproto.nullable) = false];
  119. uint64 value = 2;
  120. }
  121. // Request
  122. message Request {
  123. int32 id = 1 [(gogoproto.customname) = "ID"];
  124. string folder = 2;
  125. string name = 3;
  126. int64 offset = 4;
  127. int32 size = 5;
  128. bytes hash = 6;
  129. bool from_temporary = 7;
  130. uint32 weak_hash = 8;
  131. }
  132. // Response
  133. message Response {
  134. int32 id = 1 [(gogoproto.customname) = "ID"];
  135. bytes data = 2;
  136. ErrorCode code = 3;
  137. }
  138. enum ErrorCode {
  139. NO_ERROR = 0 [(gogoproto.enumvalue_customname) = "ErrorCodeNoError"];
  140. GENERIC = 1 [(gogoproto.enumvalue_customname) = "ErrorCodeGeneric"];
  141. NO_SUCH_FILE = 2 [(gogoproto.enumvalue_customname) = "ErrorCodeNoSuchFile"];
  142. INVALID_FILE = 3 [(gogoproto.enumvalue_customname) = "ErrorCodeInvalidFile"];
  143. }
  144. // DownloadProgress
  145. message DownloadProgress {
  146. string folder = 1;
  147. repeated FileDownloadProgressUpdate updates = 2 [(gogoproto.nullable) = false];
  148. }
  149. message FileDownloadProgressUpdate {
  150. FileDownloadProgressUpdateType update_type = 1;
  151. string name = 2;
  152. Vector version = 3 [(gogoproto.nullable) = false];
  153. repeated int32 block_indexes = 4 [packed=false];
  154. }
  155. enum FileDownloadProgressUpdateType {
  156. APPEND = 0 [(gogoproto.enumvalue_customname) = "UpdateTypeAppend"];
  157. FORGET = 1 [(gogoproto.enumvalue_customname) = "UpdateTypeForget"];
  158. }
  159. // Ping
  160. message Ping {
  161. }
  162. // Close
  163. message Close {
  164. string reason = 1;
  165. }