p2pd.proto 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. // Originally taken from: https://github.com/mhchia/py-libp2p-daemon-bindings
  2. // Licence: MIT
  3. // Author: Kevin Mai-Husan Chia
  4. syntax = "proto2";
  5. package p2pclient.p2pd.pb;
  6. message Request {
  7. enum Type {
  8. IDENTIFY = 0;
  9. CONNECT = 1;
  10. STREAM_OPEN = 2;
  11. STREAM_HANDLER = 3;
  12. DHT = 4;
  13. LIST_PEERS = 5;
  14. CONNMANAGER = 6;
  15. DISCONNECT = 7;
  16. PUBSUB = 8;
  17. PERSISTENT_CONN_UPGRADE = 9;
  18. }
  19. required Type type = 1;
  20. optional ConnectRequest connect = 2;
  21. optional StreamOpenRequest streamOpen = 3;
  22. optional StreamHandlerRequest streamHandler = 4;
  23. optional DHTRequest dht = 5;
  24. optional ConnManagerRequest connManager = 6;
  25. optional DisconnectRequest disconnect = 7;
  26. optional PSRequest pubsub = 8;
  27. }
  28. message Response {
  29. enum Type {
  30. OK = 0;
  31. ERROR = 1;
  32. }
  33. required Type type = 1;
  34. optional ErrorResponse error = 2;
  35. optional StreamInfo streamInfo = 3;
  36. optional IdentifyResponse identify = 4;
  37. optional DHTResponse dht = 5;
  38. repeated PeerInfo peers = 6;
  39. optional PSResponse pubsub = 7;
  40. }
  41. message PersistentConnectionRequest {
  42. required bytes callId = 1;
  43. oneof message {
  44. AddUnaryHandlerRequest addUnaryHandler = 2;
  45. CallUnaryRequest callUnary = 3;
  46. CallUnaryResponse unaryResponse = 4;
  47. Cancel cancel = 5;
  48. }
  49. }
  50. message PersistentConnectionResponse {
  51. required bytes callId = 1;
  52. oneof message {
  53. CallUnaryResponse callUnaryResponse = 2;
  54. CallUnaryRequest requestHandling = 3;
  55. DaemonError daemonError = 4;
  56. Cancel cancel = 5;
  57. }
  58. }
  59. message IdentifyResponse {
  60. required bytes id = 1;
  61. repeated bytes addrs = 2;
  62. }
  63. message ConnectRequest {
  64. required bytes peer = 1;
  65. repeated bytes addrs = 2;
  66. optional int64 timeout = 3;
  67. }
  68. message StreamOpenRequest {
  69. required bytes peer = 1;
  70. repeated string proto = 2;
  71. optional int64 timeout = 3;
  72. }
  73. message StreamHandlerRequest {
  74. required bytes addr = 1;
  75. repeated string proto = 2;
  76. required bool balanced = 3;
  77. }
  78. message ErrorResponse {
  79. required string msg = 1;
  80. }
  81. message StreamInfo {
  82. required bytes peer = 1;
  83. required bytes addr = 2;
  84. required string proto = 3;
  85. }
  86. message DHTRequest {
  87. enum Type {
  88. FIND_PEER = 0;
  89. FIND_PEERS_CONNECTED_TO_PEER = 1;
  90. FIND_PROVIDERS = 2;
  91. GET_CLOSEST_PEERS = 3;
  92. GET_PUBLIC_KEY = 4;
  93. GET_VALUE = 5;
  94. SEARCH_VALUE = 6;
  95. PUT_VALUE = 7;
  96. PROVIDE = 8;
  97. }
  98. required Type type = 1;
  99. optional bytes peer = 2;
  100. optional bytes cid = 3;
  101. optional bytes key = 4;
  102. optional bytes value = 5;
  103. optional int32 count = 6;
  104. optional int64 timeout = 7;
  105. }
  106. message DHTResponse {
  107. enum Type {
  108. BEGIN = 0;
  109. VALUE = 1;
  110. END = 2;
  111. }
  112. required Type type = 1;
  113. optional PeerInfo peer = 2;
  114. optional bytes value = 3;
  115. }
  116. message PeerInfo {
  117. required bytes id = 1;
  118. repeated bytes addrs = 2;
  119. }
  120. message ConnManagerRequest {
  121. enum Type {
  122. TAG_PEER = 0;
  123. UNTAG_PEER = 1;
  124. TRIM = 2;
  125. }
  126. required Type type = 1;
  127. optional bytes peer = 2;
  128. optional string tag = 3;
  129. optional int64 weight = 4;
  130. }
  131. message DisconnectRequest {
  132. required bytes peer = 1;
  133. }
  134. message PSRequest {
  135. enum Type {
  136. GET_TOPICS = 0;
  137. LIST_PEERS = 1;
  138. PUBLISH = 2;
  139. SUBSCRIBE = 3;
  140. }
  141. required Type type = 1;
  142. optional string topic = 2;
  143. optional bytes data = 3;
  144. }
  145. message PSMessage {
  146. optional bytes from = 1;
  147. optional bytes data = 2;
  148. optional bytes seqno = 3;
  149. repeated string topicIDs = 4;
  150. optional bytes signature = 5;
  151. optional bytes key = 6;
  152. }
  153. message PSResponse {
  154. repeated string topics = 1;
  155. repeated bytes peerIDs = 2;
  156. }
  157. message CallUnaryRequest {
  158. required bytes peer = 1;
  159. required string proto = 2;
  160. required bytes data = 3;
  161. }
  162. message CallUnaryResponse {
  163. oneof result {
  164. bytes response = 1;
  165. bytes error = 2;
  166. }
  167. }
  168. message AddUnaryHandlerRequest {
  169. required string proto = 1;
  170. required bool balanced = 2;
  171. }
  172. message DaemonError {
  173. optional string message = 1;
  174. }
  175. message Cancel {
  176. }
  177. message RPCError {
  178. optional string message = 1;
  179. }