p2pd.proto 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. }
  77. message ErrorResponse {
  78. required string msg = 1;
  79. }
  80. message StreamInfo {
  81. required bytes peer = 1;
  82. required bytes addr = 2;
  83. required string proto = 3;
  84. }
  85. message DHTRequest {
  86. enum Type {
  87. FIND_PEER = 0;
  88. FIND_PEERS_CONNECTED_TO_PEER = 1;
  89. FIND_PROVIDERS = 2;
  90. GET_CLOSEST_PEERS = 3;
  91. GET_PUBLIC_KEY = 4;
  92. GET_VALUE = 5;
  93. SEARCH_VALUE = 6;
  94. PUT_VALUE = 7;
  95. PROVIDE = 8;
  96. }
  97. required Type type = 1;
  98. optional bytes peer = 2;
  99. optional bytes cid = 3;
  100. optional bytes key = 4;
  101. optional bytes value = 5;
  102. optional int32 count = 6;
  103. optional int64 timeout = 7;
  104. }
  105. message DHTResponse {
  106. enum Type {
  107. BEGIN = 0;
  108. VALUE = 1;
  109. END = 2;
  110. }
  111. required Type type = 1;
  112. optional PeerInfo peer = 2;
  113. optional bytes value = 3;
  114. }
  115. message PeerInfo {
  116. required bytes id = 1;
  117. repeated bytes addrs = 2;
  118. }
  119. message ConnManagerRequest {
  120. enum Type {
  121. TAG_PEER = 0;
  122. UNTAG_PEER = 1;
  123. TRIM = 2;
  124. }
  125. required Type type = 1;
  126. optional bytes peer = 2;
  127. optional string tag = 3;
  128. optional int64 weight = 4;
  129. }
  130. message DisconnectRequest {
  131. required bytes peer = 1;
  132. }
  133. message PSRequest {
  134. enum Type {
  135. GET_TOPICS = 0;
  136. LIST_PEERS = 1;
  137. PUBLISH = 2;
  138. SUBSCRIBE = 3;
  139. }
  140. required Type type = 1;
  141. optional string topic = 2;
  142. optional bytes data = 3;
  143. }
  144. message PSMessage {
  145. optional bytes from = 1;
  146. optional bytes data = 2;
  147. optional bytes seqno = 3;
  148. repeated string topicIDs = 4;
  149. optional bytes signature = 5;
  150. optional bytes key = 6;
  151. }
  152. message PSResponse {
  153. repeated string topics = 1;
  154. repeated bytes peerIDs = 2;
  155. }
  156. message CallUnaryRequest {
  157. required bytes peer = 1;
  158. required string proto = 2;
  159. required bytes data = 3;
  160. }
  161. message CallUnaryResponse {
  162. oneof result {
  163. bytes response = 1;
  164. bytes error = 2;
  165. }
  166. }
  167. message AddUnaryHandlerRequest {
  168. required string proto = 1;
  169. }
  170. message DaemonError {
  171. optional string message = 1;
  172. }
  173. message Cancel {
  174. }
  175. message RPCError {
  176. optional string message = 1;
  177. }