bep.proto 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. }
  59. enum Compression {
  60. METADATA = 0 [(gogoproto.enumvalue_customname) = "CompressMetadata"];
  61. NEVER = 1 [(gogoproto.enumvalue_customname) = "CompressNever"];
  62. ALWAYS = 2 [(gogoproto.enumvalue_customname) = "CompressAlways"];
  63. }
  64. // Index and Index Update
  65. message Index {
  66. string folder = 1;
  67. repeated FileInfo files = 2 [(gogoproto.nullable) = false];
  68. }
  69. message IndexUpdate {
  70. string folder = 1;
  71. repeated FileInfo files = 2 [(gogoproto.nullable) = false];
  72. }
  73. message FileInfo {
  74. option (gogoproto.goproto_stringer) = false;
  75. string name = 1;
  76. FileInfoType type = 2;
  77. int64 size = 3;
  78. uint32 permissions = 4;
  79. int64 modified_s = 5;
  80. int32 modified_ns = 11;
  81. bool deleted = 6;
  82. bool invalid = 7;
  83. bool no_permissions = 8;
  84. Vector version = 9 [(gogoproto.nullable) = false];
  85. int64 sequence = 10;
  86. repeated BlockInfo Blocks = 16 [(gogoproto.nullable) = false];
  87. }
  88. enum FileInfoType {
  89. FILE = 0 [(gogoproto.enumvalue_customname) = "FileInfoTypeFile"];
  90. DIRECTORY = 1 [(gogoproto.enumvalue_customname) = "FileInfoTypeDirectory"];
  91. SYMLINK_FILE = 2 [(gogoproto.enumvalue_customname) = "FileInfoTypeSymlinkFile"];
  92. SYMLINK_DIRECTORY = 3 [(gogoproto.enumvalue_customname) = "FileInfoTypeSymlinkDirectory"];
  93. SYMLINK_UNKNOWN = 4 [(gogoproto.enumvalue_customname) = "FileInfoTypeSymlinkUnknown"];
  94. }
  95. message BlockInfo {
  96. option (gogoproto.goproto_stringer) = false;
  97. int64 offset = 1;
  98. int32 size = 2;
  99. bytes hash = 3;
  100. }
  101. message Vector {
  102. repeated Counter counters = 1 [(gogoproto.nullable) = false];
  103. }
  104. message Counter {
  105. uint64 id = 1 [(gogoproto.customname) = "ID", (gogoproto.customtype) = "ShortID", (gogoproto.nullable) = false];
  106. uint64 value = 2;
  107. }
  108. // Request
  109. message Request {
  110. int32 id = 1 [(gogoproto.customname) = "ID"];
  111. string folder = 2;
  112. string name = 3;
  113. int64 offset = 4;
  114. int32 size = 5;
  115. bytes hash = 6;
  116. bool from_temporary = 7;
  117. }
  118. // Response
  119. message Response {
  120. int32 id = 1 [(gogoproto.customname) = "ID"];
  121. bytes data = 2;
  122. ErrorCode code = 3;
  123. }
  124. enum ErrorCode {
  125. NO_ERROR = 0 [(gogoproto.enumvalue_customname) = "ErrorCodeNoError"];
  126. GENERIC = 1 [(gogoproto.enumvalue_customname) = "ErrorCodeGeneric"];
  127. NO_SUCH_FILE = 2 [(gogoproto.enumvalue_customname) = "ErrorCodeNoSuchFile"];
  128. INVALID_FILE = 3 [(gogoproto.enumvalue_customname) = "ErrorCodeInvalidFile"];
  129. }
  130. // DownloadProgress
  131. message DownloadProgress {
  132. string folder = 1;
  133. repeated FileDownloadProgressUpdate updates = 2 [(gogoproto.nullable) = false];
  134. }
  135. message FileDownloadProgressUpdate {
  136. FileDownloadProgressUpdateType update_type = 1;
  137. string name = 2;
  138. Vector version = 3 [(gogoproto.nullable) = false];
  139. repeated int32 block_indexes = 4;
  140. }
  141. enum FileDownloadProgressUpdateType {
  142. APPEND = 0 [(gogoproto.enumvalue_customname) = "UpdateTypeAppend"];
  143. FORGET = 1 [(gogoproto.enumvalue_customname) = "UpdateTypeForget"];
  144. }
  145. // Ping
  146. message Ping {
  147. }
  148. // Close
  149. message Close {
  150. string reason = 1;
  151. }