rendezvous.proto 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. syntax = "proto3";
  2. package hbb;
  3. message RegisterPeer {
  4. string id = 1;
  5. int32 serial = 2;
  6. }
  7. enum ConnType {
  8. DEFAULT_CONN = 0;
  9. FILE_TRANSFER = 1;
  10. PORT_FORWARD = 2;
  11. RDP = 3;
  12. }
  13. message RegisterPeerResponse { bool request_pk = 2; }
  14. message PunchHoleRequest {
  15. string id = 1;
  16. NatType nat_type = 2;
  17. string licence_key = 3;
  18. ConnType conn_type = 4;
  19. string token = 5;
  20. string version = 6;
  21. }
  22. message PunchHole {
  23. bytes socket_addr = 1;
  24. string relay_server = 2;
  25. NatType nat_type = 3;
  26. }
  27. message TestNatRequest {
  28. int32 serial = 1;
  29. }
  30. // per my test, uint/int has no difference in encoding, int not good for negative, use sint for negative
  31. message TestNatResponse {
  32. int32 port = 1;
  33. ConfigUpdate cu = 2; // for mobile
  34. }
  35. enum NatType {
  36. UNKNOWN_NAT = 0;
  37. ASYMMETRIC = 1;
  38. SYMMETRIC = 2;
  39. }
  40. message PunchHoleSent {
  41. bytes socket_addr = 1;
  42. string id = 2;
  43. string relay_server = 3;
  44. NatType nat_type = 4;
  45. string version = 5;
  46. }
  47. message RegisterPk {
  48. string id = 1;
  49. bytes uuid = 2;
  50. bytes pk = 3;
  51. string old_id = 4;
  52. }
  53. message RegisterPkResponse {
  54. enum Result {
  55. OK = 0;
  56. UUID_MISMATCH = 2;
  57. ID_EXISTS = 3;
  58. TOO_FREQUENT = 4;
  59. INVALID_ID_FORMAT = 5;
  60. NOT_SUPPORT = 6;
  61. SERVER_ERROR = 7;
  62. }
  63. Result result = 1;
  64. int32 keep_alive = 2;
  65. }
  66. message PunchHoleResponse {
  67. bytes socket_addr = 1;
  68. bytes pk = 2;
  69. enum Failure {
  70. ID_NOT_EXIST = 0;
  71. OFFLINE = 2;
  72. LICENSE_MISMATCH = 3;
  73. LICENSE_OVERUSE = 4;
  74. }
  75. Failure failure = 3;
  76. string relay_server = 4;
  77. oneof union {
  78. NatType nat_type = 5;
  79. bool is_local = 6;
  80. }
  81. string other_failure = 7;
  82. int32 feedback = 8;
  83. }
  84. message ConfigUpdate {
  85. int32 serial = 1;
  86. repeated string rendezvous_servers = 2;
  87. }
  88. message RequestRelay {
  89. string id = 1;
  90. string uuid = 2;
  91. bytes socket_addr = 3;
  92. string relay_server = 4;
  93. bool secure = 5;
  94. string licence_key = 6;
  95. ConnType conn_type = 7;
  96. string token = 8;
  97. }
  98. message RelayResponse {
  99. bytes socket_addr = 1;
  100. string uuid = 2;
  101. string relay_server = 3;
  102. oneof union {
  103. string id = 4;
  104. bytes pk = 5;
  105. }
  106. string refuse_reason = 6;
  107. string version = 7;
  108. int32 feedback = 9;
  109. }
  110. message SoftwareUpdate { string url = 1; }
  111. // if in same intranet, punch hole won't work both for udp and tcp,
  112. // even some router has below connection error if we connect itself,
  113. // { kind: Other, error: "could not resolve to any address" },
  114. // so we request local address to connect.
  115. message FetchLocalAddr {
  116. bytes socket_addr = 1;
  117. string relay_server = 2;
  118. }
  119. message LocalAddr {
  120. bytes socket_addr = 1;
  121. bytes local_addr = 2;
  122. string relay_server = 3;
  123. string id = 4;
  124. string version = 5;
  125. }
  126. message PeerDiscovery {
  127. string cmd = 1;
  128. string mac = 2;
  129. string id = 3;
  130. string username = 4;
  131. string hostname = 5;
  132. string platform = 6;
  133. string misc = 7;
  134. }
  135. message OnlineRequest {
  136. string id = 1;
  137. repeated string peers = 2;
  138. }
  139. message OnlineResponse {
  140. bytes states = 1;
  141. }
  142. message KeyExchange {
  143. repeated bytes keys = 1;
  144. }
  145. message HealthCheck {
  146. string token = 1;
  147. }
  148. message RendezvousMessage {
  149. oneof union {
  150. RegisterPeer register_peer = 6;
  151. RegisterPeerResponse register_peer_response = 7;
  152. PunchHoleRequest punch_hole_request = 8;
  153. PunchHole punch_hole = 9;
  154. PunchHoleSent punch_hole_sent = 10;
  155. PunchHoleResponse punch_hole_response = 11;
  156. FetchLocalAddr fetch_local_addr = 12;
  157. LocalAddr local_addr = 13;
  158. ConfigUpdate configure_update = 14;
  159. RegisterPk register_pk = 15;
  160. RegisterPkResponse register_pk_response = 16;
  161. SoftwareUpdate software_update = 17;
  162. RequestRelay request_relay = 18;
  163. RelayResponse relay_response = 19;
  164. TestNatRequest test_nat_request = 20;
  165. TestNatResponse test_nat_response = 21;
  166. PeerDiscovery peer_discovery = 22;
  167. OnlineRequest online_request = 23;
  168. OnlineResponse online_response = 24;
  169. KeyExchange key_exchange = 25;
  170. HealthCheck hc = 26;
  171. }
  172. }