bep.proto 5.7 KB

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