bep.proto 5.8 KB

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