Skip to content
File

Blob: spec/proto/tunnel.proto

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