bep.proto 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. repeated BlockInfo Blocks = 16 [(gogoproto.nullable) = false];
  89. string symlink_target = 17;
  90. }
  91. enum FileInfoType {
  92. FILE = 0 [(gogoproto.enumvalue_customname) = "FileInfoTypeFile"];
  93. DIRECTORY = 1 [(gogoproto.enumvalue_customname) = "FileInfoTypeDirectory"];
  94. SYMLINK_FILE = 2 [(gogoproto.enumvalue_customname) = "FileInfoTypeDeprecatedSymlinkFile", deprecated = true];
  95. SYMLINK_DIRECTORY = 3 [(gogoproto.enumvalue_customname) = "FileInfoTypeDeprecatedSymlinkDirectory", deprecated = true];
  96. SYMLINK = 4 [(gogoproto.enumvalue_customname) = "FileInfoTypeSymlink"];
  97. }
  98. message BlockInfo {
  99. option (gogoproto.goproto_stringer) = false;
  100. int64 offset = 1;
  101. int32 size = 2;
  102. bytes hash = 3;
  103. uint32 weak_hash = 4;
  104. }
  105. message Vector {
  106. repeated Counter counters = 1 [(gogoproto.nullable) = false];
  107. }
  108. message Counter {
  109. uint64 id = 1 [(gogoproto.customname) = "ID", (gogoproto.customtype) = "ShortID", (gogoproto.nullable) = false];
  110. uint64 value = 2;
  111. }
  112. // Request
  113. message Request {
  114. int32 id = 1 [(gogoproto.customname) = "ID"];
  115. string folder = 2;
  116. string name = 3;
  117. int64 offset = 4;
  118. int32 size = 5;
  119. bytes hash = 6;
  120. bool from_temporary = 7;
  121. }
  122. // Response
  123. message Response {
  124. int32 id = 1 [(gogoproto.customname) = "ID"];
  125. bytes data = 2;
  126. ErrorCode code = 3;
  127. }
  128. enum ErrorCode {
  129. NO_ERROR = 0 [(gogoproto.enumvalue_customname) = "ErrorCodeNoError"];
  130. GENERIC = 1 [(gogoproto.enumvalue_customname) = "ErrorCodeGeneric"];
  131. NO_SUCH_FILE = 2 [(gogoproto.enumvalue_customname) = "ErrorCodeNoSuchFile"];
  132. INVALID_FILE = 3 [(gogoproto.enumvalue_customname) = "ErrorCodeInvalidFile"];
  133. }
  134. // DownloadProgress
  135. message DownloadProgress {
  136. string folder = 1;
  137. repeated FileDownloadProgressUpdate updates = 2 [(gogoproto.nullable) = false];
  138. }
  139. message FileDownloadProgressUpdate {
  140. FileDownloadProgressUpdateType update_type = 1;
  141. string name = 2;
  142. Vector version = 3 [(gogoproto.nullable) = false];
  143. repeated int32 block_indexes = 4 [packed=false];
  144. }
  145. enum FileDownloadProgressUpdateType {
  146. APPEND = 0 [(gogoproto.enumvalue_customname) = "UpdateTypeAppend"];
  147. FORGET = 1 [(gogoproto.enumvalue_customname) = "UpdateTypeForget"];
  148. }
  149. // Ping
  150. message Ping {
  151. }
  152. // Close
  153. message Close {
  154. string reason = 1;
  155. }