p2pd.proto 4.5 KB

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