rendezvous.proto 3.6 KB

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