bep.proto 6.3 KB

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