tunnelrpc.capnp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using Go = import "go.capnp";
  2. @0xdb8274f9144abc7e;
  3. $Go.package("tunnelrpc");
  4. $Go.import("github.com/cloudflare/cloudflared/tunnelrpc");
  5. struct Authentication {
  6. key @0 :Text;
  7. email @1 :Text;
  8. originCAKey @2 :Text;
  9. }
  10. struct TunnelRegistration {
  11. err @0 :Text;
  12. # the url to access the tunnel
  13. url @1 :Text;
  14. # Used to inform the client of actions taken.
  15. logLines @2 :List(Text);
  16. # In case of error, whether the client should attempt to reconnect.
  17. permanentFailure @3 :Bool;
  18. # Displayed to user
  19. tunnelID @4 :Text;
  20. # How long should this connection wait to retry in seconds, if the error wasn't permanent
  21. retryAfterSeconds @5 :UInt16;
  22. # A unique ID used to reconnect this tunnel.
  23. eventDigest @6 :Data;
  24. # A unique ID used to prove this tunnel was previously connected to a given metal.
  25. connDigest @7 :Data;
  26. }
  27. struct RegistrationOptions {
  28. # The tunnel client's unique identifier, used to verify a reconnection.
  29. clientId @0 :Text;
  30. # Information about the running binary.
  31. version @1 :Text;
  32. os @2 :Text;
  33. # What to do with existing tunnels for the given hostname.
  34. existingTunnelPolicy @3 :ExistingTunnelPolicy;
  35. # If using the balancing policy, identifies the LB pool to use.
  36. poolName @4 :Text;
  37. # Client-defined tags to associate with the tunnel
  38. tags @5 :List(Tag);
  39. # A unique identifier for a high-availability connection made by a single client.
  40. connectionId @6 :UInt8;
  41. # origin LAN IP
  42. originLocalIp @7 :Text;
  43. # whether Argo Tunnel client has been autoupdated
  44. isAutoupdated @8 :Bool;
  45. # whether Argo Tunnel client is run from a terminal
  46. runFromTerminal @9 :Bool;
  47. # cross stream compression setting, 0 - off, 3 - high
  48. compressionQuality @10 :UInt64;
  49. uuid @11 :Text;
  50. # number of previous attempts to send RegisterTunnel/ReconnectTunnel
  51. numPreviousAttempts @12 :UInt8;
  52. # Set of features this cloudflared knows it supports
  53. features @13 :List(Text);
  54. }
  55. struct Tag {
  56. name @0 :Text;
  57. value @1 :Text;
  58. }
  59. enum ExistingTunnelPolicy {
  60. ignore @0;
  61. disconnect @1;
  62. balance @2;
  63. }
  64. struct ServerInfo {
  65. locationName @0 :Text;
  66. }
  67. struct AuthenticateResponse {
  68. permanentErr @0 :Text;
  69. retryableErr @1 :Text;
  70. jwt @2 :Data;
  71. hoursUntilRefresh @3 :UInt8;
  72. }
  73. struct ClientInfo {
  74. # The tunnel client's unique identifier, used to verify a reconnection.
  75. clientId @0 :Data;
  76. # Set of features this cloudflared knows it supports
  77. features @1 :List(Text);
  78. # Information about the running binary.
  79. version @2 :Text;
  80. # Client OS and CPU info
  81. arch @3 :Text;
  82. }
  83. struct ConnectionOptions {
  84. # client details
  85. client @0 :ClientInfo;
  86. # origin LAN IP
  87. originLocalIp @1 :Data;
  88. # What to do if connection already exists
  89. replaceExisting @2 :Bool;
  90. # cross stream compression setting, 0 - off, 3 - high
  91. compressionQuality @3 :UInt8;
  92. # number of previous attempts to send RegisterConnection
  93. numPreviousAttempts @4 :UInt8;
  94. }
  95. struct ConnectionResponse {
  96. result :union {
  97. error @0 :ConnectionError;
  98. connectionDetails @1 :ConnectionDetails;
  99. }
  100. }
  101. struct ConnectionError {
  102. cause @0 :Text;
  103. # How long should this connection wait to retry in ns
  104. retryAfter @1 :Int64;
  105. shouldRetry @2 :Bool;
  106. }
  107. struct ConnectionDetails {
  108. # identifier of this connection
  109. uuid @0 :Data;
  110. # airport code of the colo where this connection landed
  111. locationName @1 :Text;
  112. }
  113. struct TunnelAuth {
  114. accountTag @0 :Text;
  115. tunnelSecret @1 :Data;
  116. }
  117. interface RegistrationServer {
  118. registerConnection @0 (auth :TunnelAuth, tunnelId :Data, connIndex :UInt8, options :ConnectionOptions) -> (result :ConnectionResponse);
  119. unregisterConnection @1 () -> ();
  120. }
  121. interface TunnelServer extends (RegistrationServer) {
  122. registerTunnel @0 (originCert :Data, hostname :Text, options :RegistrationOptions) -> (result :TunnelRegistration);
  123. getServerInfo @1 () -> (result :ServerInfo);
  124. unregisterTunnel @2 (gracePeriodNanoSec :Int64) -> ();
  125. # obsoleteDeclarativeTunnelConnect RPC deprecated in TUN-3019
  126. obsoleteDeclarativeTunnelConnect @3 () -> ();
  127. authenticate @4 (originCert :Data, hostname :Text, options :RegistrationOptions) -> (result :AuthenticateResponse);
  128. reconnectTunnel @5 (jwt :Data, eventDigest :Data, connDigest :Data, hostname :Text, options :RegistrationOptions) -> (result :TunnelRegistration);
  129. }