Skip to content
File

Blob: spec/proto/tunnel.proto

protobuf214 lines
1syntax = "proto3";
2package protocol;
3 
4option optimize_for = SPEED;
5option go_package = "go.miragespace.co/specter/spec/protocol";
6 
7import "spec/proto/node.proto";
8import "spec/proto/pow.proto";
9 
10import "google/protobuf/descriptor.proto";
11 
12service TunnelService {
13 rpc MintDelegation(MintDelegationRequest) returns (MintDelegationResponse);
14 rpc ListDelegations(ListDelegationsRequest) returns (ListDelegationsResponse);
15 rpc RevokeDelegation(RevokeDelegationRequest) returns (RevokeDelegationResponse);
16 rpc Ping(ClientPingRequest) returns (ClientPingResponse);
17 rpc RegisterIdentity(RegisterIdentityRequest) returns (RegisterIdentityResponse);
18 rpc GetNodes(GetNodesRequest) returns (GetNodesResponse);
19 rpc GenerateHostname(GenerateHostnameRequest) returns (GenerateHostnameResponse);
20 rpc RegisteredHostnames(RegisteredHostnamesRequest) returns (RegisteredHostnamesResponse);
21 rpc PublishTunnel(PublishTunnelRequest) returns (PublishTunnelResponse);
22 rpc UnpublishTunnel(UnpublishTunnelRequest) returns (UnpublishTunnelResponse);
23 rpc ReleaseTunnel(ReleaseTunnelRequest) returns (ReleaseTunnelResponse);
24 
25 rpc AcmeInstruction(InstructionRequest) returns (InstructionResponse);
26 rpc AcmeValidate(ValidateRequest) returns (ValidateResponse);
27 
28 rpc OpenEphemeralSession(OpenEphemeralSessionRequest) returns (OpenSessionResponse);
29 rpc OpenDelegatedSession(OpenDelegatedSessionRequest) returns (OpenSessionResponse);
30}
31 
32extend google.protobuf.EnumValueOptions {
33 string alpn_name = 54242;
34}
35 
36message Link {
37 enum ALPN {
38 UNKNOWN = 0;
39 SPECTER_CHORD = 1 [(alpn_name) = "specter-chord/1"];
40 SPECTER_CLIENT = 2 [(alpn_name) = "specter-client/1"];
41 
42 HTTP2 = 9 [(alpn_name) = "h2"];
43 HTTP = 10 [(alpn_name) = "http/1.1"];
44 TCP = 11 [(alpn_name) = "specter-tcp/1"];
45 }
46 
47 ALPN alpn = 1;
48 string hostname = 2;
49 string remote = 3;
50}
51 
52message CustomHostname {
53 Node client_identity = 1;
54 ClientToken client_token = 2;
55}
56 
57message TunnelRoute {
58 Node client_destination = 1;
59 Node chord_destination = 2;
60 Node tunnel_destination = 3;
61 
62 string hostname = 10;
63}
64 
65message TunnelDestination {
66 Node chord = 1;
67 Node tunnel = 2;
68}
69 
70enum TunnelStatusCode {
71 STATUS_OK = 0;
72 
73 UNKNOWN_ERROR = 1;
74 NO_DIRECT = 2;
75}
76 
77message TunnelStatus {
78 TunnelStatusCode status = 2;
79 string error = 3;
80}
81 
82message ClientToken {
83 bytes token = 1;
84}
85 
86message ClientPingRequest {}
87 
88message ClientPingResponse {
89 Node node = 1;
90 string apex = 2;
91}
92 
93message RegisterIdentityRequest {
94}
95 
96message RegisterIdentityResponse {
97 string apex = 2;
98}
99 
100message GetNodesRequest {}
101 
102message GetNodesResponse {
103 repeated Node nodes = 1;
104}
105 
106message GenerateHostnameRequest {}
107 
108message GenerateHostnameResponse {
109 string hostname = 1;
110}
111 
112message RegisteredHostnamesRequest {}
113 
114message RegisteredHostnamesResponse {
115 repeated string hostnames = 1;
116}
117 
118message PublishTunnelRequest {
119 string hostname = 1;
120 // servers are tun identities
121 repeated Node servers = 2;
122}
123 
124message PublishTunnelResponse {
125 repeated Node published = 1;
126}
127 
128message UnpublishTunnelRequest {
129 string hostname = 1;
130}
131 
132message UnpublishTunnelResponse {}
133 
134message ReleaseTunnelRequest {
135 string hostname = 1;
136}
137 
138message ReleaseTunnelResponse {}
139 
140message InstructionRequest {
141 ProofOfWork proof = 1;
142 string hostname = 2;
143}
144 
145message InstructionResponse {
146 string name = 1;
147 string content = 2;
148}
149 
150message ValidateRequest {
151 ProofOfWork proof = 1;
152 string hostname = 2;
153}
154 
155message ValidateResponse {
156 string apex = 1;
157}
158 
159message DelegationRecord {
160 uint32 version = 1;
161 string id = 2;
162 ClientToken owner = 3;
163 string hostname = 4;
164 int64 expires_at = 5;
165}
166 
167message DelegationGrant {
168 string id = 1;
169 string hostname = 2;
170 int64 expires_at = 3;
171 bool incomplete = 4;
172}
173 
174message MintDelegationRequest {
175 string hostname = 1;
176 int64 expires_at = 2;
177}
178 
179message MintDelegationResponse {
180 DelegationGrant grant = 1;
181 string token = 2;
182}
183 
184message ListDelegationsRequest {}
185 
186message ListDelegationsResponse {
187 repeated DelegationGrant grants = 1;
188}
189 
190message RevokeDelegationRequest {
191 string id = 1;
192}
193 
194message RevokeDelegationResponse {
195 bool revoked = 1;
196 string index_error = 2;
197}
198 
199message OpenEphemeralSessionRequest {}
200 
201message OpenDelegatedSessionRequest {
202 string token = 1;
203 // Each attachment publishes exactly one of the three numbered routes.
204 uint32 route_slot = 2;
205}
206 
207message OpenSessionResponse {
208 string hostname = 1;
209 string apex = 2;
210 string grant_id = 3;
211 int64 expires_at = 4;
212 Node node = 5;
213}