bep.proto 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. // protoc protoc -I ../../../../../ -I ../../../../gogo/protobuf/protobuf -I . --gogofast_out=. message.proto
  2. syntax = "proto3";
  3. package protocol;
  4. import "github.com/gogo/protobuf/gogoproto/gogo.proto";
  5. option (gogoproto.goproto_getters_all) = false;
  6. option (gogoproto.sizer_all) = false;
  7. option (gogoproto.protosizer_all) = true;
  8. option (gogoproto.goproto_enum_stringer_all) = true;
  9. option (gogoproto.goproto_enum_prefix_all) = false;
  10. // --- Pre-auth ---
  11. message Hello {
  12. string device_name = 1;
  13. string client_name = 2;
  14. string client_version = 3;
  15. }
  16. // --- Header ---
  17. message Header {
  18. MessageType type = 1;
  19. MessageCompression compression = 2;
  20. }
  21. enum MessageType {
  22. CLUSTER_CONFIG = 0 [(gogoproto.enumvalue_customname) = "messageTypeClusterConfig"];
  23. INDEX = 1 [(gogoproto.enumvalue_customname) = "messageTypeIndex"];
  24. INDEX_UPDATE = 2 [(gogoproto.enumvalue_customname) = "messageTypeIndexUpdate"];
  25. REQUEST = 3 [(gogoproto.enumvalue_customname) = "messageTypeRequest"];
  26. RESPONSE = 4 [(gogoproto.enumvalue_customname) = "messageTypeResponse"];
  27. DOWNLOAD_PROGRESS = 5 [(gogoproto.enumvalue_customname) = "messageTypeDownloadProgress"];
  28. PING = 6 [(gogoproto.enumvalue_customname) = "messageTypePing"];
  29. CLOSE = 7 [(gogoproto.enumvalue_customname) = "messageTypeClose"];
  30. }
  31. enum MessageCompression {
  32. NONE = 0 [(gogoproto.enumvalue_customname) = "MessageCompressionNone"];
  33. LZ4 = 1 [(gogoproto.enumvalue_customname) = "MessageCompressionLZ4"];
  34. }
  35. // --- Actual messages ---
  36. // Cluster Config
  37. message ClusterConfig {
  38. repeated Folder folders = 1 [(gogoproto.nullable) = false];
  39. }
  40. message Folder {
  41. string id = 1 [(gogoproto.customname) = "ID"];
  42. string label = 2;
  43. bool read_only = 3;
  44. bool ignore_permissions = 4;
  45. bool ignore_delete = 5;
  46. bool disable_temp_indexes = 6;
  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. bool deleted = 6;
  83. bool invalid = 7;
  84. bool no_permissions = 8;
  85. Vector version = 9 [(gogoproto.nullable) = false];
  86. int64 sequence = 10;
  87. repeated BlockInfo Blocks = 16 [(gogoproto.nullable) = false];
  88. }
  89. enum FileInfoType {
  90. FILE = 0 [(gogoproto.enumvalue_customname) = "FileInfoTypeFile"];
  91. DIRECTORY = 1 [(gogoproto.enumvalue_customname) = "FileInfoTypeDirectory"];
  92. SYMLINK_FILE = 2 [(gogoproto.enumvalue_customname) = "FileInfoTypeSymlinkFile"];
  93. SYMLINK_DIRECTORY = 3 [(gogoproto.enumvalue_customname) = "FileInfoTypeSymlinkDirectory"];
  94. SYMLINK_UNKNOWN = 4 [(gogoproto.enumvalue_customname) = "FileInfoTypeSymlinkUnknown"];
  95. }
  96. message BlockInfo {
  97. option (gogoproto.goproto_stringer) = false;
  98. int64 offset = 1;
  99. int32 size = 2;
  100. bytes hash = 3;
  101. }
  102. message Vector {
  103. repeated Counter counters = 1 [(gogoproto.nullable) = false];
  104. }
  105. message Counter {
  106. uint64 id = 1 [(gogoproto.customname) = "ID", (gogoproto.customtype) = "ShortID", (gogoproto.nullable) = false];
  107. uint64 value = 2;
  108. }
  109. // Request
  110. message Request {
  111. int32 id = 1 [(gogoproto.customname) = "ID"];
  112. string folder = 2;
  113. string name = 3;
  114. int64 offset = 4;
  115. int32 size = 5;
  116. bytes hash = 6;
  117. bool from_temporary = 7;
  118. }
  119. // Response
  120. message Response {
  121. int32 id = 1 [(gogoproto.customname) = "ID"];
  122. bytes data = 2;
  123. ErrorCode code = 3;
  124. }
  125. enum ErrorCode {
  126. NO_ERROR = 0 [(gogoproto.enumvalue_customname) = "ErrorCodeNoError"];
  127. GENERIC = 1 [(gogoproto.enumvalue_customname) = "ErrorCodeGeneric"];
  128. NO_SUCH_FILE = 2 [(gogoproto.enumvalue_customname) = "ErrorCodeNoSuchFile"];
  129. INVALID_FILE = 3 [(gogoproto.enumvalue_customname) = "ErrorCodeInvalidFile"];
  130. }
  131. // DownloadProgress
  132. message DownloadProgress {
  133. string folder = 1;
  134. repeated FileDownloadProgressUpdate updates = 2 [(gogoproto.nullable) = false];
  135. }
  136. message FileDownloadProgressUpdate {
  137. FileDownloadProgressUpdateType update_type = 1;
  138. string name = 2;
  139. Vector version = 3 [(gogoproto.nullable) = false];
  140. repeated int32 block_indexes = 4;
  141. }
  142. enum FileDownloadProgressUpdateType {
  143. APPEND = 0 [(gogoproto.enumvalue_customname) = "UpdateTypeAppend"];
  144. FORGET = 1 [(gogoproto.enumvalue_customname) = "UpdateTypeForget"];
  145. }
  146. // Ping
  147. message Ping {
  148. }
  149. // Close
  150. message Close {
  151. string reason = 1;
  152. }